Skip to content

Commit

Permalink
[UI v2] chore: Removes toggleVariants as an export
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Feb 7, 2025
1 parent 0794427 commit d200452
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
2 changes: 2 additions & 0 deletions ui-v2/src/components/ui/toggle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Toggle } from "./toggle";
export { toggleVariants } from "./styles";
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"use client";
import { cva } from "class-variance-authority";

import * as TogglePrimitive from "@radix-ui/react-toggle";
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";

import { cn } from "@/lib/utils";

const toggleVariants = cva(
export const toggleVariants = cva(
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
Expand All @@ -27,19 +21,3 @@ const toggleVariants = cva(
},
},
);

const Toggle = React.forwardRef<
React.ElementRef<typeof TogglePrimitive.Root>,
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
VariantProps<typeof toggleVariants>
>(({ className, variant, size, ...props }, ref) => (
<TogglePrimitive.Root
ref={ref}
className={cn(toggleVariants({ variant, size, className }))}
{...props}
/>
));

Toggle.displayName = TogglePrimitive.Root.displayName;

export { Toggle, toggleVariants };
24 changes: 24 additions & 0 deletions ui-v2/src/components/ui/toggle/toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client";

import * as TogglePrimitive from "@radix-ui/react-toggle";
import { type VariantProps } from "class-variance-authority";
import * as React from "react";

import { cn } from "@/lib/utils";
import { toggleVariants } from "./styles";

const Toggle = React.forwardRef<
React.ElementRef<typeof TogglePrimitive.Root>,
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
VariantProps<typeof toggleVariants>
>(({ className, variant, size, ...props }, ref) => (
<TogglePrimitive.Root
ref={ref}
className={cn(toggleVariants({ variant, size, className }))}
{...props}
/>
));

Toggle.displayName = TogglePrimitive.Root.displayName;

export { Toggle };

0 comments on commit d200452

Please # to comment.