From df4c4d9d622e24be0f688d451a38944e94573578 Mon Sep 17 00:00:00 2001 From: Gabriel Graves Date: Wed, 6 Mar 2024 08:43:49 +0000 Subject: [PATCH] Add Card component and Card stories --- components/ui/card.tsx | 87 ++++++++++++++++++++++++++++++++++++++++ stories/Card.stories.tsx | 52 ++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 components/ui/card.tsx create mode 100644 stories/Card.stories.tsx diff --git a/components/ui/card.tsx b/components/ui/card.tsx new file mode 100644 index 0000000..7dd76f9 --- /dev/null +++ b/components/ui/card.tsx @@ -0,0 +1,87 @@ +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +Card.displayName = "Card"; + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +CardHeader.displayName = "CardHeader"; + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardTitle.displayName = "CardTitle"; + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardDescription.displayName = "CardDescription"; + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardContent.displayName = "CardContent"; + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +CardFooter.displayName = "CardFooter"; + +export { + Card, + CardHeader, + CardFooter, + CardTitle, + CardDescription, + CardContent, +}; diff --git a/stories/Card.stories.tsx b/stories/Card.stories.tsx new file mode 100644 index 0000000..81655d6 --- /dev/null +++ b/stories/Card.stories.tsx @@ -0,0 +1,52 @@ +/* eslint-disable react/jsx-no-literals */ +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; + +import type { Meta, StoryObj } from "@storybook/react"; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: "Ui/Card", + component: Card, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: "centered", + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ["autodocs"], +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const PrimaryExample: Story = { + args: { + children: ( + <> + + Card Title + Card Description + + +

Card Content

+
+ +

Card Footer

+
+ + ), + }, +}; + +export const Secondary: Story = { + args: { + children: "Button", + }, +};