updates storybook config and fixes and updates stories (#12683)
add packages
This commit is contained in:
1 parent
9f50941904
commit
ca0d23529a
30 files changed
+497
-409
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { Canvas, Meta } from "@storybook/blocks";
|
||||
|
||||
import { Title, CustomArgsTable } from "@calcom/storybook/components";
|
||||
|
||||
import { VerifyCodeDialog } from "./VerifyCodeDialog";
|
||||
import * as VerifyCodeDialogStories from "./VerifyCodeDialog.stories";
|
||||
|
||||
<Meta of={VerifyCodeDialogStories} />
|
||||
|
||||
<Title title="VerifyCodeDialog" suffix="Brief" subtitle="Version 1.0 — Last Update: 11 Sep 2023" />
|
||||
|
||||
## Definition
|
||||
|
||||
The `VerifyCodeDialog` component allows users to enter a verification code sent to their email. The component provides feedback in case of an error and can handle different verification processes depending on whether the user session is required.
|
||||
|
||||
## Structure
|
||||
|
||||
This component contains an input form to capture a 6-digit verification code, error handling UI, and action buttons.
|
||||
|
||||
<CustomArgsTable of={VerifyCodeDialog} />
|
||||
|
||||
{/* ## VerifyCodeDialog Story
|
||||
|
||||
<Canvas of={VerifyCodeDialogStories.Default} /> */}
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { StorybookTrpcProvider } from "@calcom/ui";
|
||||
|
||||
import { VerifyCodeDialog } from "./VerifyCodeDialog";
|
||||
|
||||
type StoryArgs = ComponentProps<typeof VerifyCodeDialog>;
|
||||
|
||||
const meta: Meta<StoryArgs> = {
|
||||
component: VerifyCodeDialog,
|
||||
title: "Features/VerifyCodeDialog",
|
||||
argTypes: {
|
||||
isOpenDialog: { control: "boolean", description: "Indicates whether the dialog is open or not." },
|
||||
setIsOpenDialog: { action: "setIsOpenDialog", description: "Function to set the dialog state." },
|
||||
email: { control: "text", description: "Email to which the verification code was sent." },
|
||||
onSuccess: { action: "onSuccess", description: "Callback function when verification succeeds." },
|
||||
// onError: { action: "onError", description: "Callback function when verification fails." },
|
||||
isUserSessionRequiredToVerify: {
|
||||
control: "boolean",
|
||||
description: "Indicates if user session is required for verification.",
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<StorybookTrpcProvider>
|
||||
<Story />
|
||||
</StorybookTrpcProvider>
|
||||
),
|
||||
],
|
||||
render: (args) => <VerifyCodeDialog {...args} />,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<StoryArgs>;
|
||||
|
||||
export const Default: Story = {
|
||||
name: "Dialog",
|
||||
args: {
|
||||
isOpenDialog: true,
|
||||
email: "[email protected]",
|
||||
// onError: (err) => {
|
||||
// if (err.message === "invalid_code") {
|
||||
// alert("Code provided is invalid");
|
||||
// }
|
||||
// },
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Canvas, Meta } from "@storybook/blocks";
|
||||
|
||||
import { Title } from "@calcom/storybook/components";
|
||||
|
||||
import * as EventMetaStories from "./EventMeta.stories";
|
||||
|
||||
<Meta of={EventMetaStories} />
|
||||
|
||||
<Title title="Event Meta" suffix="Brief" subtitle="Version 2.0 — Last Update: 12 Dec 2022" />
|
||||
|
||||
<Canvas of={EventMetaStories.ExampleStory} />
|
||||
|
||||
<Canvas of={EventMetaStories.AllVariants} />
|
||||
@@ -1,59 +0,0 @@
|
||||
import { TooltipProvider } from "@radix-ui/react-tooltip";
|
||||
import { Canvas, Meta, Story, ArgsTable } from "@storybook/addon-docs";
|
||||
|
||||
import {
|
||||
Examples,
|
||||
Example,
|
||||
Note,
|
||||
Title,
|
||||
VariantsTable,
|
||||
VariantColumn,
|
||||
RowTitles,
|
||||
CustomArgsTable,
|
||||
VariantRow,
|
||||
} from "@calcom/storybook/components";
|
||||
import { Icon } from "@calcom/ui";
|
||||
|
||||
import { EventDetails } from "./Details";
|
||||
import { EventMembers } from "./Members";
|
||||
import { EventTitle } from "./Title";
|
||||
import { mockEvent } from "./event.mock.ts";
|
||||
|
||||
<Meta title="Features/Events/Meta" component={EventDetails} />
|
||||
|
||||
<Title title="Event Meta" suffix="Brief" subtitle="Version 2.0 — Last Update: 12 Dec 2022" />
|
||||
<TooltipProvider>
|
||||
<Examples title="Combined event meta block">
|
||||
<div style={{ maxWidth: 300 }}>
|
||||
<Example title="Event Title">
|
||||
<EventTitle event={mockEvent} />
|
||||
</Example>
|
||||
<Example title="Event Details">
|
||||
<EventDetails event={mockEvent} />
|
||||
</Example>
|
||||
</div>
|
||||
</Examples>
|
||||
</TooltipProvider>
|
||||
|
||||
<Canvas>
|
||||
<Story name="All variants">
|
||||
<VariantsTable titles={["Event Meta Components"]} columnMinWidth={150}>
|
||||
<VariantRow variant="">
|
||||
<div style={{ maxWidth: 300 }}>
|
||||
<TooltipProvider>
|
||||
<EventMembers
|
||||
entity={{ name: "entityName" }}
|
||||
profile={{ name: "profileName" }}
|
||||
users={[
|
||||
{ name: "Pro example", username: "pro" },
|
||||
{ name: "Team example", username: "team" },
|
||||
]}
|
||||
/>
|
||||
<EventTitle>Quick catch-up</EventTitle>
|
||||
<EventDetails event={mockEvent} />
|
||||
</TooltipProvider>
|
||||
</div>
|
||||
</VariantRow>
|
||||
</VariantsTable>
|
||||
</Story>
|
||||
</Canvas>
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import type { PublicEvent } from "bookings/types";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { Examples, Example, VariantsTable, VariantRow } from "@calcom/storybook/components";
|
||||
|
||||
import { EventDetails } from "./Details";
|
||||
import { EventMembers } from "./Members";
|
||||
import { EventTitle } from "./Title";
|
||||
import { mockEvent } from "./event.mock";
|
||||
|
||||
type StoryArgs = ComponentProps<typeof EventDetails>;
|
||||
|
||||
const meta: Meta<StoryArgs> = {
|
||||
component: EventDetails,
|
||||
parameters: {
|
||||
nextjs: {
|
||||
appDirectory: true,
|
||||
},
|
||||
},
|
||||
title: "Features/Events/Meta",
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<StoryArgs>;
|
||||
|
||||
export const ExampleStory: Story = {
|
||||
name: "Examples",
|
||||
render: () => (
|
||||
<Examples title="Combined event meta block">
|
||||
<div style={{ maxWidth: 300 }}>
|
||||
<Example title="Event Title">
|
||||
<EventTitle>{mockEvent.title}</EventTitle>
|
||||
</Example>
|
||||
<Example title="Event Details">
|
||||
<EventDetails event={mockEvent} />
|
||||
</Example>
|
||||
</div>
|
||||
</Examples>
|
||||
),
|
||||
};
|
||||
|
||||
export const AllVariants: Story = {
|
||||
name: "All variants",
|
||||
render: () => (
|
||||
<VariantsTable titles={["Event Meta Components"]} columnMinWidth={150}>
|
||||
<VariantRow variant="">
|
||||
<div style={{ maxWidth: 300 }}>
|
||||
<EventMembers
|
||||
users={mockEvent.users}
|
||||
schedulingType="COLLECTIVE"
|
||||
entity={{ isUnpublished: false, name: "Example", orgSlug: null }}
|
||||
// TODO remove type assertion
|
||||
profile={{ weekStart: "Sunday" } as PublicEvent["profile"]}
|
||||
/>
|
||||
<EventTitle>Quick catch-up</EventTitle>
|
||||
<EventDetails event={mockEvent} />
|
||||
</div>
|
||||
</VariantRow>
|
||||
</VariantsTable>
|
||||
),
|
||||
};
|
||||
@@ -1,14 +1,17 @@
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import type { PublicEvent } from "bookings/types";
|
||||
|
||||
export const mockEvent: RouterOutputs["viewer"]["public"]["event"] = {
|
||||
export const mockEvent: PublicEvent = {
|
||||
id: 1,
|
||||
title: "Quick check-in",
|
||||
slug: "quick-check-in",
|
||||
eventName: "Quick check-in",
|
||||
description:
|
||||
"Use this event for a quick 15 minute catchup. Visit this long url to test the component https://cal.com/averylongurlwithoutspacesthatshouldntbreaklayout",
|
||||
users: [{ name: "Pro Example", username: "pro" }],
|
||||
users: [
|
||||
{ name: "Pro example", username: "pro", weekStart: "Sunday", organizationId: null },
|
||||
{ name: "Team example", username: "team", weekStart: "Sunday", organizationId: 1 },
|
||||
],
|
||||
schedulingType: null,
|
||||
length: 30,
|
||||
locations: [{ type: "integrations:google:meet" }, { type: "integrations:zoom" }],
|
||||
};
|
||||
} as PublicEvent; // TODO: complete mock and remove type assertion
|
||||
@@ -1,60 +0,0 @@
|
||||
import { Canvas, Meta, Story } from "@storybook/addon-docs";
|
||||
|
||||
import { Title, CustomArgsTable } from "@calcom/storybook/components";
|
||||
|
||||
import { StorybookTrpcProvider } from "../../../ui/components/mocks/trpc.tsx";
|
||||
import { VerifyCodeDialog } from "./VerifyCodeDialog";
|
||||
|
||||
<Meta title="Features/VerifyCodeDialog" component={VerifyCodeDialog} />
|
||||
|
||||
<Title title="VerifyCodeDialog" suffix="Brief" subtitle="Version 1.0 — Last Update: 11 Sep 2023" />
|
||||
|
||||
## Definition
|
||||
|
||||
The `VerifyCodeDialog` component allows users to enter a verification code sent to their email. The component provides feedback in case of an error and can handle different verification processes depending on whether the user session is required.
|
||||
|
||||
## Structure
|
||||
|
||||
This component contains an input form to capture a 6-digit verification code, error handling UI, and action buttons.
|
||||
|
||||
<CustomArgsTable of={VerifyCodeDialog} />
|
||||
|
||||
## VerifyCodeDialog Story
|
||||
|
||||
<Canvas>
|
||||
<Story
|
||||
name="VerifyCodeDialog"
|
||||
parameters={{
|
||||
nextjs: {
|
||||
appDirectory: true,
|
||||
},
|
||||
}}
|
||||
args={{
|
||||
isOpenDialog: true,
|
||||
setIsOpenDialog: () => {},
|
||||
email: "[email protected]",
|
||||
onSuccess: () => {},
|
||||
onError: (err) => {
|
||||
if (err.message === "invalid_code") {
|
||||
alert("Code provided is invalid");
|
||||
}
|
||||
},
|
||||
}}
|
||||
argTypes={{
|
||||
isOpenDialog: { control: "boolean", description: "Indicates whether the dialog is open or not." },
|
||||
setIsOpenDialog: { action: "setIsOpenDialog", description: "Function to set the dialog state." },
|
||||
email: { control: "text", description: "Email to which the verification code was sent." },
|
||||
onSuccess: { action: "onSuccess", description: "Callback function when verification succeeds." },
|
||||
onError: { action: "onError", description: "Callback function when verification fails." },
|
||||
isUserSessionRequiredToVerify: {
|
||||
control: "boolean",
|
||||
description: "Indicates if user session is required for verification.",
|
||||
},
|
||||
}}>
|
||||
{(args) => (
|
||||
<StorybookTrpcProvider>
|
||||
<VerifyCodeDialog {...args} />
|
||||
</StorybookTrpcProvider>
|
||||
)}
|
||||
</Story>
|
||||
</Canvas>
|
||||
Reference in new issue
Block a user