Created
July 1, 2020 03:56
-
-
Save sankalpk/5798f6618b02b29de21285e403a6f63d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React, { Component } from 'react' | |
import mobiscroll from '@mobiscroll/react' | |
import PropTypes from 'prop-types' | |
import { withStyles } from '@material-ui/core/styles' | |
import TextInput from 'components/TextInput' | |
mobiscroll.settings = { | |
theme: 'material', | |
themeVariant: 'light', | |
} | |
class DatePicker extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { date: undefined } | |
} | |
showPicker = () => { | |
this.picker.instance.show() | |
} | |
setPicker = comp => { | |
this.picker = comp | |
} | |
render() { | |
const { classes } = this.props | |
const { date } = this.state | |
console.log('DATE', date) | |
return ( | |
<> | |
<TextInput | |
className={classes.root} | |
type="text" | |
name="dob" | |
label="Date of Birth" | |
InputLabelProps={{ shrink: true, required: false }} | |
placeholder="mm/dd/yyyy" | |
onClick={this.showPicker} | |
// value={date} | |
/> | |
<mobiscroll.Date | |
ref={this.setPicker} | |
buttons={['cancel', 'set']} | |
touchUi={false} | |
placeholder="Please add a date" | |
showOnTap={false} | |
showOnFocus={false} | |
display="center" | |
className={classes.mobiscrollInput} | |
onSet={function() { | |
console.log('TRIGGERED ON SET') | |
}} | |
/> | |
</> | |
) | |
} | |
} | |
const styles = theme => ({ | |
root: { | |
width: '100%', | |
marginTop: 0, | |
marginBottom: theme.margins.md, | |
}, | |
mobiscrollInput: { | |
display: 'none', | |
}, | |
}) | |
DatePicker.propTypes = { | |
classes: PropTypes.object, | |
} | |
export default withStyles(styles)(DatePicker) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment