Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Drawer] New improvements #7925

Merged
merged 1 commit into from
Aug 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 58 additions & 41 deletions docs/src/modules/components/AppDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Toolbar from 'material-ui/Toolbar';
import Drawer from 'material-ui/Drawer';
import Typography from 'material-ui/Typography';
import Divider from 'material-ui/Divider';
import Hidden from 'material-ui/Hidden';
import AppDrawerNavItem from 'docs/src/modules/components/AppDrawerNavItem';
import Link from 'docs/src/modules/components/Link';
import { pageToTitle } from 'docs/src/modules/utils/helpers';
Expand Down Expand Up @@ -78,57 +79,73 @@ function reduceChildRoutes(props, activePage, items, childPage, index) {
return items;
}

const GITHUB_RELEASE_BASE_URL = 'https://github.com/callemall/material-ui/releases/tag/';

function AppDrawer(props, context) {
const { classes, className, docked, onRequestClose } = props;
const GITHUB_RELEASE_BASE_URL = 'https://github.com/callemall/material-ui/releases/tag/';
let other = {};

if (!docked) {
other = {
keepMounted: true,
};
}
const { classes, className, disablePermanent, mobileOpen, onRequestClose } = props;

const drawer = (
<div className={classes.nav}>
<Toolbar className={classes.toolbar}>
<Link className={classes.title} href="/" onClick={onRequestClose}>
<Typography type="title" gutterBottom color="inherit">
Material-UI
</Typography>
</Link>
{process.env.MATERIAL_UI_VERSION
? <Link
className={classes.anchor}
href={`${GITHUB_RELEASE_BASE_URL}v${process.env.MATERIAL_UI_VERSION}`}
>
<Typography type="caption">{`v${process.env.MATERIAL_UI_VERSION}`}</Typography>
</Link>
: null}
<Divider absolute />
</Toolbar>
{renderNavItems(props, context.pages, context.activePage)}
</div>
);

return (
<Drawer
className={className}
classes={{
paper: classes.paper,
}}
open={props.open}
onRequestClose={onRequestClose}
docked={docked}
{...other}
>
<div className={classes.nav}>
<Toolbar className={classes.toolbar}>
<Link className={classes.title} href="/" onClick={onRequestClose}>
<Typography type="title" gutterBottom color="inherit">
Material-UI
</Typography>
</Link>
{process.env.MATERIAL_UI_VERSION
? <Link
className={classes.anchor}
href={`${GITHUB_RELEASE_BASE_URL}v${process.env.MATERIAL_UI_VERSION}`}
>
<Typography type="caption">{`v${process.env.MATERIAL_UI_VERSION}`}</Typography>
</Link>
: null}
<Divider absolute />
</Toolbar>
{renderNavItems(props, context.pages, context.activePage)}
</div>
</Drawer>
<div className={className}>
<Hidden lgUp={!disablePermanent}>
<Drawer
classes={{
paper: classes.paper,
}}
type="temporary"
open={mobileOpen}
onRequestClose={onRequestClose}
ModalProps={{
keepMounted: true,
}}
>
{drawer}
</Drawer>
</Hidden>
{disablePermanent
? null
: <Hidden lgDown implementation="css">
<Drawer
classes={{
paper: classes.paper,
}}
type="permanent"
open
>
{drawer}
</Drawer>
</Hidden>}
</div>
);
}

AppDrawer.propTypes = {
classes: PropTypes.object.isRequired,
className: PropTypes.string,
docked: PropTypes.bool.isRequired,
disablePermanent: PropTypes.bool.isRequired,
mobileOpen: PropTypes.bool.isRequired,
onRequestClose: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
};

