-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
167 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, { useState } from 'react'; | ||
import { PropTypes } from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import FormControl from '@material-ui/core/FormControl'; | ||
// import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import FormGroup from '@material-ui/core/FormGroup'; | ||
import InputLabel from '@material-ui/core/InputLabel'; | ||
import Select from '@material-ui/core/Select'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
leftPad: { | ||
paddingLeft: theme.spacing(1), | ||
}, | ||
floatLeft: { | ||
float: 'left', | ||
}, | ||
capitalize: { | ||
textTransform: 'capitalize', | ||
} | ||
})); | ||
|
||
function ChannelDropdown(props) { | ||
|
||
const { label, value, channels, onChange } = props; | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const classes = useStyles(); | ||
|
||
return ( | ||
<FormControl fullWidth> | ||
<InputLabel margin='dense' htmlFor={`${label}-input`}>{`${label} channel`}</InputLabel> | ||
<Select | ||
labelId={`${label}-input`} | ||
open={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
onOpen={() => setIsOpen(true)} | ||
onChange={onChange} | ||
value={value} | ||
autoWidth={true} | ||
className={classes.leftPad, classes.capitalize} | ||
> | ||
{channels.map((c, i) => ( | ||
<MenuItem value={c} key={i} className={classes.capitalize}> | ||
{c} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
); | ||
} | ||
|
||
ChannelDropdown.propTypes = { | ||
label: PropTypes.string, | ||
value: PropTypes.string, | ||
channels: PropTypes.array, | ||
onChange: PropTypes.func, | ||
}; | ||
|
||
|
||
export default function ChannelForm(props) { | ||
|
||
const { targetChannels, channels, onChange } = props; | ||
|
||
return ( | ||
<FormGroup> | ||
{targetChannels && Object.keys(targetChannels).map((t, i) => ( | ||
<ChannelDropdown | ||
label={`${t}`} | ||
key={i} | ||
value={targetChannels[t]} | ||
channels={channels} | ||
onChange={e => onChange(e.target.value, t)} | ||
/> | ||
))} | ||
</FormGroup> | ||
); | ||
} | ||
|
||
ChannelForm.propTypes = { | ||
channels: PropTypes.array, | ||
targetChannels: PropTypes.object, | ||
onChange: PropTypes.func, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters