1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
import React, { Fragment, PureComponent } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { AddCircle, AddCircleOutline, Remove, ThumbUp } from '@material-ui/icons';
import { Rating } from 'ba-components';
import { green, red, indigo as blue } from '@material-ui/core/colors';
import { FormControl, Typography, Grid, Chip } from '@material-ui/core';
const styles = theme => ({
demo: {
height: 'auto',
},
divider: {
display: 'block',
margin: `${theme.spacing(3)}px 0`,
},
field: {
margin: `${theme.spacing(3)}px 0`,
},
chip: {
margin: theme.spacing(1),
fontWeight: 'bold',
color: '#FFF',
background: red[300]
},
blue: {
color: blue[300]
},
green: {
color: green[500]
},
red: {
color: red[300]
},
small: {
'& button': {
width: 72,
height: 72,
padding: 16
},
'& svg': {
width: 36,
height: 36
}
},
medium: {
'& button': {
width: 96,
height: 96,
padding: 24
},
'& svg': {
width: 48,
height: 48
}
},
large: {
'& button': {
width: 120,
height: 120,
padding: 30
},
'& svg': {
width: 60,
height: 60
}
}
});
class RatingCustom extends PureComponent {
state = {
rating: 3
}
handleChange = value => {
this.setState({ rating: value });
}
render() {
const { classes } = this.props;
return (
<Fragment>
<Grid
container
alignItems="flex-start"
justify="space-around"
direction="row"
spacing={2}
>
<Grid
item
md={6}
className={classes.demo}
>
<Typography variant="button" className={classes.divider}>Ratting Custom Icon</Typography>
<FormControl className={classes.formControl}>
<Rating
value={this.state.rating}
max={5}
onChange={(value) => this.handleChange(value)}
iconFilled={<ThumbUp className={classes.blue} />}
iconHovered={<ThumbUp className={classes.blue} />}
iconNormal={<Remove className={classes.red} />}
/>
</FormControl>
</Grid>
<Grid
item
md={6}
className={classes.demo}
>
<Typography variant="button" className={classes.divider}>Show Counter</Typography>
<Grid
container
alignItems="flex-start"
justify="flex-start"
direction="row"
>
<FormControl className={classes.formControl}>
<Rating
value={this.state.rating}
max={5}
onChange={(value) => this.handleChange(value)}
iconFilled={<AddCircle className={classes.green} />}
iconHovered={<AddCircleOutline className={classes.green} />}
iconNormal={<AddCircleOutline className={classes.green} />}
tooltipRenderer={(index) => <span>{ index }</span>}
tooltipPosition="bottom-center"
/>
</FormControl>
<Chip label={this.state.rating} className={classes.chip} />
</Grid>
</Grid>
<Grid
item
md={12}
className={classes.demo}
>
<Typography variant="button" className={classes.divider}>Ratting Custom Size</Typography>
<FormControl className={classes.formControl}>
<div className={classes.small}>
<Rating
value={this.state.rating}
max={5}
onChange={(value) => this.handleChange(value)}
/>
</div>
<div className={classes.medium}>
<Rating
value={this.state.rating}
max={5}
onChange={(value) => this.handleChange(value)}
/>
</div>
<div className={classes.large}>
<Rating
value={this.state.rating}
max={5}
onChange={(value) => this.handleChange(value)}
/>
</div>
</FormControl>
</Grid>
</Grid>
</Fragment>
);
}
}
RatingCustom.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(RatingCustom);
|