Skip to content

Commit e5c99dd

Browse files
committed
Fix styling on FilterSort
1 parent 1abec9b commit e5c99dd

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/components/filters/FilterSort.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@ import Typography from '@material-ui/core/Typography';
77
import Icon from '@material-ui/core/Icon';
88
import FormGroup from '@material-ui/core/FormGroup';
99
import ButtonBase from '@material-ui/core/ButtonBase';
10+
import { withStyles } from '@material-ui/core/styles';
1011

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+
};
1227

1328
type Props = {
29+
classes: Object, // injected styles
1430
values: Array<string>,
1531
name: string,
1632
state: {
@@ -21,17 +37,23 @@ type Props = {
2137
};
2238

2339
const FilterSort = ({
24-
values, name, state, onChange,
40+
classes, values, name, state, onChange,
2541
}: Props) => (
2642
<ExpansionPanel>
2743
<ExpansionPanelSummary expandIcon={<Icon>expand_more</Icon>}>
2844
<Typography>{name}</Typography>
2945
</ExpansionPanelSummary>
3046
<ExpansionPanelDetails>
31-
<FormGroup>
47+
<FormGroup className={classes.formGroup}>
3248
{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>
3557
<Typography>{value}</Typography>
3658
</ButtonBase>
3759
))}
@@ -48,4 +70,4 @@ function iconValue(index: number, ascending: boolean, nestedIndex: number): stri
4870
return '';
4971
}
5072

51-
export default FilterSort;
73+
export default withStyles(styles)(FilterSort);

0 commit comments

Comments
 (0)