Skip to content

Commit 30d5033

Browse files
authored
Merge pull request #14 from Zetoff/fix/fixing-previous-version
fixed issues
2 parents 7dcd187 + 4d4d656 commit 30d5033

File tree

9 files changed

+121
-26
lines changed

9 files changed

+121
-26
lines changed

src/components/AppBar/AppBar.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@
33
import React from 'react';
44
import PropTypes from 'prop-types';
55
import { withStyles } from 'material-ui/styles';
6-
import DefaultAppBar from 'material-ui/AppBar';
6+
import MaterialUIAppBar from 'material-ui/AppBar';
7+
78

89
import styles from './styles';
910

1011
class AppBar extends React.PureComponent {
1112
static propTypes = {
13+
classes: PropTypes.shape({}),
1214
children: PropTypes.element,
13-
navbarPostion: PropTypes.string,
15+
position: PropTypes.string,
1416
color: PropTypes.string,
1517
};
1618

1719
render() {
18-
const { children, navbarPostion, color, ...other } = this.props;
20+
const { children, position, classes, color, ...other } = this.props;
1921
return (
20-
<DefaultAppBar position={navbarPostion} color={color}>
22+
<MaterialUIAppBar position={position} color={color}>
2123
{React.cloneElement(children, { ...other })}
22-
</DefaultAppBar>
24+
</MaterialUIAppBar>
2325
);
2426
}
2527
}

src/components/Layout/Layout.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Layout extends React.PureComponent {
1717
classes: PropTypes.shape({}),
1818
overrideClasses: PropTypes.shape({}),
1919
children: PropTypes.element.isRequired,
20-
navbarPostion: PropTypes.string,
20+
appBarPosition: PropTypes.string,
2121
stickyFooter: PropTypes.bool,
2222
footerContent: PropTypes.element,
2323
appBarContent: PropTypes.element,
@@ -31,7 +31,7 @@ class Layout extends React.PureComponent {
3131

3232
static defaultProps = {
3333
title: '',
34-
navbarPostion: 'default',
34+
appBarPosition: 'default',
3535
stickyFooter: false,
3636
drawerOpen: false,
3737
};
@@ -53,7 +53,7 @@ class Layout extends React.PureComponent {
5353
classes: defaultClasses,
5454
overrideClasses,
5555
children,
56-
navbarPostion,
56+
appBarPosition,
5757
stickyFooter,
5858
footerContent,
5959
appBarContent,
@@ -68,13 +68,12 @@ class Layout extends React.PureComponent {
6868

6969
const mainClassnames = classNames(
7070
classes.main,
71-
{ [`${classes.mainFixedNavbar}`]: navbarPostion === 'fixed' },
71+
{ [`${classes.mainFixedAppBar}`]: appBarPosition === 'fixed' },
7272
{ [`${classes.mainStickyFooter}`]: stickyFooter },
7373
);
74-
7574
return (
7675
<div className={classes.layout}>
77-
<AppBar {...appBarProps} onIconClick={this.toggleDrawer}>
76+
<AppBar {...appBarProps} position={appBarPosition} onIconClick={this.toggleDrawer}>
7877
{appBarContent}
7978
</AppBar>
8079
{drawerContent ? (

src/components/Layout/styles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const styles = {
88
paddingTop: '0px',
99
display: 'flex',
1010
},
11-
mainFixedNavbar: {
11+
mainFixedAppBar: {
1212
marginTop: '64px',
1313
},
1414
mainStickyFooter: {
1515
flex: 1,
1616
},
1717
'@media (max-width: 599px)': {
18-
mainFixedNavbar: {
18+
mainFixedAppBar: {
1919
marginTop: '56px',
2020
},
2121
},

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Layout from './components/Layout';
33
export { default as AppBar } from './components/AppBar';
44
export { default as Footer } from './components/Footer';
55

6-
export { default as BasicAppBar } from './templates/AppBar/BasicNavBar';
6+
7+
export { default as BasicAppBar } from './templates/AppBar/BasicAppBar';
78
export { default as TwoRowsAppBar } from './templates/AppBar/TwoRowsAppBar';
89
export { default as BasicFooter } from './templates/Footer/BasicFooter';
910
export { default as BasicDrawer } from './templates/Drawer/BasicDrawer';
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 BasicAppBar 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+
onIconClick: PropTypes.func,
23+
};
24+
25+
handleIconClick = () => {
26+
this.props.onIconClick();
27+
}
28+
29+
renderLogo = () => {
30+
const { classes, title, logo } = this.props;
31+
if (logo) {
32+
return (
33+
<div className={classes.logo}>
34+
<img src={logo} alt={title} className={classes.image} />
35+
</div>
36+
);
37+
}
38+
return (
39+
<Typography type="title" color="inherit" className={classes.flex}>
40+
{title}
41+
</Typography>
42+
);
43+
};
44+
45+
render() {
46+
const { links } = this.props;
47+
return (
48+
<Toolbar>
49+
<Hidden smUp>
50+
<IconButton color="inherit" aria-label="Menu" onClick={this.handleIconClick}>
51+
<MenuIcon />
52+
</IconButton>
53+
</Hidden>
54+
{this.renderLogo()}
55+
<Hidden xsDown>
56+
<div>
57+
{_.map(links, link => (
58+
<Button href={link.href} color="inherit" key={link.label}>
59+
{link.label}
60+
</Button>
61+
))}
62+
</div>
63+
</Hidden>
64+
</Toolbar>
65+
);
66+
}
67+
}
68+
69+
export default compose(withStyles(styles), withWidth())(BasicAppBar);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import BasicAppBar from './BasicAppBar';
2+
3+
export default BasicAppBar;
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;

src/templates/AppBar/TwoRowsAppBar/TwoRowsAppBar.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import { withStyles } from 'material-ui/styles';
66

77
import styles from './styles';
88

9+
const contentPropType = PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]);
10+
911
class TwoRowsAppBar extends PureComponent {
1012
static propTypes = {
1113
classes: PropTypes.shape({}),
12-
topLeftContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
13-
topCenterContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
14-
topRightContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
15-
bottomLeftContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
16-
bottomCenterContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
17-
bottomRightContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)),
14+
topLeftContent: contentPropType,
15+
topCenterContent: contentPropType,
16+
topRightContent: contentPropType,
17+
bottomLeftContent: contentPropType,
18+
bottomCenterContent: contentPropType,
19+
bottomRightContent: contentPropType,
1820
};
1921

2022
static defaultProps = {
@@ -25,7 +27,8 @@ class TwoRowsAppBar extends PureComponent {
2527
bottomLeftContent: null,
2628
bottomCenterContent: null,
2729
bottomRightContent: null,
28-
}
30+
};
31+
2932

3033
render() {
3134
const {

src/templates/AppBar/TwoRowsAppBar/styles.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ export default {
1313
marginTop: '0',
1414
marginBottom: '0',
1515
},
16-
topCenter:{
16+
topCenter: {
1717
textAlign: 'center',
1818
display: 'flex',
1919
justifyContent: 'center',
2020
alignItems: 'center',
2121
},
22-
bottomCenter:{
22+
bottomCenter: {
2323
textAlign: 'center',
2424
display: 'flex',
2525
justifyContent: 'center',
2626
alignItems: 'center',
2727
},
28-
right:{
28+
right: {
2929
justifyContent: 'flex-end',
3030
display: 'flex',
3131
},
32-
left:{
32+
left: {
3333
justifyContent: 'flex-start',
3434
display: 'flex',
35-
}
35+
},
3636
};

0 commit comments

Comments
 (0)