From ce043325481011ab2db551d398b1c586221c5ae1 Mon Sep 17 00:00:00 2001 From: Umut Sirin Date: Tue, 8 Aug 2023 01:00:05 -0700 Subject: [PATCH] feat(packages/ui): add and
components & their stories (#614) Adds `` and `` components to our design system/component lib. --- apps/ui/stories/Avatar.stories.tsx | 2 +- apps/ui/stories/Card.stories.tsx | 68 +++++++++++ apps/ui/stories/Form.stories.tsx | 115 +++++++++++++++++ apps/ui/stories/Toast.stories.tsx | 1 + package-lock.json | 28 ++++- packages/ui/components/card.tsx | 56 +++++++++ packages/ui/components/form.tsx | 190 +++++++++++++++++++++++++++++ packages/ui/components/index.ts | 2 + packages/ui/index.ts | 5 + packages/ui/package.json | 5 +- 10 files changed, 469 insertions(+), 3 deletions(-) create mode 100644 apps/ui/stories/Card.stories.tsx create mode 100644 apps/ui/stories/Form.stories.tsx create mode 100644 packages/ui/components/card.tsx create mode 100644 packages/ui/components/form.tsx diff --git a/apps/ui/stories/Avatar.stories.tsx b/apps/ui/stories/Avatar.stories.tsx index 8eb35274..0c5abfaf 100644 --- a/apps/ui/stories/Avatar.stories.tsx +++ b/apps/ui/stories/Avatar.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; -import { UserAvatar } from "@kampus/ui-next/components/user-avatar"; +import { UserAvatar } from "@kampus/ui-next"; const meta = { component: UserAvatar, diff --git a/apps/ui/stories/Card.stories.tsx b/apps/ui/stories/Card.stories.tsx new file mode 100644 index 00000000..12f344ee --- /dev/null +++ b/apps/ui/stories/Card.stories.tsx @@ -0,0 +1,68 @@ +"use client"; + +import type { Meta, StoryObj } from "@storybook/react"; + +import { + Button, + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, + Input, + Label, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@kampus/ui-next"; + +const meta = { + title: "Card", + component: Card, +} satisfies Meta; + +export default meta; +type Story = StoryObj; +export const Default = { + render: () => { + return ( + + + Create project + Deploy your new project in one-click. + + + +
+
+ + +
+
+ + +
+
+ +
+ + + + +
+ ); + }, +} satisfies Story; diff --git a/apps/ui/stories/Form.stories.tsx b/apps/ui/stories/Form.stories.tsx new file mode 100644 index 00000000..646b8ade --- /dev/null +++ b/apps/ui/stories/Form.stories.tsx @@ -0,0 +1,115 @@ +"use client"; + +import type { Meta, StoryObj } from "@storybook/react"; + +import { + Button, + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, + Input, + Textarea, + useForm, + z, +} from "@kampus/ui-next"; + +// 1. create a form schema + +const formSchema = z.object({ + title: z.string().min(1, { message: "baslik en az 1 karakterli" }), + content: z.string().optional(), +}); + +const FormStory = () => { + // create a form state helper using `useForm` hook + const form = useForm(formSchema, { + defaultValues: { + title: "", + content: "", + }, + }); + + const onSubmit = (values: z.infer) => { + console.log({ values }); + }; + + return ( + + + Add new post + Share your links & thoughts with us + +
+ {/* eslint-disable-next-line @typescript-eslint/no-misused-promises */} + + + ( + + Title + + + + Write a descriptive title for your post. + + + )} + /> + + ( + + Content + +