diff --git a/app/docs/components/toggle-group/page.tsx b/app/docs/components/toggle-group/page.tsx new file mode 100644 index 00000000..2d152e41 --- /dev/null +++ b/app/docs/components/toggle-group/page.tsx @@ -0,0 +1,229 @@ +import { Metadata } from "next" +import { Separator } from "@radix-ui/react-select" +import { Bold, Italic, Underline } from "lucide-react" + +import { toggleGroupMetaData } from "@/lib/metadata" +import { ToggleGroup, ToggleGroupItem } from "@/components/ui/8bit/toggle-group" + +import CodeSnippet from "../code-snippet" +import CopyCommandButton from "../copy-command-button" +import InstallationCommands from "../installation-commands" +import { OpenInV0Button } from "../open-in-v0-button" + +export const metadata: Metadata = { + title: "8bit Toggle Group", + description: "Displays Toggle Group Component.", + openGraph: { images: toggleGroupMetaData }, +} +export default function ToggleGroupPage() { + return ( +
+
+

Toggle Group

+ +
+

+ A set of two-state buttons that can be toggled on or off. +

+
+
+

+ A simple 8-bit Toggle Group component +

+
+ +
+
+
+ + + + + + + + + + + +
+
+

Installation

+ +

Examples

+

Default

+
+
+

+ Default example +

+
+ +
+
+
+ + + + + + + + + + + +
+
+ {` + + + + + + + + + +`} +

Outline

+
+
+

+ Outline example +

+
+ +
+
+
+ + + + + + + + + + + +
+ {` + + + + + + + + + +`} +

Single

+
+
+

+ Single example +

+
+ +
+
+
+ + + + + + + + + + + +
+
+ {` + + + + + + + + + +`} +

Disabled

+
+
+

+ Disabled example +

+
+ +
+
+
+ + + + + + + + + + + +
+
+ {` + + + + + + + + + +`} +
+
+ ) +} diff --git a/components/ui/8bit/toggle-group.tsx b/components/ui/8bit/toggle-group.tsx new file mode 100644 index 00000000..0dc03a3e --- /dev/null +++ b/components/ui/8bit/toggle-group.tsx @@ -0,0 +1,88 @@ +import { Press_Start_2P } from "next/font/google" +import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +import { + ToggleGroup as ShadcnToggleGroup, + ToggleGroupItem as ShadcnToggleGroupItem, +} from "../toggle-group" + +const pressStart = Press_Start_2P({ weight: ["400"], subsets: ["latin"] }) + +export const toggleGroupVariants = cva("", { + variants: { + font: { normal: "", retro: pressStart.className }, + variant: { + default: "bg-transparent", + outline: + "bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground", + }, + size: { + default: "h-9 px-2 min-w-9", + sm: "h-4 px-1.5 min-w-4", + lg: "h-10 px-2.5 min-w-10", + }, + }, + defaultVariants: { variant: "default", font: "retro", size: "default" }, +}) + +export type BitToggleGroupProps = React.ComponentPropsWithoutRef< + typeof ToggleGroupPrimitive.Root +> & + VariantProps + +export type BitToggleGroupItemProps = React.ComponentPropsWithoutRef< + typeof ToggleGroupPrimitive.Item +> & + VariantProps + +function ToggleGroup({ ...props }: BitToggleGroupProps) { + const { className, font, children } = props + + return ( + + {" "} + {children}{" "} + + ) +} +function ToggleGroupItem({ ...props }: BitToggleGroupItemProps) { + const { className, font, children, variant } = props + return ( + + {" "} + {children}{" "} + {variant === "outline" && ( + <> + {" "} +