@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 72 lines 3.71 KB
Raw
1 import { cva, type VariantProps } from "class-variance-authority";
2 import type * as React from "react";
3
4 import { cn } from "~/lib/utils";
5 import { Separator } from "./separator";
6
7 const groupVariants = cva(
8 "flex w-fit *:focus-visible:z-1 has-[>[data-slot=group]]:gap-2 *:has-focus-visible:z-1 dark:*:[[data-slot=button]:hover~[data-slot=separator]:not([data-slot]:hover~[data-slot=separator]~[data-slot=separator]),[data-slot][data-pressed]~[data-slot=separator]:not([data-slot][data-pressed]~[data-slot=separator]~[data-slot=separator])]:before:bg-input/64 dark:*:[[data-slot=separator]:has(~[data-slot=button]:hover):not(:has(~[data-slot=separator]~[data-slot]:hover)),[data-slot=separator]:has(~[data-slot][data-pressed]):not(:has(~[data-slot=separator]~[data-slot][data-pressed]))]:before:bg-input/64",
9 {
10 defaultVariants: {
11 orientation: "horizontal",
12 },
13 variants: {
14 orientation: {
15 horizontal:
16 "*:[[data-slot]~[data-slot]:not([data-slot=separator])]:before:-start-[0.5px] *:data-slot:not-data-[slot=separator]:has-[~[data-slot]]:before:-end-[0.5px] *:pointer-coarse:after:min-w-auto *:data-slot:has-[~[data-slot]]:rounded-e-none *:data-slot:has-[~[data-slot]]:border-e-0 *:data-slot:has-[~[data-slot]]:before:rounded-e-none *:[[data-slot]~[data-slot]]:rounded-s-none *:[[data-slot]~[data-slot]]:border-s-0 *:[[data-slot]~[data-slot]]:before:rounded-s-none",
17 vertical:
18 "*:[[data-slot]~[data-slot]:not([data-slot=separator])]:before:-top-[0.5px] *:data-slot:not-data-[slot=separator]:has-[~[data-slot]]:before:-bottom-[0.5px] flex-col *:pointer-coarse:after:min-h-auto *:data-slot:has-[~[data-slot]]:rounded-b-none *:data-slot:has-[~[data-slot]]:border-b-0 *:data-slot:not-data-[slot=separator]:has-[~[data-slot]]:before:hidden *:data-slot:has-[~[data-slot]]:before:rounded-b-none dark:*:last:before:hidden dark:*:first:before:block *:[[data-slot]~[data-slot]]:rounded-t-none *:[[data-slot]~[data-slot]]:border-t-0 *:[[data-slot]~[data-slot]]:before:rounded-t-none",
19 },
20 },
21 },
22 );
23
24 function Group({
25 className,
26 orientation,
27 children,
28 ...props
29 }: {
30 className?: string;
31 orientation?: VariantProps<typeof groupVariants>["orientation"];
32 children: React.ReactNode;
33 } & React.ComponentProps<"div">) {
34 return (
35 <div
36 className={cn(groupVariants({ orientation }), className)}
37 data-orientation={orientation}
38 data-slot="group"
39 role="group"
40 {...props}
41 >
42 {children}
43 </div>
44 );
45 }
46
47 function GroupSeparator({
48 className,
49 orientation = "vertical",
50 ...props
51 }: {
52 className?: string;
53 } & React.ComponentProps<typeof Separator>) {
54 return (
55 <Separator
56 className={cn(
57 "[[data-slot=input-control]:focus-within+&,[data-slot=input-group]:focus-within+&,[data-slot=select-trigger]:focus-visible+*+&,[data-slot=number-field]:focus-within+input+&]:-translate-x-px pointer-events-none relative z-2 bg-input before:absolute before:inset-0 has-[+[data-slot=input-control]:focus-within,+[data-slot=input-group]:focus-within,+[data-slot=select-trigger]:focus-visible+*,+[data-slot=number-field]:focus-within]:translate-x-px has-[+[data-slot=input-control]:focus-within,+[data-slot=input-group]:focus-within,+[data-slot=select-trigger]:focus-visible+*,+[data-slot=number-field]:focus-within]:bg-ring dark:before:bg-input/32 [[data-slot=input-control]:focus-within+&,[data-slot=input-group]:focus-within+&,[data-slot=select-trigger]:focus-visible+*+&,[data-slot=number-field]:focus-within+&,[data-slot=number-field]:focus-within+input+&]:bg-ring",
58 className,
59 )}
60 orientation={orientation}
61 {...props}
62 />
63 );
64 }
65
66 export {
67 Group,
68 Group as ButtonGroup,
69 GroupSeparator,
70 GroupSeparator as ButtonGroupSeparator,
71 groupVariants,
72 };