-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add #date-picker including the docs and examples
- Loading branch information
1 parent
b31b58e
commit f211a03
Showing
8 changed files
with
206 additions
and
42 deletions.
There are no files selected for viewing
19 changes: 12 additions & 7 deletions
19
packages/dnb-design-system-portal/src/pages/uilib/components/date-picker.md
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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
--- | ||
title: 'DatePicker' | ||
draft: false | ||
status: 'wip' | ||
# status: 'imp' | ||
# order: 1 | ||
--- | ||
|
||
import Tabs from 'Tags/Tabs' | ||
|
||
import DatePickerInfo from 'Pages/uilib/components/date-picker/date-picker-info' | ||
import DatePickerProperties from 'Pages/uilib/components/date-picker/date-picker-properties' | ||
import DatePickerEvents from 'Pages/uilib/components/date-picker/date-picker-events' | ||
|
||
# DatePicker | ||
|
||
<Tabs> | ||
<Tabs.Content title="Info" selected> | ||
... | ||
<Tabs.Content> | ||
<DatePickerInfo /> | ||
</Tabs.Content> | ||
<Tabs.Content> | ||
<DatePickerProperties /> | ||
</Tabs.Content> | ||
<Tabs.Content title="Details" disabled> | ||
... | ||
<Tabs.Content> | ||
<DatePickerEvents /> | ||
</Tabs.Content> | ||
</Tabs> | ||
|
||
**Under development** |
85 changes: 85 additions & 0 deletions
85
packages/dnb-design-system-portal/src/pages/uilib/components/date-picker/Examples.js
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,85 @@ | ||
/** | ||
* UI lib Component Example | ||
* | ||
*/ | ||
|
||
import React, { PureComponent, Fragment } from 'react' | ||
import ComponentBox from '../../../../shared/tags/ComponentBox' | ||
|
||
class Example extends PureComponent { | ||
render() { | ||
return ( | ||
<Fragment> | ||
<ComponentBox> | ||
{/* @jsx */ ` | ||
<DatePicker | ||
label="Range DatePicker:" | ||
start_date="2019-05-1" | ||
end_date="2019-05-17" | ||
range={true} | ||
show_input={true} | ||
on_change={({ start_date, end_date }) => { | ||
console.log('on_change', start_date, end_date) | ||
}} | ||
on_submit={({ start_date, end_date }) => { | ||
console.log('on_submit', start_date, end_date) | ||
}} | ||
on_cancel={({ start_date, end_date }) => { | ||
console.log('on_cancel', start_date, end_date) | ||
}} | ||
/> | ||
`} | ||
</ComponentBox> | ||
<ComponentBox> | ||
{/* @jsx */ ` | ||
<DatePicker | ||
label="Defualt DatePicker with Input:" | ||
date={new Date()} | ||
show_input={true} | ||
// show_submit_button={true} | ||
show_cancel_button={true} | ||
on_change={({ date }) => { | ||
console.log('on_change', date) | ||
}} | ||
on_cancel={({ date }) => { | ||
console.log('on_cancel', date) | ||
}} | ||
/> | ||
`} | ||
</ComponentBox> | ||
<ComponentBox> | ||
{/* @jsx */ ` | ||
<DatePicker | ||
label="Defualt DatePicker:" | ||
date="2019-05-05" | ||
on_change={({ date }) => { | ||
console.log('on_change', date) | ||
}} | ||
on_show={({ date }) => { | ||
console.log('on_show', date) | ||
}} | ||
/> | ||
`} | ||
</ComponentBox> | ||
<ComponentBox> | ||
{/* @jsx */ ` | ||
<DatePicker | ||
label="Hidden Nav:" | ||
date="2019-05-05" | ||
hide_navigation={true} | ||
hide_days={true} | ||
on_change={({ date }) => { | ||
console.log('on_change', date) | ||
}} | ||
on_hide={({ date }) => { | ||
console.log('on_hide', date) | ||
}} | ||
/> | ||
`} | ||
</ComponentBox> | ||
</Fragment> | ||
) | ||
} | ||
} | ||
|
||
export default Example |
24 changes: 24 additions & 0 deletions
24
...sign-system-portal/src/pages/uilib/components/date-picker/date-picker-events.md
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,24 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
## Events | ||
|
||
| Events | Description | | ||
| ----------- | ------------------------------------------------------------------------------------------- | | ||
| `on_change` | _(optional)_ will be called on a date change event. Returns an object with a date instance. | | ||
| `on_submit` | _(optional)_ will be called once a user presses the submit button. | | ||
| `on_cancel` | _(optional)_ will be called once a user presses the cancel button. | | ||
| `on_show` | _(optional)_ will be called once date-picker is visible. | | ||
| `on_hide` | _(optional)_ will be called once date-picker is hidden. | | ||
|
||
## Returned Object | ||
|
||
```js | ||
{ | ||
date: "return_format", /* Gets returned if range is true. Same as start_date and startDate */ | ||
start_date: "return_format", | ||
end_date: "return_format", | ||
days_between: number | ||
} | ||
``` |
17 changes: 17 additions & 0 deletions
17
...design-system-portal/src/pages/uilib/components/date-picker/date-picker-info.md
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,17 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
import Examples from 'Pages/uilib/components/date-picker/Examples' | ||
|
||
## Description | ||
|
||
The date-picker component should be used whenever there is to enter a single date or a date range/period with a start and end date. | ||
|
||
### Date Object | ||
|
||
The date-picker operates with a default JavaScript Date instance as well as string (ISO 8601) like `start_date="2019-05-05"`. | ||
|
||
## Demos | ||
|
||
<Examples /> |
25 changes: 25 additions & 0 deletions
25
...-system-portal/src/pages/uilib/components/date-picker/date-picker-properties.md
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,25 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
## Properties | ||
|
||
| Properties | Description | | ||
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `date` | _(optional)_ defines the pre filled date by either a JavaScript DateInstance or (ISO 8601) like `date="2019-05-05"`. | | ||
| `start_date` | _(optional)_ to set the pre filled starting date. Is used if `range={true}` is set to true. Defaults to null, showing the `mask_placeholder`. | | ||
| `end_date` | _(optional)_ to set the pre filled ending date. Is used if `range={true}` is set to true. Defaults to null, showing the `mask_placeholder`. | | ||
| `return_format` | _(optional)_ Defines how the returned date, as a string, should be formatted as. Defualts to `YYYY-MM-DD`. | | ||
| `range` | _(optional)_ if the date picker should support a range of two dates (starting and ending date). Defaults to `false`. | | ||
| `show_input` | _(optional)_ if the input fields with the mask should be visible. Defaults to `false`. | | ||
| `mask_order` | _(optional)_ to define the order of the masked placeholder input fields. Defaults to `dd/mm/yyyy` | | ||
| `opened` | _(optional)_ to open the date-picker by default. Defaults to `false`. | | ||
| `mask_placeholder` | _(optional)_ to display the placeholder on input. Defaults to `dd/mm/åååå`. | | ||
| `hide_navigation` | _(optional)_ if set to `true`, the navigation will be hidden. Defaults to `false`. | | ||
| `hide_days` | _(optional)_ if set to `true`, the week days will be hidden. Defaults to `false`. | | ||
| `show_submit_button` | _(optional)_ if set to `true`, a submit button will be shown. Defaults to `false`. | | ||
| `show_cancel_button` | _(optional)_ if set to `true`, a cancel button will be shown. Defaults to `false`. | | ||
| `link` | _(optional)_ link both calendars, once to user is navigating between months. Only meant to use if range is set to ture. Defaults to `false`. | | ||
| `first_day` | _(optional)_ to define the first day of the week. Defaults to `monday`. | | ||
| `locale` | _(optional)_ to define the locale used in the calendar. Needs to be an `date-fns` locale object, like `import nbLocale from 'date-fns/locale/nb'`. Defaults to `nb`. | | ||
| `label` | _(optional)_ a prepending label in sync with the date input field. | |
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
Oops, something went wrong.