|
| 1 | +import * as React from "react"; |
| 2 | +import * as TabsPrimitive from "@radix-ui/react-tabs"; |
| 3 | +import { cn } from "../../utilities"; |
| 4 | + |
| 5 | +const Tabs = TabsPrimitive.Root; |
| 6 | + |
| 7 | +const TabsList = React.forwardRef< |
| 8 | + React.ElementRef<typeof TabsPrimitive.List>, |
| 9 | + React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> |
| 10 | +>(({ className, ...props }, ref) => ( |
| 11 | + <TabsPrimitive.List |
| 12 | + ref={ref} |
| 13 | + className={cn("flex shrink-0 flex-wrap justify-start border-b text-text-sm", className)} |
| 14 | + {...props} |
| 15 | + /> |
| 16 | +)); |
| 17 | +TabsList.displayName = TabsPrimitive.List.displayName; |
| 18 | + |
| 19 | +const TabsTrigger = React.forwardRef< |
| 20 | + React.ElementRef<typeof TabsPrimitive.Trigger>, |
| 21 | + React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> |
| 22 | +>(({ className, ...props }, ref) => ( |
| 23 | + <TabsPrimitive.Trigger |
| 24 | + ref={ref} |
| 25 | + className={cn( |
| 26 | + "group/trigger px-3 py-2 data-[state=active]:text-theme-text-brand data-[state=active]:shadow-inner data-[state=active]:shadow-primary-400 hover:data-[state=inactive]:shadow-inner hover:data-[state=inactive]:shadow-neutral-200", |
| 27 | + className |
| 28 | + )} |
| 29 | + {...props} |
| 30 | + /> |
| 31 | +)); |
| 32 | +TabsTrigger.displayName = TabsPrimitive.Trigger.displayName; |
| 33 | + |
| 34 | +const TabsContent = React.forwardRef< |
| 35 | + React.ElementRef<typeof TabsPrimitive.Content>, |
| 36 | + React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> |
| 37 | +>(({ className, ...props }, ref) => ( |
| 38 | + <TabsPrimitive.Content |
| 39 | + ref={ref} |
| 40 | + className={cn( |
| 41 | + "mt-5 grow rounded-md border border-theme-border-moderate bg-white p-7 outline-none", |
| 42 | + className |
| 43 | + )} |
| 44 | + {...props} |
| 45 | + /> |
| 46 | +)); |
| 47 | +TabsContent.displayName = TabsPrimitive.Content.displayName; |
| 48 | + |
| 49 | +export { Tabs, TabsList, TabsTrigger, TabsContent }; |
0 commit comments