From 93b9cfd232b296c1378c1b27a8de6ce64fdc96c0 Mon Sep 17 00:00:00 2001 From: YasamanKahdooei Date: Sun, 7 Apr 2024 15:35:29 +0330 Subject: [PATCH] add a part of first page --- app/globals.css | 386 ++++++++++++----------- app/page.tsx | 2 +- components.json | 17 + components/SignIn/LoginForm.tsx | 138 +++++++++ components/{ => SignIn}/SignIn.tsx | 24 +- components/ui/alert-dialog.tsx | 146 +++++++++ components/ui/badge.tsx | 36 +++ components/ui/button.tsx | 56 ++++ components/ui/dialog.tsx | 122 ++++++++ components/ui/dropdown-menu.tsx | 205 ++++++++++++ components/ui/form.tsx | 176 +++++++++++ components/ui/input.tsx | 31 ++ components/ui/label.tsx | 26 ++ components/ui/radio-group.tsx | 44 +++ components/ui/select.tsx | 164 ++++++++++ components/ui/separator.tsx | 31 ++ components/ui/sonner.tsx | 31 ++ components/ui/table.tsx | 120 +++++++ components/ui/tabs.tsx | 55 ++++ components/ui/textarea.tsx | 26 ++ components/ui/toast.tsx | 127 ++++++++ components/ui/toaster.tsx | 35 +++ components/ui/use-toast.ts | 192 ++++++++++++ lib/utils.ts | 6 + package-lock.json | 481 +++++++++++++++++++++-------- package.json | 19 +- tailwind.config.ts | 84 ++++- 27 files changed, 2424 insertions(+), 356 deletions(-) create mode 100644 components.json create mode 100644 components/SignIn/LoginForm.tsx rename components/{ => SignIn}/SignIn.tsx (80%) create mode 100644 components/ui/alert-dialog.tsx create mode 100644 components/ui/badge.tsx create mode 100644 components/ui/button.tsx create mode 100644 components/ui/dialog.tsx create mode 100644 components/ui/dropdown-menu.tsx create mode 100644 components/ui/form.tsx create mode 100644 components/ui/input.tsx create mode 100644 components/ui/label.tsx create mode 100644 components/ui/radio-group.tsx create mode 100644 components/ui/select.tsx create mode 100644 components/ui/separator.tsx create mode 100644 components/ui/sonner.tsx create mode 100644 components/ui/table.tsx create mode 100644 components/ui/tabs.tsx create mode 100644 components/ui/textarea.tsx create mode 100644 components/ui/toast.tsx create mode 100644 components/ui/toaster.tsx create mode 100644 components/ui/use-toast.ts create mode 100644 lib/utils.ts diff --git a/app/globals.css b/app/globals.css index 8faa69c..c60d30b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,215 +1,213 @@ @tailwind base; -@tailwind components; -@tailwind utilities; + @tailwind components; + @tailwind utilities; + @layer base { + :root { + --background: 0 0% 100%; + --foreground: 222.2 84% 4.9%; + --card: 0 0% 100%; + --card-foreground: 222.2 84% 4.9%; -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 222.2 84% 4.9%; + --popover: 0 0% 100%; + --popover-foreground: 222.2 84% 4.9%; - --card: 0 0% 100%; - --card-foreground: 222.2 84% 4.9%; + --primary: 222.2 47.4% 11.2%; + --primary-foreground: 210 40% 98%; - --popover: 0 0% 100%; - --popover-foreground: 222.2 84% 4.9%; + --secondary: 210 40% 96.1%; + --secondary-foreground: 222.2 47.4% 11.2%; - --primary: 222.2 47.4% 11.2%; - --primary-foreground: 210 40% 98%; + --muted: 210 40% 96.1%; + --muted-foreground: 215.4 16.3% 46.9%; - --secondary: 210 40% 96.1%; - --secondary-foreground: 222.2 47.4% 11.2%; + --accent: 210 40% 96.1%; + --accent-foreground: 222.2 47.4% 11.2%; - --muted: 210 40% 96.1%; - --muted-foreground: 215.4 16.3% 46.9%; + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 210 40% 98%; - --accent: 210 40% 96.1%; - --accent-foreground: 222.2 47.4% 11.2%; + --border: 214.3 31.8% 91.4%; + --input: 214.3 31.8% 91.4%; + --ring: 222.2 84% 4.9%; - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 210 40% 98%; + --radius: 0.5rem; + } - --border: 214.3 31.8% 91.4%; - --input: 214.3 31.8% 91.4%; - --ring: 222.2 84% 4.9%; + .dark { + --background: 222.2 84% 4.9%; + --foreground: 210 40% 98%; - --radius: 0.5rem; + --card: 222.2 84% 4.9%; + --card-foreground: 210 40% 98%; + + --popover: 222.2 84% 4.9%; + --popover-foreground: 210 40% 98%; + + --primary: 210 40% 98%; + --primary-foreground: 222.2 47.4% 11.2%; + + --secondary: 217.2 32.6% 17.5%; + --secondary-foreground: 210 40% 98%; + + --muted: 217.2 32.6% 17.5%; + --muted-foreground: 215 20.2% 65.1%; + + --accent: 217.2 32.6% 17.5%; + --accent-foreground: 210 40% 98%; + + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 210 40% 98%; + + --border: 217.2 32.6% 17.5%; + --input: 217.2 32.6% 17.5%; + --ring: 212.7 26.8% 83.9%; + } } - .dark { - --background: 222.2 84% 4.9%; - --foreground: 210 40% 98%; - - --card: 222.2 84% 4.9%; - --card-foreground: 210 40% 98%; - - --popover: 222.2 84% 4.9%; - --popover-foreground: 210 40% 98%; - - --primary: 210 40% 98%; - --primary-foreground: 222.2 47.4% 11.2%; - - --secondary: 217.2 32.6% 17.5%; - --secondary-foreground: 210 40% 98%; - - --muted: 217.2 32.6% 17.5%; - --muted-foreground: 215 20.2% 65.1%; - - --accent: 217.2 32.6% 17.5%; - --accent-foreground: 210 40% 98%; - - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 40% 98%; - - --border: 217.2 32.6% 17.5%; - --input: 217.2 32.6% 17.5%; - --ring: 212.7 26.8% 83.9%; + @layer base { + * { + @apply border-border; + } + body { + @apply bg-background text-foreground; + } } -} -/* -@layer base { + * { - @apply border-border; + margin: 0; + padding: 0; + box-sizing: border-box; + direction: rtl; + font-family: "iranyekan"; + -webkit-tap-highlight-color: transparent; + --d-header-height: 70px; + --d-sideMenu-width-open: 200px; + --d-sideMenu-width-close: 70px; } - + body { - @apply bg-background text-foreground; + margin: 0; + padding: 0; + direction: rtl; + background-color: var(--main-bg); } -} */ - -* { - margin: 0; - padding: 0; - box-sizing: border-box; - direction: rtl; - font-family: "iranyekan"; - -webkit-tap-highlight-color: transparent; - --d-header-height: 70px; - --d-sideMenu-width-open: 200px; - --d-sideMenu-width-close: 70px; -} - -body { - margin: 0; - padding: 0; - direction: rtl; - background-color: var(--main-bg); -} -a { - text-decoration: none; -} - -ul { - list-style: none; -} - -button, -input { - font-family: iranyekan; -} - -@layer utilities { - .text-balance { - text-wrap: balance; + a { + text-decoration: none; } -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: bold; - src: url(../assets/fonts/eot/iranyekanwebboldfanum.eot); - src: url(../assets/fonts/eot/iranyekanwebboldfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebboldfanum.woff) format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanwebboldfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 100; - src: url(../assets/fonts/eot/iranyekanwebthinfanum.eot); - src: url(../assets/fonts/eot/iranyekanwebthinfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebthinfanum.woff) format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanwebthinfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 300; - src: url(../assets/fonts/eot/iranyekanweblightfanum.eot); - src: url(../assets/fonts/eot/iranyekanweblightfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanweblightfanum.woff) format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanweblightfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: normal; - src: url(/fonts/eot/iranyekanwebregularfanum.eot); - src: url(/fonts/eot/iranyekanwebregularfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(/fonts/woff/iranyekanwebregularfanum.woff) - format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(/fonts/ttf/iranyekanwebregularfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 500; - src: url(/fonts/eot/iranyekanwebmediumfanum.eot); - src: url(/fonts/eot/iranyekanwebmediumfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(/fonts/woff/iranyekanwebmediumfanum.woff) format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(/fonts/ttf/iranyekanwebmediumfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 800; - src: url(../assets/fonts/eot/iranyekanwebextraboldfanum.eot); - src: url(../assets/fonts/eot/iranyekanwebextraboldfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebextraboldfanum.woff) - format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanwebextraboldfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 850; - src: url(../assets/fonts/eot/iranyekanwebblackfanum.eot); - src: url(../assets/fonts/eot/iranyekanwebblackfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebblackfanum.woff) format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanwebblackfanum.ttf) format("truetype"); -} - -@font-face { - font-family: "iranyekan"; - font-style: normal; - font-weight: 900; - src: url(../assets/fonts/eot/iranyekanwebextrablackfanum.eot); - src: url(../assets/fonts/eot/iranyekanwebextrablackfanum.eot?#iefix) - format("embedded-opentype"), - /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebextrablackfanum.woff) - format("woff"), - /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url(../assets/fonts/ttf/iranyekanwebextrablackfanum.ttf) format("truetype"); -} + + ul { + list-style: none; + } + + button, + input { + font-family: iranyekan; + } + + @layer utilities { + .text-balance { + text-wrap: balance; + } + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: bold; + src: url(../assets/fonts/eot/iranyekanwebboldfanum.eot); + src: url(../assets/fonts/eot/iranyekanwebboldfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebboldfanum.woff) format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanwebboldfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 100; + src: url(../assets/fonts/eot/iranyekanwebthinfanum.eot); + src: url(../assets/fonts/eot/iranyekanwebthinfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebthinfanum.woff) format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanwebthinfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 300; + src: url(../assets/fonts/eot/iranyekanweblightfanum.eot); + src: url(../assets/fonts/eot/iranyekanweblightfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanweblightfanum.woff) format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanweblightfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: normal; + src: url(/fonts/eot/iranyekanwebregularfanum.eot); + src: url(/fonts/eot/iranyekanwebregularfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(/fonts/woff/iranyekanwebregularfanum.woff) + format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(/fonts/ttf/iranyekanwebregularfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 500; + src: url(/fonts/eot/iranyekanwebmediumfanum.eot); + src: url(/fonts/eot/iranyekanwebmediumfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(/fonts/woff/iranyekanwebmediumfanum.woff) format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(/fonts/ttf/iranyekanwebmediumfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 800; + src: url(../assets/fonts/eot/iranyekanwebextraboldfanum.eot); + src: url(../assets/fonts/eot/iranyekanwebextraboldfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebextraboldfanum.woff) + format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanwebextraboldfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 850; + src: url(../assets/fonts/eot/iranyekanwebblackfanum.eot); + src: url(../assets/fonts/eot/iranyekanwebblackfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebblackfanum.woff) format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanwebblackfanum.ttf) format("truetype"); + } + + @font-face { + font-family: "iranyekan"; + font-style: normal; + font-weight: 900; + src: url(../assets/fonts/eot/iranyekanwebextrablackfanum.eot); + src: url(../assets/fonts/eot/iranyekanwebextrablackfanum.eot?#iefix) + format("embedded-opentype"), + /* IE6-8 */ url(../assets/fonts/woff/iranyekanwebextrablackfanum.woff) + format("woff"), + /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url(../assets/fonts/ttf/iranyekanwebextrablackfanum.ttf) format("truetype"); + } + diff --git a/app/page.tsx b/app/page.tsx index 5c9e9f2..1d19412 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,4 @@ -import SignIn from "@/components/SignIn"; +import SignIn from "@/components/SignIn/SignIn"; import Image from "next/image"; export default function Home() { diff --git a/components.json b/components.json new file mode 100644 index 0000000..15f2b02 --- /dev/null +++ b/components.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "default", + "rsc": true, + "tsx": true, + "tailwind": { + "config": "tailwind.config.ts", + "css": "app/globals.css", + "baseColor": "slate", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils" + } +} \ No newline at end of file diff --git a/components/SignIn/LoginForm.tsx b/components/SignIn/LoginForm.tsx new file mode 100644 index 0000000..5220072 --- /dev/null +++ b/components/SignIn/LoginForm.tsx @@ -0,0 +1,138 @@ +"use client"; + +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; +import { Button } from "@/components/ui/button"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import Image from "next/image"; +import { RefreshCcw } from "lucide-react"; +import { Oval, ThreeDots } from "react-loader-spinner"; +import img1 from "@/assets/images/direct.png"; +import Link from "next/link"; + +const formSchema = z.object({ + username: z.string({ required_error: "*فیلد اجباری*" }).max(11, { + message: "حداکثر تعداد کاراکتر 11 تا میباشد.", + }), + + captcha: z + .string({ required_error: "*فیلد اجباری*" }) + .length(5, { message: "لطفا کد امنیتی را به طور کامل وارد نمایید." }), +}); + +function LoginForm() { + // 1. Define your form. + const form = useForm>({ + resolver: zodResolver(formSchema), + // defaultValues: { + // username: "", + // }, + }); + + // 2. Define a submit handler. + function onSubmit(values: z.infer) { + // Do something with the form values. + // ✅ This will be type-safe and validated. + console.log(values); + } + + return ( + <> +
+ + {/* Phone Number */} + ( + + تلفن همراه + + + + + + )} + /> + + {/* Capcha */} +
+ ( + + + + + + + )} + /> + + {/* {isLoading ? ( +
+ +
+ ) : ( */} +
+ icon + refetch()} + color="#fcc52d" + /> +
+ {/* )} */} +
+ + + + + + ورود با یزد من + + ); +} + +export default LoginForm; diff --git a/components/SignIn.tsx b/components/SignIn/SignIn.tsx similarity index 80% rename from components/SignIn.tsx rename to components/SignIn/SignIn.tsx index 7fc583b..956bc2c 100644 --- a/components/SignIn.tsx +++ b/components/SignIn/SignIn.tsx @@ -1,19 +1,23 @@ -import Image from "next/image"; import React from "react"; -import img1 from "../assets/images/auth_image_1.png"; -import img2 from "../assets/images/auth_image_6.png"; -import img3 from "../assets/images/auth_image_4.png"; -import pishgaman from "../assets/images/goroh-pishgaman-logo.png"; -import shetab from "../assets/images/shetab-logo.png"; -import ostandari from "../assets/images/ostandari2.png"; +import Image from "next/image"; +import img1 from "@/assets/images/auth_image_1.png"; +import img2 from "@/assets/images/auth_image_6.png"; +import img3 from "@/assets/images/auth_image_4.png"; +import pishgaman from "@/assets/images/goroh-pishgaman-logo.png"; +import shetab from "@/assets/images/shetab-logo.png"; +import ostandari from "@/assets/images/ostandari2.png"; +import LoginForm from "./LoginForm"; function SignIn() { return (
+ + {/* Right Section */}
- World +
+ {/* Left Section */}
, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName + +const AlertDialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + +)); +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName + +const AlertDialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogHeader.displayName = "AlertDialogHeader" + +const AlertDialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogFooter.displayName = "AlertDialogFooter" + +const AlertDialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName + +const AlertDialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogDescription.displayName = + AlertDialogPrimitive.Description.displayName + +const AlertDialogAction = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName + +const AlertDialogCancel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx new file mode 100644 index 0000000..f000e3e --- /dev/null +++ b/components/ui/badge.tsx @@ -0,0 +1,36 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/components/ui/button.tsx b/components/ui/button.tsx new file mode 100644 index 0000000..0e91656 --- /dev/null +++ b/components/ui/button.tsx @@ -0,0 +1,56 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const buttonVariants = cva( + "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground hover:bg-blue/90", + destructive: + "bg-destructive text-destructive-foreground hover:bg-destructive/90", + outline: + "border border-input bg-background hover:bg-accent hover:text-accent-foreground", + secondary: + "bg-secondary text-secondary-foreground hover:bg-secondary/80", + ghost: "hover:bg-accent hover:text-accent-foreground", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: "h-10 px-4 py-2", + sm: "h-9 rounded-md px-3", + lg: "h-11 rounded-md px-8", + icon: "h-10 w-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +export interface ButtonProps + extends React.ButtonHTMLAttributes, + VariantProps { + asChild?: boolean +} + +const Button = React.forwardRef( + ({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : "button" + return ( + + ) + } +) +Button.displayName = "Button" + +export { Button, buttonVariants } diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx new file mode 100644 index 0000000..4ea3a1d --- /dev/null +++ b/components/ui/dialog.tsx @@ -0,0 +1,122 @@ +"use client" + +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { X } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Dialog = DialogPrimitive.Root + +const DialogTrigger = DialogPrimitive.Trigger + +const DialogPortal = DialogPrimitive.Portal + +const DialogClose = DialogPrimitive.Close + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +DialogContent.displayName = DialogPrimitive.Content.displayName + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogHeader.displayName = "DialogHeader" + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogFooter.displayName = "DialogFooter" + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogTitle.displayName = DialogPrimitive.Title.displayName + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogDescription.displayName = DialogPrimitive.Description.displayName + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogClose, + DialogTrigger, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +} diff --git a/components/ui/dropdown-menu.tsx b/components/ui/dropdown-menu.tsx new file mode 100644 index 0000000..242b07a --- /dev/null +++ b/components/ui/dropdown-menu.tsx @@ -0,0 +1,205 @@ +"use client" + +import * as React from "react" +import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" +import { + CheckIcon, + ChevronRightIcon, + DotFilledIcon, +} from "@radix-ui/react-icons" + +import { cn } from "@/lib/utils" + +const DropdownMenu = DropdownMenuPrimitive.Root + +const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger + +const DropdownMenuGroup = DropdownMenuPrimitive.Group + +const DropdownMenuPortal = DropdownMenuPrimitive.Portal + +const DropdownMenuSub = DropdownMenuPrimitive.Sub + +const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup + +const DropdownMenuSubTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, children, ...props }, ref) => ( + + {children} + + +)) +DropdownMenuSubTrigger.displayName = + DropdownMenuPrimitive.SubTrigger.displayName + +const DropdownMenuSubContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DropdownMenuSubContent.displayName = + DropdownMenuPrimitive.SubContent.displayName + +const DropdownMenuContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, sideOffset = 4, ...props }, ref) => ( + + + +)) +DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName + +const DropdownMenuItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, ...props }, ref) => ( + +)) +DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName + +const DropdownMenuCheckboxItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, checked, ...props }, ref) => ( + + + + + + + {children} + +)) +DropdownMenuCheckboxItem.displayName = + DropdownMenuPrimitive.CheckboxItem.displayName + +const DropdownMenuRadioItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + + + + {children} + +)) +DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName + +const DropdownMenuLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, ...props }, ref) => ( + +)) +DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName + +const DropdownMenuSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName + +const DropdownMenuShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ) +} +DropdownMenuShortcut.displayName = "DropdownMenuShortcut" + +export { + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuGroup, + DropdownMenuPortal, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuRadioGroup, +} diff --git a/components/ui/form.tsx b/components/ui/form.tsx new file mode 100644 index 0000000..5c2e2db --- /dev/null +++ b/components/ui/form.tsx @@ -0,0 +1,176 @@ +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" +import { + Controller, + ControllerProps, + FieldPath, + FieldValues, + FormProvider, + useFormContext, +} from "react-hook-form" + +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" + +const Form = FormProvider + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +> = { + name: TName +} + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +>({ + ...props +}: ControllerProps) => { + return ( + + + + ) +} + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState, formState } = useFormContext() + + const fieldState = getFieldState(fieldContext.name, formState) + + if (!fieldContext) { + throw new Error("useFormField should be used within ") + } + + const { id } = itemContext + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + } +} + +type FormItemContextValue = { + id: string +} + +const FormItemContext = React.createContext( + {} as FormItemContextValue +) + +const FormItem = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => { + const id = React.useId() + + return ( + +
+ + ) +}) +FormItem.displayName = "FormItem" + +const FormLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => { + const { error, formItemId } = useFormField() + + return ( +