From ff5037cf5beeff5586a9c37744960c6481adcb44 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Thu, 13 Jul 2023 14:50:45 +0800 Subject: [PATCH] remove unused stuff --- packages/ui/src/components/shadcn/button.tsx | 48 ---- .../ui/src/components/shadcn/calendar.tsx | 57 ----- packages/ui/src/components/shadcn/command.tsx | 145 ----------- packages/ui/src/components/shadcn/dialog.tsx | 106 -------- packages/ui/src/components/shadcn/form.tsx | 170 ------------- packages/ui/src/components/shadcn/input.tsx | 24 -- packages/ui/src/components/shadcn/label.tsx | 19 -- packages/ui/src/components/shadcn/popover.tsx | 29 --- packages/ui/src/components/shadcn/select.tsx | 118 --------- packages/ui/src/components/shadcn/toast.tsx | 122 --------- .../updated/Accordion/Accordion.stories.tsx | 79 ------ .../shadcn/updated/Accordion/Accordion.tsx | 235 ------------------ .../shadcn/updated/Alert/Alert.stories.tsx | 92 ------- .../components/shadcn/updated/Alert/Alert.tsx | 145 ----------- .../shadcn/updated/Badge/Badge.stories.tsx | 155 ------------ .../components/shadcn/updated/Badge/Badge.tsx | 51 ---- .../shadcn/updated/Button/Button.stories.tsx | 175 ------------- .../shadcn/updated/Button/Button.tsx | 192 -------------- .../ui/src/components/shadcn/use-toast.tsx | 187 -------------- 19 files changed, 2149 deletions(-) delete mode 100644 packages/ui/src/components/shadcn/button.tsx delete mode 100644 packages/ui/src/components/shadcn/calendar.tsx delete mode 100644 packages/ui/src/components/shadcn/command.tsx delete mode 100644 packages/ui/src/components/shadcn/dialog.tsx delete mode 100644 packages/ui/src/components/shadcn/form.tsx delete mode 100644 packages/ui/src/components/shadcn/input.tsx delete mode 100644 packages/ui/src/components/shadcn/label.tsx delete mode 100644 packages/ui/src/components/shadcn/popover.tsx delete mode 100644 packages/ui/src/components/shadcn/select.tsx delete mode 100644 packages/ui/src/components/shadcn/toast.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Accordion/Accordion.stories.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Accordion/Accordion.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Alert/Alert.stories.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Alert/Alert.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Badge/Badge.stories.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Badge/Badge.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Button/Button.stories.tsx delete mode 100644 packages/ui/src/components/shadcn/updated/Button/Button.tsx delete mode 100644 packages/ui/src/components/shadcn/use-toast.tsx diff --git a/packages/ui/src/components/shadcn/button.tsx b/packages/ui/src/components/shadcn/button.tsx deleted file mode 100644 index f44e27e7212..00000000000 --- a/packages/ui/src/components/shadcn/button.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import * as React from 'react' -import { Slot } from '@radix-ui/react-slot' -import { VariantProps, cva } from 'class-variance-authority' - -import { cn } from '@ui/lib/utils' - -const buttonVariants = cva( - 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background', - { - variants: { - variant: { - default: 'bg-primary text-primary-foreground hover:bg-primary/90', - destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90', - outline: 'border border-input 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: 'underline-offset-4 hover:underline text-primary', - }, - size: { - default: 'h-10 py-2 px-4', - sm: 'h-9 px-3 rounded-md', - lg: 'h-11 px-8 rounded-md', - }, - }, - 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/packages/ui/src/components/shadcn/calendar.tsx b/packages/ui/src/components/shadcn/calendar.tsx deleted file mode 100644 index ef9bb2493fe..00000000000 --- a/packages/ui/src/components/shadcn/calendar.tsx +++ /dev/null @@ -1,57 +0,0 @@ -'use client' - -import * as React from 'react' -import { ChevronLeft, ChevronRight } from 'lucide-react' -import { DayPicker } from 'react-day-picker' - -import { cn } from '@ui/lib/utils' -import { buttonVariants } from '@ui/components/shadcn/button' - -export type CalendarProps = React.ComponentProps - -function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) { - return ( - , - IconRight: ({ ...props }) => , - }} - {...props} - /> - ) -} -Calendar.displayName = 'Calendar' - -export { Calendar } diff --git a/packages/ui/src/components/shadcn/command.tsx b/packages/ui/src/components/shadcn/command.tsx deleted file mode 100644 index 8c8940306ac..00000000000 --- a/packages/ui/src/components/shadcn/command.tsx +++ /dev/null @@ -1,145 +0,0 @@ -'use client' - -import * as React from 'react' -import { DialogProps } from '@radix-ui/react-dialog' -import { Command as CommandPrimitive } from 'cmdk-supabase' -import { Search } from 'lucide-react' - -import { cn } from '@ui/lib/utils' -import { Dialog, DialogContent } from '@ui/components/shadcn/dialog' - -const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -Command.displayName = CommandPrimitive.displayName - -interface CommandDialogProps extends DialogProps {} - -const CommandDialog = ({ children, ...props }: CommandDialogProps) => { - return ( - - - - {children} - - - - ) -} - -const CommandInput = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( -
- - -
-)) - -CommandInput.displayName = CommandPrimitive.Input.displayName - -const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) - -CommandList.displayName = CommandPrimitive.List.displayName - -const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->((props, ref) => ( - -)) - -CommandEmpty.displayName = CommandPrimitive.Empty.displayName - -const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) - -CommandGroup.displayName = CommandPrimitive.Group.displayName - -const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -CommandSeparator.displayName = CommandPrimitive.Separator.displayName - -const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) - -CommandItem.displayName = CommandPrimitive.Item.displayName - -const CommandShortcut = ({ className, ...props }: React.HTMLAttributes) => { - return ( - - ) -} -CommandShortcut.displayName = 'CommandShortcut' - -export { - Command, - CommandDialog, - CommandInput, - CommandList, - CommandEmpty, - CommandGroup, - CommandItem, - CommandShortcut, - CommandSeparator, -} diff --git a/packages/ui/src/components/shadcn/dialog.tsx b/packages/ui/src/components/shadcn/dialog.tsx deleted file mode 100644 index 5055e1bdddd..00000000000 --- a/packages/ui/src/components/shadcn/dialog.tsx +++ /dev/null @@ -1,106 +0,0 @@ -'use client' - -import * as React from 'react' -import * as DialogPrimitive from '@radix-ui/react-dialog' -import { X } from 'lucide-react' - -import { cn } from '@ui/lib/utils' - -const Dialog = DialogPrimitive.Root - -const DialogTrigger = DialogPrimitive.Trigger - -const DialogPortal = ({ className, children, ...props }: DialogPrimitive.DialogPortalProps) => ( - -
- {children} -
-
-) -DialogPortal.displayName = DialogPrimitive.Portal.displayName - -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, - DialogTrigger, - DialogContent, - DialogHeader, - DialogFooter, - DialogTitle, - DialogDescription, -} diff --git a/packages/ui/src/components/shadcn/form.tsx b/packages/ui/src/components/shadcn/form.tsx deleted file mode 100644 index 80674dfe20b..00000000000 --- a/packages/ui/src/components/shadcn/form.tsx +++ /dev/null @@ -1,170 +0,0 @@ -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 '@ui/lib/utils' -import { Label } from '@ui/components/shadcn/label' - -import { useId } from '@radix-ui/react-id' - -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>( - ({ className, ...props }, ref) => { - // const id = React.useId() - const id = useId() - console.log('id', id) - return ( - -
- - ) - } -) -FormItem.displayName = 'FormItem' - -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField() - - return ( -