updates storybook config and fixes and updates stories (#12683)

add packages
This commit is contained in:
Henrik Klee authored and GitHub committed 2023-12-06 10:41:35 +02:00
1 parent 9f50941904
commit ca0d23529a
30 files changed
+497 -409

No files matched your search

@@ -15,7 +15,7 @@ import { Badge } from "./Badge";
<Meta title="UI/Badge" component={Badge} />
<Title title="Bages" suffix="Brief" subtitle="Version 2.0 — Last Update: 22 Aug 2022" />
<Title title="Badge" suffix="Brief" subtitle="Version 2.0 — Last Update: 22 Aug 2022" />
## Definition
@@ -2,7 +2,7 @@ import { Canvas, Meta, Story, ArgsTable } from "@storybook/addon-docs";
import { Examples, Example, Note, Title, CustomArgsTable } from "@calcom/storybook/components";
import { Breadcrumb } from "./Breadcrumb";
import { Breadcrumb, BreadcrumbItem } from "./Breadcrumb";
<Meta title="UI/Breadcrumbs" component={Breadcrumb} />
@@ -0,0 +1,52 @@
import { Meta } from "@storybook/blocks";
import { Title, CustomArgsTable } from "@calcom/storybook/components";
import { Dialog, DialogContent, DialogFooter, DialogClose, DialogHeader } from "./Dialog";
import * as DialogStories from "./Dialog.stories";
<Meta of={DialogStories} />
<Title title="Dialog" suffix="Brief" subtitle="Version 1.0 — Last Update: 18 Aug 2023" />
## Definition
The `Dialog` component provides a flexible way to create dialogs in your application.
## Structure
The `Dialog` component is composed of the following components:
- `Dialog`: The main component that wraps the entire dialog. It manages the dialog's open and close states.
- `DialogContent`: Represents the content of the dialog. It can have different sizes, types, and an optional icon.
- `DialogHeader`: Renders the header of the dialog, including the title and subtitle.
- `DialogFooter`: Renders the footer of the dialog, which can contain action buttons.
- `DialogClose`: Renders a close button for the dialog.
## Components Arguments
### Dialog
<CustomArgsTable of={Dialog} />
### DialogContent
<CustomArgsTable of={DialogContent} />
### DialogHeader
<CustomArgsTable of={DialogHeader} />
### DialogFooter
<CustomArgsTable of={DialogFooter} />
### DialogClose
<CustomArgsTable of={DialogClose} />
{/* ## Dialog Story
<Canvas of={DialogStories.Default}/> */}
@@ -0,0 +1,87 @@
import type { Meta, StoryObj } from "@storybook/react";
import type { ComponentProps } from "react";
import { Dialog, DialogContent, DialogFooter, DialogClose, DialogHeader } from "./Dialog";
type StoryArgs = ComponentProps<typeof Dialog> &
ComponentProps<typeof DialogContent> &
ComponentProps<typeof DialogHeader> &
ComponentProps<typeof DialogFooter> &
ComponentProps<typeof DialogClose> & {
onClick: (...args: unknown[]) => void;
};
const meta: Meta<StoryArgs> = {
component: Dialog,
parameters: {
nextjs: {
appDirectory: true,
},
},
title: "UI/Dialog",
argTypes: {
title: {
control: "text",
},
description: {
control: "text",
},
type: {
options: ["creation", "confirmation"],
control: {
type: "select",
},
},
open: {
control: "boolean",
},
showDivider: {
control: "boolean",
},
disabled: {
control: "boolean",
},
color: {
options: ["minimal", "primary", "secondary", "emphasis"],
control: {
type: "select",
},
},
onClick: { action: "clicked" }, // this is a storybook action addons action
},
render: ({ title, description, type, open, showDivider, disabled, color, onClick }) => (
<Dialog open={open}>
<DialogContent type={type}>
<DialogHeader title={title} subtitle={description} />
<DialogFooter showDivider={showDivider}>
<DialogClose
disabled={disabled}
color={color}
onClick={() => {
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.set("args", "open:false");
window.open(currentUrl.toString(), "_self");
onClick();
}}
/>
</DialogFooter>
</DialogContent>
</Dialog>
),
};
export default meta;
type Story = StoryObj<StoryArgs>;
export const Default: Story = {
name: "Dialog",
args: {
title: "Example Dialog",
description: "Example Dialog Description",
type: "creation",
open: true,
showDivider: false,
disabled: false,
color: "minimal",
},
};
@@ -1,119 +0,0 @@
import { Canvas, Meta, Story } from "@storybook/addon-docs";
import { Title, CustomArgsTable } from "@calcom/storybook/components";
import { Dialog, DialogContent, DialogFooter, DialogClose, DialogHeader } from "./Dialog";
<Meta title="UI/Dialog" component={Dialog} />
<Title title="Dialog" suffix="Brief" subtitle="Version 1.0 — Last Update: 18 Aug 2023" />
## Definition
The `Dialog` component provides a flexible way to create dialogs in your application.
## Structure
The `Dialog` component is composed of the following components:
- `Dialog`: The main component that wraps the entire dialog. It manages the dialog's open and close states.
- `DialogContent`: Represents the content of the dialog. It can have different sizes, types, and an optional icon.
- `DialogHeader`: Renders the header of the dialog, including the title and subtitle.
- `DialogFooter`: Renders the footer of the dialog, which can contain action buttons.
- `DialogClose`: Renders a close button for the dialog.
## Components Arguments
### Dialog
<CustomArgsTable of={Dialog} />
### DialogContent
<CustomArgsTable of={DialogContent} />
### DialogHeader
<CustomArgsTable of={DialogHeader} />
### DialogFooter
<CustomArgsTable of={DialogFooter} />
### DialogClose
<CustomArgsTable of={DialogClose} />
## Dialog Story
<Canvas>
<Story
name="Dialog"
parameters={{
nextjs: {
appDirectory: true,
},
}}
args={{
title: "Example Dialog",
description: "Example Dialog Description",
type: "creation",
open: true,
showDivider: false,
disabled: false,
color: "minimal",
}}
argTypes={{
title: {
control: "text",
},
description: {
control: "text",
},
type: {
control: {
type: "select",
options: ["creation", "confirmation"],
},
},
open: {
control: "boolean",
},
showDivider: {
control: "boolean",
},
disabled: {
control: "boolean",
},
color: {
control: {
type: "select",
options: ["minimal", "primary", "secondary", "emphasis"],
},
},
onClick: { action: "clicked" },
}}>
{({ title, description, type, open, showDivider, disabled, color, onClick }) => (
<Dialog title="Default" open={open}>
<DialogContent type={type}>
<DialogHeader title={title} subtitle={description} />
<DialogFooter showDivider={showDivider}>
<DialogClose
disabled={disabled}
color={color}
onClick={() => {
const newPath = "?path=/story/ui-dialog--dialog&args=open:false";
window.open(newPath, "_self");
onClick();
}}
/>
</DialogFooter>
</DialogContent>
</Dialog>
)}
</Story>
</Canvas>
@@ -1,7 +1,4 @@
import { TooltipProvider } from "@radix-ui/react-tooltip";
import {
Tooltip,
} from "@calcom/ui";
import { Tooltip } from "@radix-ui/react-tooltip";
import { Canvas, Meta, Story } from "@storybook/addon-docs";
import {
@@ -69,17 +66,15 @@ The `Color Picker` takes in several props
{({ defaultValue, onChange, resetDefaultValue, className, popoverAlign }) => (
<VariantsTable titles={["Default"]} columnMinWidth={150}>
<VariantRow>
<TooltipProvider>
<Tooltip content="color picker">
<ColorPicker
defaultValue={defaultValue}
onChange={onChange}
resetDefaultValue={resetDefaultValue}
className={className}
popoverAlign={popoverAlign}
/>
</Tooltip>
</TooltipProvider>
<Tooltip content="color picker">
<ColorPicker
defaultValue={defaultValue}
onChange={onChange}
resetDefaultValue={resetDefaultValue}
className={className}
popoverAlign={popoverAlign}
/>
</Tooltip>
</VariantRow>
</VariantsTable>
)}
@@ -48,7 +48,7 @@ describe("Tests for ColorPicker component", () => {
const colorInput = screen.getByRole("textbox");
await act(async () => userEvent.clear(colorInput));
const newColorValue = "#00FF00";
await act(async () => userEvent.type(colorInput, newColorValue));
await act(async () => await userEvent.type(colorInput, newColorValue));
expect(screen.getByRole("button", { name: "pick colors" })).toHaveStyle(
`background-color: ${newColorValue}`
);
@@ -1,5 +1,4 @@
import { Canvas, Meta, Story } from "@storybook/addon-docs";
import { useRouter } from "next/router";
import { CustomArgsTable, Title, VariantsTable, VariantRow } from "@calcom/storybook/components";
@@ -1,4 +1,4 @@
import { Meta, Story } from "@storybook/addon-docs/blocks";
import { Meta, Story, Canvas } from "@storybook/addon-docs/blocks";
import {
Title,
@@ -6,7 +6,7 @@ import {
Examples,
Example,
VariantsTable,
VariantsRow,
VariantRow,
} from "@calcom/storybook/components";
import { Plus } from "@calcom/ui/components/icon";
@@ -0,0 +1,20 @@
import { Canvas, Meta } from "@storybook/blocks";
import { Title, CustomArgsTable } from "@calcom/storybook/components";
import { TooltipProvider } from "@radix-ui/react-tooltip";
import { Tooltip } from "./Tooltip";
import * as TooltipStories from "./Tooltip.stories";
<Meta of={TooltipStories} />
<Title title="Tooltip" suffix="Brief" subtitle="Version 2.0 — Last Update: 06 Jan 2023" />
## Definition
Tooltip components can be used to provide additional information about an element when the user hovers over or focuses on the element.
<TooltipProvider>
<CustomArgsTable of={Tooltip} />
</TooltipProvider>
<Canvas of={TooltipStories.Default}/>
@@ -0,0 +1,37 @@
import type { Meta, StoryObj } from "@storybook/react";
import { VariantRow, VariantsTable } from "@calcom/storybook/components";
import { Tooltip } from "./Tooltip";
const meta: Meta<typeof Tooltip> = {
component: Tooltip,
title: "UI/Tooltip",
};
export default meta;
type Story = StoryObj<typeof Tooltip>;
export const Default: Story = {
name: "Tooltip",
parameters: {
hoverMsg: "Click to copy",
alertMsg: "Copied!",
content: "Copy me!",
},
render: (_, { parameters: { content, hoverMsg, alertMsg } }) => (
<VariantsTable titles={[]}>
<VariantRow variant="Default">
<Tooltip content={`${hoverMsg}`}>
<span
className="dark:text-darkgray-50 bg-brand-default dark:bg-darkgray-900 rounded-md p-2 text-gray-100 hover:cursor-pointer"
onClick={() => {
alert(`${alertMsg}`);
}}>
{content}
</span>
</Tooltip>
</VariantRow>
</VariantsTable>
),
};
@@ -1,69 +0,0 @@
import { TooltipProvider } from "@radix-ui/react-tooltip";
import { Canvas, Meta, Story, ArgsTable } from "@storybook/addon-docs";
import {
Examples,
Example,
Note,
Title,
CustomArgsTable,
VariantsTable,
VariantRow,
} from "@calcom/storybook/components";
import Tooltip from "./Tooltip";
<Meta title="UI/Tooltip" component={Tooltip} />
<Title title="Tooltip" suffix="Brief" subtitle="Version 2.0 — Last Update: 06 Jan 2023" />
## Definition
Tooltip components can be used to provide additional information about an element when the user hovers over or focuses on the element.
<CustomArgsTable of={Tooltip} />
<Canvas>
<Story
name="Tooltip"
args={{
alertMsg: "Copied!",
hoverMsg: "Copy to clipboard",
content: "Hover Me",
}}
argTypes={{
alertMsg: {
control: {
type: "text",
},
},
hoverMsg: {
control: {
type: "text",
},
},
content: {
control: {
type: "text",
},
},
}}>
{({ alertMsg, hoverMsg, content }) => (
<TooltipProvider>
<VariantsTable titles={[""]} columnMinWidth={150}>
<VariantRow variant="Default">
<Tooltip content={`${hoverMsg}`}>
<span
className="dark:text-darkgray-50 bg-brand-default dark:bg-darkgray-900 rounded-md p-2 text-gray-100 hover:cursor-pointer"
onClick={() => {
alert(`${alertMsg}`);
}}>
{content}
</span>
</Tooltip>
</VariantRow>
</VariantsTable>
</TooltipProvider>
)}
</Story>
</Canvas>