From f3a58145ee14a77f7eac83db6f0183ff8a411f0e Mon Sep 17 00:00:00 2001 From: "GitStart-Cal.com" <121884634+gitstart-calcom@users.noreply.github.com> Date: Tue, 22 Aug 2023 06:27:27 -0300 Subject: [PATCH] chore: add datePicker in storybook (CALCOM-10760) (#10784) * Update datepicker.stories.mdx * Update datepicker.stories.mdx * Requested changes --------- Co-authored-by: gitstart-calcom --- packages/features/calendars/DatePicker.tsx | 6 +- .../features/calendars/datepicker.stories.mdx | 78 +++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 packages/features/calendars/datepicker.stories.mdx diff --git a/packages/features/calendars/DatePicker.tsx b/packages/features/calendars/DatePicker.tsx index a1bd85741b..bb4485f5ea 100644 --- a/packages/features/calendars/DatePicker.tsx +++ b/packages/features/calendars/DatePicker.tsx @@ -69,7 +69,11 @@ export const Day = ({ {...props}> {date.date()} {date.isToday() && ( - + {t("today")} )} diff --git a/packages/features/calendars/datepicker.stories.mdx b/packages/features/calendars/datepicker.stories.mdx new file mode 100644 index 0000000000..8d48fd9f19 --- /dev/null +++ b/packages/features/calendars/datepicker.stories.mdx @@ -0,0 +1,78 @@ +import { Canvas, Meta, Story, ArgsTable } from "@storybook/addon-docs"; + +import { + Examples, + Example, + Title, + VariantsTable, + CustomArgsTable, + VariantRow, +} from "@calcom/storybook/components"; +import dayjs from "@calcom/dayjs"; + +import DatePicker from "./DatePicker"; + + + + + +## Definition + +DatePicker is a clickable element that allows the user to select a specific date from the available list in the component. + +## Structure + +DatePicker component offers a complete and customizable element for the user to select a specific date in the calendar. + +<CustomArgsTable of={DatePicker} /> + +<Examples title="DatePicker"> + <Example title="Default"> + <DatePicker /> + </Example> +</Examples> + +<Title offset title="DatePicker" suffix="Variants" /> + +<Canvas> + <Story + name="DatePicker" + args={{ + weekStart: 0, + excludedDates: ["2023-08-20", "2023-08-21"], + minDate: dayjs("2023-07-23").utc(), + maxDate: dayjs("2023-08-30").utc(), + selected: dayjs("2023-08-30").utc(), + isLoading: false, + onChange: (newDate) => console.log(newDate), + onMonthChange: (newMonth) => console.log(newMonth), + }} + argTypes={{ + weekStart: { + control: { + type: "inline-radio", + options: [0, 1, 2, 3, 4, 5, 6], + }, + }, + selected: { + control: "date" + } + }}> + {({ weekStart, excludedDates, onChange, onMonthChange, minDate, maxDate, selected, isLoading }) => ( + <VariantsTable titles={["Default"]} columnMinWidth={150}> + <VariantRow variant="Default"> + <DatePicker + weekStart={weekStart} + excludedDates={excludedDates} + minDate={dayjs(minDate).utc()} + maxDate={dayjs(maxDate).utc()} + onChange={onChange} + onMonthChange={onMonthChange} + selected={dayjs(selected)} + isLoading={isLoading} + /> + </VariantRow> + </VariantsTable> + )} + </Story> +</Canvas>