@@ -3,10 +3,23 @@ import PropTypes from 'prop-types';
3
3
import Toolbar from 'material-ui/Toolbar' ;
4
4
import Grid from 'material-ui/Grid' ;
5
5
import { withStyles } from 'material-ui/styles' ;
6
+ import withWidth , { isWidthDown } from 'material-ui/utils/withWidth' ;
7
+ import classNames from 'classnames' ;
8
+ import compose from 'recompose/compose' ;
6
9
7
10
import styles from './styles' ;
8
11
9
- const contentPropType = PropTypes . oneOfType ( [ PropTypes . element , PropTypes . arrayOf ( PropTypes . element ) ] ) ;
12
+ const contentPropType = PropTypes . oneOfType ( [
13
+ PropTypes . element ,
14
+ PropTypes . arrayOf ( PropTypes . element ) ,
15
+ ] ) ;
16
+
17
+ // TODO find a way to better overwrite the items styles
18
+ const style = {
19
+ item : {
20
+ padding : '0px' ,
21
+ } ,
22
+ } ;
10
23
11
24
class TwoRowsAppBar extends PureComponent {
12
25
static propTypes = {
@@ -17,6 +30,8 @@ class TwoRowsAppBar extends PureComponent {
17
30
bottomLeftContent : contentPropType ,
18
31
bottomCenterContent : contentPropType ,
19
32
bottomRightContent : contentPropType ,
33
+ width : PropTypes . string ,
34
+ smallScreenWidth : PropTypes . string ,
20
35
} ;
21
36
22
37
static defaultProps = {
@@ -27,9 +42,9 @@ class TwoRowsAppBar extends PureComponent {
27
42
bottomLeftContent : null ,
28
43
bottomCenterContent : null ,
29
44
bottomRightContent : null ,
45
+ smallScreenWidth : 'xs' ,
30
46
} ;
31
47
32
-
33
48
render ( ) {
34
49
const {
35
50
classes,
@@ -39,29 +54,94 @@ class TwoRowsAppBar extends PureComponent {
39
54
bottomLeftContent,
40
55
bottomCenterContent,
41
56
bottomRightContent,
57
+ width,
58
+ smallScreenWidth = 'xs' ,
42
59
} = this . props ;
60
+
61
+ const smallScreen = isWidthDown ( smallScreenWidth , width ) ;
62
+
43
63
return (
44
64
< Toolbar >
45
65
< Grid container direction = "column" className = { classes . wrapper } >
46
- < Grid container className = { classes . topRow } justify = { 'space-between' } >
47
- < Grid item xs = { 2 } className = { classes . left } >
66
+ < Grid
67
+ container
68
+ className = { classNames ( classes . row , classes . topRow ) }
69
+ justify = { 'space-between' }
70
+ >
71
+ < Grid
72
+ item
73
+ style = { style . item }
74
+ xs = { 2 }
75
+ sm = { 4 }
76
+ md = { 3 }
77
+ lg = { 2 }
78
+ className = { classes . left }
79
+ >
48
80
{ topLeftContent }
49
81
</ Grid >
50
- < Grid item xs = { 8 } className = { classes . topCenter } >
82
+ < Grid
83
+ item
84
+ style = { style . item }
85
+ xs = { 8 }
86
+ sm = { 4 }
87
+ md = { 6 }
88
+ lg = { 8 }
89
+ className = { classNames ( classes . topCenter , {
90
+ [ `${ classes . centerBig } ` ] : ! smallScreen ,
91
+ } ) }
92
+ >
51
93
{ topCenterContent }
52
94
</ Grid >
53
- < Grid item xs = { 2 } className = { classes . right } >
95
+ < Grid
96
+ item
97
+ style = { style . item }
98
+ xs = { 2 }
99
+ sm = { 4 }
100
+ md = { 3 }
101
+ lg = { 2 }
102
+ className = { classes . right }
103
+ >
54
104
{ topRightContent }
55
105
</ Grid >
56
106
</ Grid >
57
- < Grid container className = { classes . bottomRow } justify = { 'space-between' } >
58
- < Grid item xs = { 2 } className = { classes . left } >
107
+ < Grid
108
+ container
109
+ className = { classNames ( classes . row , classes . bottomRow ) }
110
+ justify = { 'space-between' }
111
+ >
112
+ < Grid
113
+ item
114
+ style = { style . item }
115
+ xs = { 2 }
116
+ sm = { 4 }
117
+ md = { 3 }
118
+ lg = { 2 }
119
+ className = { classes . left }
120
+ >
59
121
{ bottomLeftContent }
60
122
</ Grid >
61
- < Grid item xs = { 8 } className = { classes . bottomCenter } >
123
+ < Grid
124
+ item
125
+ style = { style . item }
126
+ xs = { 8 }
127
+ sm = { 4 }
128
+ md = { 6 }
129
+ lg = { 8 }
130
+ className = { classNames ( classes . bottomCenter , {
131
+ [ `${ classes . centerBig } ` ] : ! smallScreen ,
132
+ } ) }
133
+ >
62
134
{ bottomCenterContent }
63
135
</ Grid >
64
- < Grid item xs = { 2 } className = { classes . right } >
136
+ < Grid
137
+ item
138
+ style = { style . item }
139
+ xs = { 2 }
140
+ sm = { 4 }
141
+ md = { 3 }
142
+ lg = { 2 }
143
+ className = { classes . right }
144
+ >
65
145
{ bottomRightContent }
66
146
</ Grid >
67
147
</ Grid >
@@ -71,4 +151,4 @@ class TwoRowsAppBar extends PureComponent {
71
151
}
72
152
}
73
153
74
- export default withStyles ( styles ) ( TwoRowsAppBar ) ;
154
+ export default compose ( withStyles ( styles ) , withWidth ( ) ) ( TwoRowsAppBar ) ;
0 commit comments