Implement new responsive, dev section header and home scaffolding

This commit is contained in:
Fabio Berger 2018-09-17 16:55:22 +01:00
parent 60ef45722c
commit ce51edcf80
5 changed files with 103 additions and 53 deletions

View File

@ -3,6 +3,7 @@ import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer'; import Drawer from 'material-ui/Drawer';
import * as React from 'react'; import * as React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { DocsLogo } from 'ts/components/documentation/docs_logo';
import { Container } from 'ts/components/ui/container'; import { Container } from 'ts/components/ui/container';
import { Deco, Key, ObjectMap, WebsitePaths } from 'ts/types'; import { Deco, Key, ObjectMap, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
@ -17,17 +18,6 @@ interface DocsContentTopBarState {
isDrawerOpen: boolean; isDrawerOpen: boolean;
} }
const styles: Styles = {
menuItem: {
fontSize: 14,
color: colors.darkestGrey,
paddingTop: 6,
paddingBottom: 6,
cursor: 'pointer',
fontWeight: 400,
},
};
interface MenuItemInfo { interface MenuItemInfo {
title: string; title: string;
url: string; url: string;
@ -50,11 +40,6 @@ export class DocsContentTopBar extends React.Component<DocsContentTopBarProps, D
} }
} }
public render(): React.ReactNode { public render(): React.ReactNode {
const menuIconStyle = {
fontSize: 25,
color: 'black',
cursor: 'pointer',
};
const menuItemInfos: MenuItemInfo[] = [ const menuItemInfos: MenuItemInfo[] = [
{ {
title: this.props.translate.get(Key.Github, Deco.Cap), title: this.props.translate.get(Key.Github, Deco.Cap),
@ -76,9 +61,9 @@ export class DocsContentTopBar extends React.Component<DocsContentTopBarProps, D
}, },
]; ];
return ( return (
<div style={{ height: 75 }} className="pb1"> <Container height={75} className="pb1">
<Container className="flex items-center" paddingTop={30} width="100%"> <Container className="flex items-center lg-pt3 md-pt3 sm-pt1 relative" width="100%">
<div className="col col-2"> <div className="col col-2 sm-hide xs-hide">
<Link <Link
to={WebsitePaths.Home} to={WebsitePaths.Home}
style={{ color: colors.linkSectionGrey }} style={{ color: colors.linkSectionGrey }}
@ -90,14 +75,28 @@ export class DocsContentTopBar extends React.Component<DocsContentTopBarProps, D
</div> </div>
</Link> </Link>
</div> </div>
<div className="col col-10"> <div className="col col-4 md-hide sm-hide xs-hide" />
<div className="col col-6 md-pl4 md-ml4 sm-hide xs-hide">
<div className="flex items-center justify-between right" style={{ width: 300 }}> <div className="flex items-center justify-between right" style={{ width: 300 }}>
{this._renderMenuItems(menuItemInfos)} {this._renderMenuItems(menuItemInfos)}
</div> </div>
</div> </div>
<div className={'md-hide lg-hide'}> <div className="lg-hide md-hide">
<div style={menuIconStyle}> <DocsLogo height={30} containerStyle={{ paddingTop: 6, paddingLeft: 18 }} />
<i className="zmdi zmdi-menu" onClick={this._onMenuButtonClick.bind(this)} /> </div>
<div className="md-hide lg-hide absolute" style={{ right: 18, top: 12 }}>
<div
style={{
fontSize: 30,
color: 'black',
cursor: 'pointer',
}}
>
<i
className="zmdi zmdi-menu"
style={{ color: colors.grey700 }}
onClick={this._onMenuButtonClick.bind(this)}
/>
</div> </div>
</div> </div>
</Container> </Container>
@ -110,7 +109,7 @@ export class DocsContentTopBar extends React.Component<DocsContentTopBarProps, D
}} }}
/> />
{this._renderDrawer()} {this._renderDrawer()}
</div> </Container>
); );
} }
private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode { private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode {

View File

@ -2,12 +2,21 @@ import * as React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { WebsitePaths } from 'ts/types'; import { WebsitePaths } from 'ts/types';
export const DocsLogo = () => { export interface DocsLogoProps {
height: number;
containerStyle?: React.CSSProperties;
}
export const DocsLogo: React.StatelessComponent<DocsLogoProps> = props => {
return ( return (
<div style={{ paddingTop: 28 }}> <div style={props.containerStyle}>
<Link to={`${WebsitePaths.Home}`} className="text-decoration-none"> <Link to={`${WebsitePaths.Home}`} className="text-decoration-none">
<img src="/images/docs_logo.svg" height="36px" /> <img src="/images/docs_logo.svg" height={props.height} />
</Link> </Link>
</div> </div>
); );
}; };
DocsLogo.defaultProps = {
containerStyle: {},
};

View File

@ -15,6 +15,7 @@ export interface ContainerProps {
paddingRight?: StringOrNum; paddingRight?: StringOrNum;
paddingLeft?: StringOrNum; paddingLeft?: StringOrNum;
backgroundColor?: string; backgroundColor?: string;
background?: string;
borderRadius?: StringOrNum; borderRadius?: StringOrNum;
maxWidth?: StringOrNum; maxWidth?: StringOrNum;
maxHeight?: StringOrNum; maxHeight?: StringOrNum;

View File

@ -1,15 +1,28 @@
import * as React from 'react'; import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { Home as HomeComponent, HomeProps } from 'ts/pages/documentation/home'; import { Home as HomeComponent, HomeProps } from 'ts/pages/documentation/home';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer'; import { State } from 'ts/redux/reducer';
import { ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate'; import { Translate } from 'ts/utils/translate';
interface ConnectedState { interface ConnectedState {
translate: Translate; translate: Translate;
screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
dispatcher: Dispatcher;
} }
const mapStateToProps = (state: State, _ownProps: HomeProps): ConnectedState => ({ const mapStateToProps = (state: State, _ownProps: HomeProps): ConnectedState => ({
translate: state.translate, translate: state.translate,
screenWidth: state.screenWidth,
}); });
export const DocsHome: React.ComponentClass<HomeProps> = connect(mapStateToProps, undefined)(HomeComponent); const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
dispatcher: new Dispatcher(dispatch),
});
export const DocsHome: React.ComponentClass<HomeProps> = connect(mapStateToProps, mapDispatchToProps)(HomeComponent);

View File

@ -1,53 +1,81 @@
import { colors } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import DocumentTitle = require('react-document-title'); import DocumentTitle = require('react-document-title');
import { DocsContentTopBar } from 'ts/components/documentation/docs_content_top_bar'; import { DocsContentTopBar } from 'ts/components/documentation/docs_content_top_bar';
import { DocsLogo } from 'ts/components/documentation/docs_logo'; 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 { Translate } from 'ts/utils/translate';
import { utils } from 'ts/utils/utils';
const THROTTLE_TIMEOUT = 100;
export interface HomeProps { export interface HomeProps {
location: Location; location: Location;
translate: Translate; translate: Translate;
screenWidth: ScreenWidths;
dispatcher: Dispatcher;
} }
export interface HomeState {} export interface HomeState {}
export class Home extends React.Component<HomeProps, HomeState> { export class Home extends React.Component<HomeProps, HomeState> {
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 { public render(): React.ReactNode {
const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
const mainContentPadding = isSmallScreen ? 0 : 50;
return ( return (
<div <Container
className="flex items-center" className="flex items-center"
style={{ width="100%"
width: '100%', background={`linear-gradient(to right, ${colors.grey100} 0%, ${colors.grey100} 50%, ${
background: 'linear-gradient(to right, #f5f5f5 0%, #f5f5f5 50%, #ffffff 50%, #ffffff 100%)', colors.white
}} } 50%, ${colors.white} 100%)`}
> >
<DocumentTitle title="0x Docs Home" /> <DocumentTitle title="0x Docs Home" />
<div className="flex mx-auto"> <div className="flex mx-auto">
<div <Container
style={{ className="sm-hide xs-hide"
width: 234, width={234}
paddingLeft: 22, paddingLeft={22}
paddingRight: 22, paddingRight={22}
backgroundColor: '#f5f5f5', paddingTop={2}
height: '100vh', backgroundColor={colors.grey100}
}} height="100vh"
> >
<DocsLogo /> <DocsLogo height={36} containerStyle={{ paddingTop: 28 }} />
</div> </Container>
<div <Container
style={{ width={isSmallScreen ? '100vw' : 716}
width: 716, paddingLeft={mainContentPadding}
paddingLeft: 50, paddingRight={mainContentPadding}
paddingRight: 50, backgroundColor={colors.white}
backgroundColor: '#ffffff', height="100vh"
height: '100vh',
}}
> >
<DocsContentTopBar location={this.props.location} translate={this.props.translate} /> <DocsContentTopBar location={this.props.location} translate={this.props.translate} />
</div> <div>
<h1 style={{ color: '#333333', fontSize: 30 }}>Start building on 0x</h1>
</div>
</Container>
</div> </div>
</div> </Container>
); );
} }
private _updateScreenWidth(): void {
const newScreenWidth = utils.getScreenWidth();
this.props.dispatcher.updateScreenWidth(newScreenWidth);
}
} }