-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds EuiDatePicker component
- Loading branch information
Showing
27 changed files
with
2,190 additions
and
1 deletion.
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
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,79 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import moment from 'moment'; | ||
|
||
import { | ||
EuiDatePicker, | ||
EuiFormRow, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default class extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
startDate: moment() | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
|
||
handleChange(date) { | ||
this.setState({ | ||
startDate: date | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<EuiFormRow label="className example"> | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
showTimeSelect | ||
onChange={this.handleChange} | ||
className="dpTest__purpleInput" | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiFormRow label="calendarClassName example"> | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
showTimeSelect | ||
onChange={this.handleChange} | ||
calendarClassName="dpTest__purpleCal" | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiFormRow label="dayClassName example"> | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
showTimeSelect | ||
onChange={this.handleChange} | ||
dayClassName={date => date.date() < Math.random() * 31 ? 'dpTest__purpleDay' : undefined} | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiFormRow label="popperClassName example"> | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
showTimeSelect | ||
onChange={this.handleChange} | ||
popperClassName="dpTest__purplePopper" | ||
/> | ||
</EuiFormRow> | ||
|
||
</div> | ||
); | ||
} | ||
} |
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,63 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import PropTypes from 'prop-types'; | ||
|
||
import moment from 'moment'; | ||
|
||
import { | ||
EuiDatePicker, | ||
EuiButton, | ||
} from '../../../../src/components'; | ||
|
||
// Should be a component because the datepicker does some ref stuff behind the scenes | ||
// eslint-disable-next-line react/prefer-stateless-function | ||
class ExampleCustomInput extends React.Component { | ||
|
||
render () { | ||
return ( | ||
<EuiButton | ||
className="example-custom-input" | ||
onClick={this.props.onClick} | ||
> | ||
{this.props.value} | ||
</EuiButton> | ||
) | ||
} | ||
} | ||
|
||
ExampleCustomInput.propTypes = { | ||
onClick: PropTypes.func, | ||
value: PropTypes.string | ||
}; | ||
|
||
// eslint-disable-next-line react/no-multi-comp | ||
export default class extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
startDate: moment() | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
|
||
handleChange(date) { | ||
this.setState({ | ||
startDate: date | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
onChange={this.handleChange} | ||
customInput={<ExampleCustomInput />} | ||
/> | ||
); | ||
} | ||
} |
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,40 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import moment from 'moment'; | ||
|
||
import { | ||
EuiDatePicker, | ||
EuiFormRow, | ||
} from '../../../../src/components'; | ||
|
||
export default class extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
startDate: moment() | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
|
||
handleChange(date) { | ||
this.setState({ | ||
startDate: date | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<EuiFormRow label="Select a date"> | ||
<EuiDatePicker | ||
selected={this.state.startDate} | ||
onChange={this.handleChange} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
} |
Oops, something went wrong.