-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-Dropdown-Component.js
77 lines (72 loc) · 2.33 KB
/
react-Dropdown-Component.js
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
import React, { Component } from 'react'
import compose from 'recompose/compose';
import { withStyles } from '@material-ui/core/styles';
import Select from '@material-ui/core/Select';
import classNames from 'classnames';
import MenuItem from '@material-ui/core/MenuItem';
import PropTypes from 'prop-types';
const styles = theme => ({
selectMenuItems: {
fontSize: "11px"
},
selectBox: {
display: "inline-flex"
},
selectInputBox: {
minWidth: "50px"
},
selectedValueStyle: {
fontSize: "12px",
fontWeight: "500",
textAlign: "left",
paddingLeft: "15px"
}
})
class SelectDropdown extends Component {
constructor(props) {
super(props);
}
render() {
const { classes } = this.props;
return (
<Select value={this.props.selectedValue}
inputProps={{
id: this.props.id,
name: this.props.name
}}
classes={{
select: classes.selectedValueStyle
}}
style={{
width: this.props.width ? this.props.width : "auto"
}}
disabled={this.props.disabled}
onChange={this.props.handleSelectChange}
className={classNames(classes.selectInputBox)} >
{this.props.menuItems.length > 0 ?
this.props.menuItems.map((item, index) => {
return <MenuItem
key={item}
value={item}
className={classes.selectMenuItems}
style={{
fontWeight: this.props.selectedValue !== item ? "500" : "700"
}}
>
{item}
</MenuItem>
})
: null}
</Select>
)
}
}
SelectDropdown.propTypes = {
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
//selectedValue: PropTypes.string.isRequired,
menuItems: PropTypes.array.isRequired,
handleSelectChange: PropTypes.func.isRequired,
//width: PropTypes.string.isRequired
}
export default compose(withStyles(styles))(SelectDropdown)