-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: adding
DateField
docs page (#3188)
Co-authored-by: sarahgm <[email protected]>
- Loading branch information
1 parent
e382f83
commit 2f455d8
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
docs/content/components/datefield/date-field-basic.demo.tsx
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,10 @@ | ||
import { CalendarDate } from '@internationalized/date'; | ||
import { DateField } from '@marigold/components'; | ||
|
||
export default () => ( | ||
<DateField | ||
label="Date field" | ||
defaultValue={new CalendarDate(2020, 2, 3)} | ||
description="This is description" | ||
/> | ||
); |
9 changes: 9 additions & 0 deletions
9
docs/content/components/datefield/date-field-disabled.demo.tsx
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,9 @@ | ||
import { DateField } from '@marigold/components'; | ||
|
||
export default () => ( | ||
<DateField | ||
label="Field Disabled" | ||
disabled | ||
description="This field is disabled" | ||
/> | ||
); |
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,5 @@ | ||
import { DateField } from '@marigold/components'; | ||
|
||
export default () => ( | ||
<DateField label="Date field" error errorMessage="Something went wrong !" /> | ||
); |
5 changes: 5 additions & 0 deletions
5
docs/content/components/datefield/date-field-required.demo.tsx
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,5 @@ | ||
import { DateField } from '@marigold/components'; | ||
|
||
export default () => ( | ||
<DateField label="Date" required description="required 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
title: DateField | ||
group: Form | ||
caption: Component for input forms. | ||
# badge: 'new' | ||
--- | ||
|
||
The `<DateField>` allows users to enter and edit date values using a keyboard. Each part of a date value is displayed in an individually editable segment. | ||
|
||
The `<DateField>` segments are individually focusable and editable by the user, by typing or using the arrow keys to increment and decrement the value. This approach allows values to be formatted and parsed correctly regardless of the locale or date format, and offers an easy and error-free way to edit dates using the keyboard. | ||
|
||
## Usage | ||
|
||
### Import | ||
|
||
To import the component you just have to use this code below. | ||
|
||
```tsx | ||
import { DateField } from '@marigold/components'; | ||
``` | ||
|
||
### Props | ||
|
||
<PropsTable | ||
props={[ | ||
{ | ||
property: 'label', | ||
type: 'ReactNode', | ||
description: 'The label text. ', | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'description', | ||
type: 'ReactNode', | ||
description: 'A helpful text.', | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'errorMessage', | ||
type: 'ReactNode', | ||
description: 'An error message.', | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'error', | ||
type: 'boolean', | ||
description: | ||
'If `true`, the field is considered invalid and if set the errorMessage is shown instead of the `description`.', | ||
default: 'false', | ||
}, | ||
{ | ||
property: 'defaultValue', | ||
type: 'DateValue', | ||
description: 'The default value of the date field.', | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'value', | ||
type: 'DateValue', | ||
description: 'The value of the date field.', | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'disabled', | ||
type: 'boolean', | ||
description: 'If `true`, the date field is disabled.', | ||
default: 'false', | ||
}, | ||
{ | ||
property: 'required', | ||
type: 'boolean', | ||
description: 'If `true`, the date field is required.', | ||
default: 'false', | ||
}, | ||
{ | ||
property: 'readOnly', | ||
type: 'boolean', | ||
description: 'If `true`, the date field is readOnly.', | ||
default: 'false', | ||
}, | ||
{ | ||
property: 'onChange', | ||
type: 'function', | ||
description: | ||
"A callback function that is called with the date field's current value changes.", | ||
default: 'none', | ||
}, | ||
{ | ||
property: 'width', | ||
type: 'string', | ||
description: 'Control the width of the field.', | ||
default: '100%', | ||
}, | ||
]} | ||
/> | ||
|
||
## Examples | ||
|
||
### Simple DateField | ||
|
||
This example shows a regular `<DateField>` without any special props. | ||
|
||
<ComponentDemo file="./date-field-basic.demo.tsx" /> | ||
|
||
### Disabled DateField | ||
|
||
You can disable the `<DateField>` so that the user can't interact with it anymore. | ||
|
||
<ComponentDemo file="./date-field-disabled.demo.tsx" /> | ||
|
||
### Required DateField | ||
|
||
If you want a `<DateField>` to be required, you just have to add the property `required`. With that the small required icon appears next to the label. | ||
|
||
<ComponentDemo file="./date-field-required.demo.tsx" /> | ||
|
||
### DateField With an Error | ||
|
||
This example shows how to use the `error` with the `errorMessage`. | ||
|
||
<ComponentDemo file="./date-field-error.demo.tsx" /> |
2f455d8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
marigold-storybook – ./
marigold-storybook-git-main-marigold.vercel.app
marigold-latest.vercel.app
marigold-storybook-marigold.vercel.app
2f455d8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
marigold-docs – ./
marigold-docs.vercel.app
marigold-docs-git-main-marigold.vercel.app
marigold-docs-marigold.vercel.app