AppDrawer.contextTypes = {
Expand Down
83 changes: 56 additions & 27 deletions docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Typography from 'material-ui/Typography';
import AppBar from 'material-ui/AppBar';
import Toolbar from 'material-ui/Toolbar';
import IconButton from 'material-ui/IconButton';
import withWidth, { isWidthUp } from 'material-ui/utils/withWidth';
import MenuIcon from 'material-ui-icons/Menu';
import LightbulbOutline from 'material-ui-icons/LightbulbOutline';
import Github from 'docs/src/modules/components/Github';
Expand All @@ -20,7 +19,14 @@ import AppSearch from 'docs/src/modules/components/AppSearch';
import { pageToTitle } from 'docs/src/modules/utils/helpers';

// Disaply a progress bar between route transitions
NProgress.configure({ showSpinner: false });
NProgress.configure({
template: `
<div class="bar" role="bar">
<dt></dt>
<dd></dd>
</div>
`,
});

Router.onRouteChangeStart = () => {
NProgress.start();
Expand Down Expand Up @@ -49,23 +55,45 @@ const styles = theme => ({
'#nprogress': {
pointerEvents: 'none',
'& .bar': {
background: '#000',
position: 'fixed',
background: '#000',
borderRadius: 1,
zIndex: theme.zIndex.tooltip,
top: 0,
left: 0,
width: '100%',
height: 2,
},
'& .peg': {
display: 'block',
'& dd, & dt': {
position: 'absolute',
top: 0,
height: 2,
boxShadow: '#000 1px 0 6px 1px',
borderRadius: '100%',
animation: 'nprogress-pulse 2s ease-out 0s infinite',
},
'& dd': {
opacity: 0.6,
width: 20,
right: 0,
width: 100,
height: '100%',
boxShadow: '0 0 10px #000, 0 0 5px #000',
opacity: 1,
transform: 'rotate(3deg) translate(0px, -4px)',
clip: 'rect(-6px,22px,14px,10px)',
},
'& dt': {
opacity: 0.6,
width: 180,
right: -80,
clip: 'rect(-6px,90px,14px,-6px)',
},
},
'@keyframes nprogress-pulse': {
'30%': {
opacity: 0.6,
},
'60%': {
opacity: 0,
},
to: {
opacity: 0.6,
},
},
},
Expand All @@ -89,49 +117,52 @@ const styles = theme => ({
backgroundColor: 'transparent',
boxShadow: 'none',
},
[theme.breakpoints.up('lg')]: {
drawer: {
width: 250,
},
appBarShift: {
appBarShift: {
[theme.breakpoints.up('lg')]: {
width: 'calc(100% - 250px)',
},
navIconHide: {
},
drawer: {
[theme.breakpoints.up('lg')]: {
width: 250,
},
},
navIconHide: {
[theme.breakpoints.up('lg')]: {
display: 'none',
},
},
});

class AppFrame extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
state = {
drawerOpen: false,
mobileOpen: false,
};

handleDrawerClose = () => {
this.setState({ drawerOpen: false });
this.setState({ mobileOpen: false });
};

handleDrawerToggle = () => {
this.setState({ drawerOpen: !this.state.drawerOpen });
this.setState({ mobileOpen: !this.state.mobileOpen });
};

handleToggleShade = () => {
this.props.dispatch({ type: 'TOGGLE_THEME_SHADE' });
};

render() {
const { children, classes, width } = this.props;
const { children, classes } = this.props;
const title =
this.context.activePage.title !== false ? pageToTitle(this.context.activePage) : null;

let drawerDocked = isWidthUp('lg', width);
let disablePermanent = false;
let navIconClassName = '';
let appBarClassName = classes.appBar;

if (title === null) {
// home route, don't shift app bar or dock drawer
drawerDocked = false;
disablePermanent = true;
appBarClassName += ` ${classes.appBarHome}`;
} else {
navIconClassName += ` ${classes.navIconHide}`;
Expand Down Expand Up @@ -176,9 +207,9 @@ class AppFrame extends React.Component<any, any> {
</AppBar>
<AppDrawer
className={classes.drawer}
docked={drawerDocked}
disablePermanent={disablePermanent}
onRequestClose={this.handleDrawerClose}
open={drawerDocked || this.state.drawerOpen}
mobileOpen={this.state.mobileOpen}
/>
{children}
</div>
Expand All @@ -190,7 +221,6 @@ AppFrame.propTypes = {
children: PropTypes.node.isRequired,
classes: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
width: PropTypes.string.isRequired,
};

AppFrame.contextTypes = {
Expand All @@ -203,6 +233,5 @@ export default compose(
withStyles(styles, {
name: 'AppFrame',
}),
withWidth(),
connect(),
)(AppFrame);
1 change: 0 additions & 1 deletion docs/src/modules/components/AppWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if (process.browser && !global.__INSERTION_POINT__) {
}

class AppWrapper extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
componentWillMount() {
this.styleContext = getContext();
}
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const styles = theme => ({
});

class Demo extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
state = {
codeOpen: false,
};
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const styles = theme => ({
});

class OnClick extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
handleClick = event => {
if (this.props.onClick) {
this.props.onClick(event);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function MarkdownDocs(props, context) {
<AppContent className={classes.root}>
<Head>
<title>
{getTitle(markdown)}
{`${getTitle(markdown)} - Material-UI`}
</title>
</Head>
<div className={classes.header}>
Expand Down
8 changes: 6 additions & 2 deletions docs/src/pages/demos/app-bar/ButtonAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ const styles = {
flex: {
flex: 1,
},
menuButton: {
marginLeft: 12,
marginRight: 20,
},
};

function ButtonAppBar(props) {
const classes = props.classes;
return (
<div className={classes.root}>
<AppBar position="static">
<Toolbar>
<IconButton color="contrast" aria-label="Menu">
<Toolbar disableGutters>
<IconButton className={classes.menuButton} color="contrast" aria-label="Menu">
<MenuIcon />
</IconButton>
<Typography type="title" color="inherit" className={classes.flex}>
Expand Down
Loading