From ce51edcf80cbecab6f04db4704ddcf21c804f3b0 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 17 Sep 2018 16:55:22 +0100 Subject: Implement new responsive, dev section header and home scaffolding --- .../documentation/docs_content_top_bar.tsx | 47 +++++++------ .../ts/components/documentation/docs_logo.tsx | 15 ++++- packages/website/ts/components/ui/container.tsx | 1 + packages/website/ts/containers/docs_home.ts | 15 ++++- packages/website/ts/pages/documentation/home.tsx | 78 +++++++++++++++------- 5 files changed, 103 insertions(+), 53 deletions(-) (limited to 'packages') diff --git a/packages/website/ts/components/documentation/docs_content_top_bar.tsx b/packages/website/ts/components/documentation/docs_content_top_bar.tsx index c2bbfc417..148f2f7cb 100644 --- a/packages/website/ts/components/documentation/docs_content_top_bar.tsx +++ b/packages/website/ts/components/documentation/docs_content_top_bar.tsx @@ -3,6 +3,7 @@ import * as _ from 'lodash'; import Drawer from 'material-ui/Drawer'; import * as React from 'react'; import { Link } from 'react-router-dom'; +import { DocsLogo } from 'ts/components/documentation/docs_logo'; import { Container } from 'ts/components/ui/container'; import { Deco, Key, ObjectMap, WebsitePaths } from 'ts/types'; import { constants } from 'ts/utils/constants'; @@ -17,17 +18,6 @@ interface DocsContentTopBarState { isDrawerOpen: boolean; } -const styles: Styles = { - menuItem: { - fontSize: 14, - color: colors.darkestGrey, - paddingTop: 6, - paddingBottom: 6, - cursor: 'pointer', - fontWeight: 400, - }, -}; - interface MenuItemInfo { title: string; url: string; @@ -50,11 +40,6 @@ export class DocsContentTopBar extends React.Component - -
+ + +
-
+
+
{this._renderMenuItems(menuItemInfos)}
-
-
- +
+ +
+
+
+
@@ -110,7 +109,7 @@ export class DocsContentTopBar extends React.Component {this._renderDrawer()} -
+ ); } private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode { diff --git a/packages/website/ts/components/documentation/docs_logo.tsx b/packages/website/ts/components/documentation/docs_logo.tsx index 2a539c84b..9daf84ad0 100644 --- a/packages/website/ts/components/documentation/docs_logo.tsx +++ b/packages/website/ts/components/documentation/docs_logo.tsx @@ -2,12 +2,21 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { WebsitePaths } from 'ts/types'; -export const DocsLogo = () => { +export interface DocsLogoProps { + height: number; + containerStyle?: React.CSSProperties; +} + +export const DocsLogo: React.StatelessComponent = props => { return ( -
+
- +
); }; + +DocsLogo.defaultProps = { + containerStyle: {}, +}; diff --git a/packages/website/ts/components/ui/container.tsx b/packages/website/ts/components/ui/container.tsx index f2ae68b70..1e0bfd959 100644 --- a/packages/website/ts/components/ui/container.tsx +++ b/packages/website/ts/components/ui/container.tsx @@ -15,6 +15,7 @@ export interface ContainerProps { paddingRight?: StringOrNum; paddingLeft?: StringOrNum; backgroundColor?: string; + background?: string; borderRadius?: StringOrNum; maxWidth?: StringOrNum; maxHeight?: StringOrNum; diff --git a/packages/website/ts/containers/docs_home.ts b/packages/website/ts/containers/docs_home.ts index 79bf68618..9c7b70a6f 100644 --- a/packages/website/ts/containers/docs_home.ts +++ b/packages/website/ts/containers/docs_home.ts @@ -1,15 +1,28 @@ import * as React from 'react'; import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; import { Home as HomeComponent, HomeProps } from 'ts/pages/documentation/home'; +import { Dispatcher } from 'ts/redux/dispatcher'; import { State } from 'ts/redux/reducer'; +import { ScreenWidths } from 'ts/types'; import { Translate } from 'ts/utils/translate'; interface ConnectedState { translate: Translate; + screenWidth: ScreenWidths; +} + +interface ConnectedDispatch { + dispatcher: Dispatcher; } const mapStateToProps = (state: State, _ownProps: HomeProps): ConnectedState => ({ translate: state.translate, + screenWidth: state.screenWidth, +}); + +const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ + dispatcher: new Dispatcher(dispatch), }); -export const DocsHome: React.ComponentClass = connect(mapStateToProps, undefined)(HomeComponent); +export const DocsHome: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)(HomeComponent); diff --git a/packages/website/ts/pages/documentation/home.tsx b/packages/website/ts/pages/documentation/home.tsx index 003212279..a065efc80 100644 --- a/packages/website/ts/pages/documentation/home.tsx +++ b/packages/website/ts/pages/documentation/home.tsx @@ -1,53 +1,81 @@ +import { colors } from '@0xproject/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import DocumentTitle = require('react-document-title'); import { DocsContentTopBar } from 'ts/components/documentation/docs_content_top_bar'; import { DocsLogo } from 'ts/components/documentation/docs_logo'; +import { Container } from 'ts/components/ui/container'; +import { Dispatcher } from 'ts/redux/dispatcher'; +import { ScreenWidths } from 'ts/types'; import { Translate } from 'ts/utils/translate'; +import { utils } from 'ts/utils/utils'; + +const THROTTLE_TIMEOUT = 100; export interface HomeProps { location: Location; translate: Translate; + screenWidth: ScreenWidths; + dispatcher: Dispatcher; } export interface HomeState {} export class Home extends React.Component { + private readonly _throttledScreenWidthUpdate: () => void; + constructor(props: HomeProps) { + super(props); + this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); + } + public componentDidMount(): void { + window.addEventListener('resize', this._throttledScreenWidthUpdate); + window.scrollTo(0, 0); + } + public componentWillUnmount(): void { + window.removeEventListener('resize', this._throttledScreenWidthUpdate); + } public render(): React.ReactNode { + const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm; + const mainContentPadding = isSmallScreen ? 0 : 50; return ( -
-
- -
-
+ + -
+
+

Start building on 0x

+
+
-
+ ); } + private _updateScreenWidth(): void { + const newScreenWidth = utils.getScreenWidth(); + this.props.dispatcher.updateScreenWidth(newScreenWidth); + } } -- cgit v1.2.3