diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-07-01 15:05:45 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-07-01 15:05:45 +0200 |
| commit | e4683e38dbe83c138f798817786e85097ee00d94 (patch) | |
| tree | 428ae3842e29839bc7d092d81005cb830233e730 /apps/web/src/components | |
| parent | ac4ff63438089228f935014cac75504b3f7f3a5a (diff) | |
| download | opencut-e4683e38dbe83c138f798817786e85097ee00d94.tar.gz | |
style: make select component look similar to other components
Diffstat (limited to 'apps/web/src/components')
| -rw-r--r-- | apps/web/src/components/ui/select.tsx | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/apps/web/src/components/ui/select.tsx b/apps/web/src/components/ui/select.tsx index a0f5f7b2..b93413f8 100644 --- a/apps/web/src/components/ui/select.tsx +++ b/apps/web/src/components/ui/select.tsx @@ -3,6 +3,7 @@ import * as React from "react"; import { Select as SelectPrimitive } from "radix-ui"; import { Check, ChevronDown, ChevronUp } from "lucide-react"; +import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "../../lib/utils"; @@ -12,6 +13,21 @@ const SelectGroup = SelectPrimitive.Group; const SelectValue = SelectPrimitive.Value; +const selectItemVariants = cva( + "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none transition-opacity data-[disabled]:pointer-events-none data-[disabled]:opacity-50", + { + variants: { + variant: { + default: "focus:opacity-65 focus:text-accent-foreground", + destructive: "text-destructive focus:text-destructive/80", + }, + }, + defaultVariants: { + variant: "default", + }, + } +); + const SelectTrigger = React.forwardRef< React.ElementRef<typeof SelectPrimitive.Trigger>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> @@ -19,7 +35,7 @@ const SelectTrigger = React.forwardRef< <SelectPrimitive.Trigger ref={ref} className={cn( - "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", + "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:opacity-65 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className )} {...props} @@ -113,14 +129,13 @@ SelectLabel.displayName = SelectPrimitive.Label.displayName; const SelectItem = React.forwardRef< React.ElementRef<typeof SelectPrimitive.Item>, - React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> ->(({ className, children, ...props }, ref) => ( + React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & { + variant?: VariantProps<typeof selectItemVariants>["variant"]; + } +>(({ className, children, variant = "default", ...props }, ref) => ( <SelectPrimitive.Item ref={ref} - className={cn( - "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", - className - )} + className={cn(selectItemVariants({ variant }), className)} {...props} > <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center"> @@ -139,7 +154,7 @@ const SelectSeparator = React.forwardRef< >(({ className, ...props }, ref) => ( <SelectPrimitive.Separator ref={ref} - className={cn("-mx-1 my-1 h-px bg-muted", className)} + className={cn("-mx-1 my-1 h-px bg-foreground/10", className)} {...props} /> )); |
