@@ -7,10 +7,26 @@ import Typography from '@material-ui/core/Typography';
7
7
import Icon from '@material-ui/core/Icon' ;
8
8
import FormGroup from '@material-ui/core/FormGroup' ;
9
9
import ButtonBase from '@material-ui/core/ButtonBase' ;
10
+ import { withStyles } from '@material-ui/core/styles' ;
10
11
11
- // NOTE: using name as the key, this shouldn't be a problem
12
+ const styles = {
13
+ item : {
14
+ width : '100%' ,
15
+ padding : '8px 16px' ,
16
+ display : 'flex' ,
17
+ alignItems : 'center' ,
18
+ justifyContent : 'flex-start' ,
19
+ } ,
20
+ formGroup : {
21
+ width : '100%' , // lets the items be full width
22
+ } ,
23
+ icon : {
24
+ marginRight : 8 ,
25
+ } ,
26
+ } ;
12
27
13
28
type Props = {
29
+ classes : Object , // injected styles
14
30
values : Array < string > ,
15
31
name : string ,
16
32
state : {
@@ -21,17 +37,23 @@ type Props = {
21
37
} ;
22
38
23
39
const FilterSort = ( {
24
- values, name, state, onChange,
40
+ classes , values, name, state, onChange,
25
41
} : Props ) => (
26
42
< ExpansionPanel >
27
43
< ExpansionPanelSummary expandIcon = { < Icon > expand_more</ Icon > } >
28
44
< Typography > { name } </ Typography >
29
45
</ ExpansionPanelSummary >
30
46
< ExpansionPanelDetails >
31
- < FormGroup >
47
+ < FormGroup className = { classes . formGroup } >
32
48
{ values . map ( ( value , nestedIndex ) => (
33
- < ButtonBase onClick = { onChange ( nestedIndex ) } key = { `${ name } ${ value } ` } >
34
- < Icon > { iconValue ( state . index , state . ascending , nestedIndex ) } </ Icon >
49
+ < ButtonBase
50
+ onClick = { onChange ( nestedIndex ) }
51
+ key = { `${ name } ${ value } ` }
52
+ className = { classes . item }
53
+ >
54
+ < Icon className = { classes . icon } >
55
+ { iconValue ( state . index , state . ascending , nestedIndex ) }
56
+ </ Icon >
35
57
< Typography > { value } </ Typography >
36
58
</ ButtonBase >
37
59
) ) }
@@ -48,4 +70,4 @@ function iconValue(index: number, ascending: boolean, nestedIndex: number): stri
48
70
return '' ;
49
71
}
50
72
51
- export default FilterSort ;
73
+ export default withStyles ( styles ) ( FilterSort ) ;
0 commit comments