-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into nb-react-uswds-tooltip
- Loading branch information
Showing
5 changed files
with
692 additions
and
4 deletions.
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
102 changes: 102 additions & 0 deletions
102
src/components/forms/DateRangePicker/DateRangePicker.stories.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,102 @@ | ||
import React from 'react' | ||
|
||
import { DateRangePicker } from './DateRangePicker' | ||
import { Form } from '../Form/Form' | ||
import { addDays, formatDate } from '../DatePicker/utils' | ||
|
||
export default { | ||
title: 'Components/Form controls/Date range picker', | ||
component: DateRangePicker, | ||
argTypes: { | ||
onSubmit: { | ||
action: 'submitted' | ||
}, | ||
startDatePickerDisabled: { | ||
control: { type: 'boolean' }, | ||
defaultValue: false | ||
}, | ||
endDatePickerDisabled: { | ||
control: { type: 'boolean' }, | ||
defaultValue: false | ||
}, | ||
}, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: ` | ||
### USWDS 2.0 Date Range Picker component | ||
Source: https://designsystem.digital.gov/components/form-controls/#date-range-picker | ||
` | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export const completeDateRangePicker = (argTypes): React.ReactElement => ( | ||
<Form onSubmit={argTypes.onSubmit}> | ||
<DateRangePicker | ||
startDateLabel="Event start date" | ||
startDateHint="mm/dd/yyyy" | ||
startDatePickerProps={{ | ||
id: "event-date-start", | ||
name: "event-date-start", | ||
disabled: argTypes.startDatePickerDisabled | ||
}} | ||
endDateLabel="Event end date" | ||
endDateHint="mm/dd/yyyy" | ||
endDatePickerProps={{ | ||
id: "event-date-end", | ||
name: "event-date-end", | ||
disabled: argTypes.endDatePickerDisabled | ||
}} | ||
/> | ||
</Form> | ||
) | ||
|
||
export const withDefaultValues = (argTypes): React.ReactElement => ( | ||
<Form onSubmit={argTypes.onSubmit}> | ||
<DateRangePicker | ||
startDateLabel="Event start date" | ||
startDateHint="mm/dd/yyyy" | ||
startDatePickerProps={{ | ||
id: "event-date-start", | ||
name: "event-date-start", | ||
defaultValue: "2021-01-20", | ||
disabled: argTypes.startDatePickerDisabled | ||
}} | ||
endDateLabel="Event end date" | ||
endDateHint="mm/dd/yyyy" | ||
endDatePickerProps={{ | ||
id: "event-date-end", | ||
name: "event-date-end", | ||
defaultValue: "2021-01-25", | ||
disabled: argTypes.endDatePickerDisabled | ||
}} | ||
/> | ||
</Form> | ||
) | ||
|
||
export const withAllowableRanges = (argTypes): React.ReactElement => ( | ||
<Form onSubmit={argTypes.onSubmit}> | ||
<DateRangePicker | ||
startDateLabel="Event start date" | ||
startDateHint="mm/dd/yyyy" | ||
startDatePickerProps={{ | ||
id: "event-date-start", | ||
name: "event-date-start", | ||
minDate: "2021-01-01", | ||
maxDate: "2021-01-20", | ||
disabled: argTypes.startDatePickerDisabled | ||
}} | ||
endDateLabel="Event end date" | ||
endDateHint="mm/dd/yyyy" | ||
endDatePickerProps={{ | ||
id: "event-date-end", | ||
name: "event-date-end", | ||
minDate: "2021-01-20", | ||
maxDate: "2021-01-25", | ||
disabled: argTypes.endDatePickerDisabled | ||
}} | ||
/> | ||
</Form> | ||
) |
Oops, something went wrong.