Skip to content

Commit

Permalink
feat: more dqa comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasdano committed Oct 13, 2023
1 parent d32bd15 commit d47fd76
Show file tree
Hide file tree
Showing 18 changed files with 2,772 additions and 1,317 deletions.
2 changes: 1 addition & 1 deletion src/components/DatePicker/DatePickInput/DatePickInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const DatePickInput = React.forwardRef<HTMLInputElement, DatePickInputProps>(
);

const getLabel = useMemo(() => {
if (inputProps?.label.length) {
if (inputProps?.label?.length) {
return inputProps.label;
}

Expand Down
126 changes: 119 additions & 7 deletions src/components/DatePicker/DatePicker.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Implementation of the regular DatePicker

<Preview>
<Story name="DatePicker" parameters={{ decorators: [withKnobs] }} play={openDatePicker} autoPlay>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand Down Expand Up @@ -97,7 +97,7 @@ Implementation of the regular DateRangePicker
play={openDatePicker}
autoPlay
>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand All @@ -117,13 +117,93 @@ Implementation of the regular DateRangePicker
</Story>
</Preview>

### DatePicker and DateRangePicker with Statuses

DatePicker and DateRangePicker inherit all TextField statuses behavior.

<Preview>
<Story
name="DatePicker and DateRangePicker with Statuses"
parameters={{ decorators: [withKnobs] }}
>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Normal',
status: {
type: 'normal',
hintMessage: text('Custom Hint Message', 'Hint Message'),
},
}}
/>
);
}}
</Function>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Error',
status: {
type: 'error',
hintMessage: text('Custom Error Message', 'Error Message'),
},
}}
/>
);
}}
</Function>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Read-only',
status: {
type: 'read-only',
hintMessage: text('Custom Hint Message', 'Hint Message'),
},
}}
/>
);
}}
</Function>
</Stack>
</Story>
</Preview>

### DateRangePicker with options

Implementation of the regular DatePicker with options

<Preview>
<Story name="DateRangePicker with options" parameters={{ decorators: [withKnobs] }}>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand All @@ -150,7 +230,7 @@ Implementation of the DatePicker with a Filter instead of a TextField

<Preview>
<Story name="DatePicker with Filter" parameters={{ decorators: [withKnobs] }}>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: undefined, to: undefined });
Expand Down Expand Up @@ -185,13 +265,13 @@ Implementation of the DatePicker with a Filter instead of a TextField
</Story>
</Preview>

### DayPicker with disabled dates
### DatePicker with disabled dates

Some disable dates functionality

<Preview>
<Story name="DayPicker with disabled dates">
<Stack>
<Story name="DatePicker with disabled dates">
<Stack height={600}>
<Function>
{() => {
const [date, setDate] = useState({
Expand All @@ -205,6 +285,38 @@ Some disable dates functionality
</Story>
</Preview>

### Disabled DatePicker & DateRangePicker

Disabled DatePicker & DateRangePicker

<Preview>
<Story name="Disabled DatePicker & DateRangePicker">
<Stack>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
inputProps={{
label: 'Normal',
status: {
type: 'normal',
hintMessage: 'This field is disabled',
},
isDisabled: true,
}}
/>
);
}}
</Function>
</Stack>
</Story>
</Preview>

### Playground

<Preview>
Expand Down
Loading

0 comments on commit d47fd76

Please sign in to comment.