-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui,ui-date-input): add new DateInput2 component
- Loading branch information
Showing
12 changed files
with
592 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,114 @@ | ||
--- | ||
describes: DateInput | ||
--- | ||
|
||
This component is an updated version of [`DateInput`](/#DateInput) that's easier to configure for developers, has a better UX, better accessibility features and a year picker. We recommend using this instead of `DateInput` which will be deprecated in the future. | ||
|
||
### Minimal config | ||
|
||
- ```js | ||
class Example extends React.Component { | ||
state = { value: '' } | ||
|
||
render() { | ||
return ( | ||
<DateInput2 | ||
renderLabel="Choose a date" | ||
screenReaderLabels={{ | ||
calendarIcon: 'Calendar', | ||
nextMonthButton: 'Next month', | ||
prevMonthButton: 'Previous month' | ||
}} | ||
value={this.state.value} | ||
width="20rem" | ||
onChange={(e, value) => this.setState({ value })} | ||
invalidDateErrorMessage="Invalid date" | ||
/> | ||
) | ||
} | ||
} | ||
|
||
render(<Example />) | ||
``` | ||
|
||
- ```js | ||
const Example = () => { | ||
const [value, setValue] = useState('') | ||
return ( | ||
<DateInput2 | ||
renderLabel="Choose a date" | ||
screenReaderLabels={{ | ||
calendarIcon: 'Calendar', | ||
nextMonthButton: 'Next month', | ||
prevMonthButton: 'Previous month' | ||
}} | ||
value={value} | ||
width="20rem" | ||
onChange={(e, value) => setValue(value)} | ||
invalidDateErrorMessage="Invalid date" | ||
/> | ||
) | ||
} | ||
|
||
render(<Example />) | ||
``` | ||
|
||
### With year picker | ||
|
||
- ```js | ||
class Example extends React.Component { | ||
state = { value: '' } | ||
|
||
render() { | ||
return ( | ||
<DateInput2 | ||
renderLabel="Choose a date" | ||
screenReaderLabels={{ | ||
calendarIcon: 'Calendar', | ||
nextMonthButton: 'Next month', | ||
prevMonthButton: 'Previous month' | ||
}} | ||
width="20rem" | ||
value={this.state.value} | ||
onChange={(e, value) => this.setState({ value })} | ||
invalidDateErrorMessage="Invalid date" | ||
withYearPicker={{ | ||
screenReaderLabel: 'Year picker', | ||
startYear: 1999, | ||
endYear: 2024 | ||
}} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
render(<Example />) | ||
``` | ||
|
||
- ```js | ||
const Example = () => { | ||
const [value, setValue] = useState('') | ||
|
||
return ( | ||
<DateInput2 | ||
renderLabel="Choose a date" | ||
screenReaderLabels={{ | ||
calendarIcon: 'Calendar', | ||
nextMonthButton: 'Next month', | ||
prevMonthButton: 'Previous month' | ||
}} | ||
width="20rem" | ||
value={value} | ||
onChange={(e, value) => setValue(value)} | ||
invalidDateErrorMessage="Invalid date" | ||
withYearPicker={{ | ||
screenReaderLabel: 'Year picker', | ||
startYear: 1999, | ||
endYear: 2024 | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
render(<Example />) | ||
``` |
Oops, something went wrong.