Skip to content

Instantly share code, notes, and snippets.

@joebandenburg
Created July 24, 2015 08:46
Show Gist options
  • Save joebandenburg/4c4bee614836cfa1b2a4 to your computer and use it in GitHub Desktop.
Save joebandenburg/4c4bee614836cfa1b2a4 to your computer and use it in GitHub Desktop.
Dockable LeftNav
class AppNav extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.fixed !== nextProps.fixed) {
if (nextProps.fixed) {
this.refs.nav.open();
} else {
this.refs.nav.close();
}
}
}
open() {
this.refs.nav.open();
}
render() {
const outerStyle = {
position: (this.props.fixed) ? "relative" : undefined,
width: (this.props.fixed) ? 256 : undefined,
flexShrink: 0
};
const style = {};
if (this.props.fixed) {
style.position = "absolute";
}
return (
<div style={outerStyle}>
<mui.LeftNav ref="nav"
docked={this.props.fixed}
menuItems={this.props.menuItems}
selectedIndex={this.props.selectedIndex}
style={style}
onChange={this.props.onNavigate} />
</div>
);
}
}
@joebandenburg
Copy link
Author

This component assumes it's nested in a flexbox container.

@hungtuchen
Copy link

which part should I change if I didn't wrap it in a flexbox container
I only use flexbox on smaller component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment