Last active
April 14, 2017 06:14
-
-
Save tikitikipoo/214829287c4cbaa1298d426c1cd179e2 to your computer and use it in GitHub Desktop.
クリアできるredux-form-material-uiのTimePicker
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
import { TimePicker } from 'redux-form-material-ui' | |
import IconButton from 'material-ui/IconButton' | |
import Clear from 'material-ui/svg-icons/content/clear' | |
const Clearable = ComposedComponent => class extends React.Component { | |
clearDate (event) { | |
event.preventDefault(); | |
const self = this | |
this.refs.timePicker.setState({ | |
time: null, | |
dialogTime: null, | |
}, () => { | |
this.props.input.onChange(null, null) | |
}); | |
} | |
render () { | |
return ( | |
<div style={{position: 'relative', display: 'inline-block'}}> | |
<ComposedComponent | |
{ ...this.props } | |
ref="timePicker" | |
/> | |
{this.props.input.value && | |
<IconButton ref="button" onClick={this.clearDate.bind(this)} style={{position: 'absolute', top: '6px',right: '4px', padding: '0', width: '24px', height: '24px'}}> | |
<Clear /> | |
</IconButton> | |
} | |
</div> | |
) | |
} | |
}; | |
export default Clearable(TimePicker) |
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
import TimePicker from 'path/to/TimePicker' | |
<Field | |
id='start_at' | |
key='start_at' | |
name="start_at" | |
component={TimePicker} | |
autoOk={true} | |
format={null} | |
props={{format: "24hr"}} | |
style={{display:'inline-block', width: 120, verticalAlign:'top', marginLeft: 10, marginTop: 24}} | |
textFieldStyle={{width: 120}} | |
cancelLabel="キャンセル" | |
okLabel="決定" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment