Skip to content

Commit 5480826

Browse files
committed
navbar templates
1 parent 9ff1f21 commit 5480826

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import _ from 'lodash';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
4+
import IconButton from 'material-ui/IconButton';
5+
import Button from 'material-ui/Button';
6+
import Toolbar from 'material-ui/Toolbar';
7+
import Typography from 'material-ui/Typography';
8+
import MenuIcon from 'material-ui-icons/Menu';
9+
import Hidden from 'material-ui/Hidden';
10+
import { withStyles } from 'material-ui/styles';
11+
import withWidth from 'material-ui/utils/withWidth';
12+
import compose from 'recompose/compose';
13+
14+
import styles from './styles';
15+
16+
class BasicNavBar extends React.PureComponent {
17+
static propTypes = {
18+
links: PropTypes.arrayOf(PropTypes.shape({})),
19+
classes: PropTypes.shape({}),
20+
title: PropTypes.string,
21+
logo: PropTypes.string,
22+
};
23+
24+
renderLogo = () => {
25+
const { classes, title, logo } = this.props;
26+
if (logo) {
27+
return (
28+
<div className={classes.logo}>
29+
<img src={logo} alt={title} className={classes.image} />
30+
</div>
31+
);
32+
}
33+
return (
34+
<Typography type="title" color="inherit" className={classes.flex}>
35+
{title}
36+
</Typography>
37+
);
38+
};
39+
40+
handleIconClick = () => {
41+
this.props.onIconClick();
42+
}
43+
44+
render() {
45+
const { links, onIconClick } = this.props;
46+
return (
47+
<Toolbar>
48+
<Hidden smUp>
49+
<IconButton color="inherit" aria-label="Menu" onClick={this.handleIconClick}>
50+
<MenuIcon />
51+
</IconButton>
52+
</Hidden>
53+
{this.renderLogo()}
54+
<Hidden xsDown>
55+
<div>
56+
{_.map(links, link => (
57+
<Button href={link.href} color="inherit" key={link.label}>
58+
{link.label}
59+
</Button>
60+
))}
61+
</div>
62+
</Hidden>
63+
</Toolbar>
64+
);
65+
}
66+
}
67+
68+
export default compose(withStyles(styles), withWidth())(BasicNavBar);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import BasicNavBar from './BasicNavBar';
2+
3+
export default BasicNavBar;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const styles = {
2+
flex: {
3+
flex: 1,
4+
},
5+
logo: {
6+
flex: 1,
7+
cursor: 'pointer',
8+
height: '45px',
9+
minWidth: '160px',
10+
},
11+
image: {
12+
height: '100%',
13+
margin: '0',
14+
padding: '0',
15+
},
16+
};
17+
18+
export default styles;

0 commit comments

Comments
 (0)