All files / src/ahuora-design-system/ui tabs.tsx

91.66% Statements 33/36
57.14% Branches 12/21
50% Functions 3/6
100% Lines 22/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109          76x   76x                                                     76x                                                                   76x     5034x 839x   2139x   3356x   76x   76x     9252x 2313x   4755x   9252x   76x   76x     5883x 1961x   192x     2153x   7844x   76x      
import * as TabsPrimitive from "@radix-ui/react-tabs";
import { cva, VariantProps } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
 
const Tabs = TabsPrimitive.Root;
 
const tabsListVariants = cva(
  "inline-flex h-9 items-center justify-center  p-1 text-muted-foreground",
  {
    variants: {
      bg: {
        default: "bg-muted",
        blend: "bg-[var(--background)]",
      },
      type: {
        vFull: "flex-col h-full",
        vShort: "flex-col h-auto",
        hFull: "flex-row w-full",
        hShort: "flex-row",
      },
      rounded: {
        yes: "rounded-lg",
        no: "rounded-0",
      },
    },
    defaultVariants: {
      bg: "default",
      type: "hFull",
      rounded: "no",
    },
  },
);
 
const tabsTriggerVariants = cva(
  "inline-flex w-full items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all 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:
          "border-0 data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow",
        blend:
          "text-[#7F8EA3] data-[state=active]:bg-muted data-[state=active]:text-muted-foreground",
        underline:
          "border-0 data-[state=active]:border-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow data-[state=active]:border-b-4 data-[state=active]:border-b-primary",
        white:
          "border-0 data-[state=active]:bg-background data-[state=active]:text-zinc-900 data-[state=active]:shadow data-[state=active]:bg-white",
      },
      size: {
        default: "h-9 px-3",
        sm: "h-8 px-2",
        lg: "h-10 px-3",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  },
);
 
export interface TabsListProps
  extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>,
    VariantProps<typeof tabsListVariants> {}
 
export interface TabsTriggerProps
  extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>,
    VariantProps<typeof tabsTriggerVariants> {}
 
const TabsList = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.List>,
  TabsListProps
>(({ bg, type, rounded, className, ...props }, ref) => (
  <TabsPrimitive.List
    ref={ref}
    className={cn(tabsListVariants({ bg, type, rounded, className }))}
    {...props}
  />
));
TabsList.displayName = TabsPrimitive.List.displayName;
 
const TabsTrigger = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.Trigger>,
  TabsTriggerProps
>(({ variant, className, ...props }, ref) => (
  <TabsPrimitive.Trigger
    ref={ref}
    className={cn(tabsTriggerVariants({ variant, className }))}
    {...props}
  />
));
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
 
const TabsContent = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
  <TabsPrimitive.Content
    ref={ref}
    className={cn(
      "ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
      className,
    )}
    {...props}
  />
));
TabsContent.displayName = TabsPrimitive.Content.displayName;
 
export { Tabs, TabsContent, TabsList, TabsTrigger };