Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ComposerControl.tsx

71 lines1.6 KB

1import type { ComponentProps } from "react";
2import { ChevronDownIcon, type LucideIcon } from "lucide-react";
3​
4import { cn } from "~/lib/utils";
5import { Button } from "../ui/button";
6import { SelectTrigger } from "../ui/select";
7​
8const composerControlClassName =
9 "h-7 min-h-7 gap-1.5 px-2.5 text-secondary-label transition-none hover:text-foreground [&_svg[data-composer-control-icon]]:mx-0 [&_svg[data-composer-control-chevron]]:-mx-0.5";
10​
11export function ComposerControl({
12 className,
13 size = "sm",
14 variant = "ghost",
15 ...props
16}: ComponentProps<typeof Button>) {
17 return (
18 <Button
19 className={cn(composerControlClassName, className)}
20 size={size}
21 variant={variant}
22 {...props}
23 />
24 );
26​
27export function ComposerControlIcon({
28 icon: Icon,
29 className,
30 opticalSize = "default",
31}: {
32 icon: LucideIcon;
33 className?: string | undefined;
34 opticalSize?: "default" | "large";
35}) {
36 return (
37 <Icon
38 aria-hidden="true"
39 className={cn("shrink-0", opticalSize === "large" ? "size-4.5" : "size-4", className)}
40 data-composer-control-icon
41 />
42 );
44​
45export function ComposerControlChevron() {
46 return (
47 <ChevronDownIcon
48 aria-hidden="true"
49 className="-mx-0.5 size-3.5 shrink-0 text-icon-muted"
50 data-composer-control-chevron
51 strokeWidth={2.25}
52 />
53 );
55​
56export function ComposerSelectControl({
57 className,
58 size = "sm",
59 variant = "ghost",
60 ...props
61}: ComponentProps<typeof SelectTrigger>) {
62 return (
63 <SelectTrigger
64 className={cn(composerControlClassName, className)}
65 icon={<ComposerControlChevron />}
66 size={size}
67 variant={variant}
68 {...props}
69 />
70 );