Provider env vars table and reworked accent color picker (#3026)

Co-authored-by: ss <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-06-09 23:27:59 -07:00
1 parent 31533466b0
commit e2db800f7c
7 files changed
+612 -155

No files matched your search

+2 -1
View File
@@ -22,6 +22,7 @@
"hooks": "~/hooks"
},
"registries": {
"@coss": "https://coss.com/ui/r/{name}.json"
"@coss": "https://coss.com/ui/r/{name}.json",
"@spell": "https://spell.sh/r/{name}.json"
}
}
+101
View File
@@ -0,0 +1,101 @@
"use client";
import { useState } from "react";
import { cn } from "~/lib/utils";
interface ColorSelectorProps {
colors: string[];
size?: "default" | "sm" | "lg";
defaultValue: string;
name?: string;
onColorSelect?: (color: string) => void;
className?: string;
}
const colorMap = {
default: "var(--foreground)",
red: "var(--color-red-500)",
green: "var(--color-green-500)",
blue: "var(--color-blue-500)",
yellow: "var(--color-yellow-500)",
purple: "var(--color-purple-500)",
pink: "var(--color-pink-500)",
indigo: "var(--color-indigo-500)",
orange: "var(--color-orange-500)",
teal: "var(--color-teal-500)",
cyan: "var(--color-cyan-500)",
lime: "var(--color-lime-500)",
emerald: "var(--color-emerald-500)",
violet: "var(--color-violet-500)",
fuchsia: "var(--color-fuchsia-500)",
rose: "var(--color-rose-500)",
sky: "var(--color-sky-500)",
amber: "var(--color-amber-500)",
} as const;
function getSizeClass(size: "default" | "sm" | "lg") {
switch (size) {
case "sm":
return "size-4";
case "default":
return "size-5";
case "lg":
return "size-6";
default:
return "size-5";
}
}
function getColorValue(color: string): string {
return colorMap[color as keyof typeof colorMap] || color;
}
export function ColorSelector({
colors,
size = "default",
defaultValue,
name,
onColorSelect,
className,
}: ColorSelectorProps) {
const [selectedColor, setSelectedColor] = useState<string>(defaultValue);
const handleColorSelect = (color: string) => {
setSelectedColor(color);
onColorSelect?.(color);
};
const sizeClass = getSizeClass(size);
return (
<div className={cn("flex gap-2", className)}>
{name && <input type="hidden" name={name} value={selectedColor} />}
{colors.map((color) => {
const colorValue = getColorValue(color);
return (
<div
key={color}
className={`${sizeClass} cursor-pointer rounded-full transition-transform duration-200 active:scale-90`}
style={{
backgroundColor: colorValue,
...(selectedColor === color && {
boxShadow: `inset 0 0 0 2px var(--card), 0 0 0 2px ${colorValue}`,
}),
}}
onClick={() => handleColorSelect(color)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleColorSelect(color);
}
}}
tabIndex={0}
role="button"
aria-label={`Select ${color} color`}
aria-pressed={selectedColor === color}
/>
);
})}
</div>
);
}
@@ -0,0 +1,335 @@
"use client";
import { PipetteIcon, XIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState, type PointerEvent } from "react";
import { ColorSelector } from "../color-selector";
import { Button } from "../ui/button";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { normalizeProviderAccentColor } from "../../providerInstances";
import { cn } from "../../lib/utils";
const PROVIDER_ACCENT_SWATCHES = [
"#2563eb",
"#16a34a",
"#ea580c",
"#dc2626",
"#7c3aed",
"#0891b2",
] as const;
const FALLBACK_ACCENT_COLOR = PROVIDER_ACCENT_SWATCHES[0];
function clamp(value: number, min = 0, max = 1) {
return Math.min(max, Math.max(min, value));
}
function hexToHsv(hex: string) {
const normalized = normalizeProviderAccentColor(hex) ?? FALLBACK_ACCENT_COLOR;
const numeric = Number.parseInt(normalized.slice(1), 16);
const red = ((numeric >> 16) & 255) / 255;
const green = ((numeric >> 8) & 255) / 255;
const blue = (numeric & 255) / 255;
const max = Math.max(red, green, blue);
const min = Math.min(red, green, blue);
const delta = max - min;
let hue = 0;
if (delta !== 0) {
if (max === red) {
hue = ((green - blue) / delta) % 6;
} else if (max === green) {
hue = (blue - red) / delta + 2;
} else {
hue = (red - green) / delta + 4;
}
hue *= 60;
if (hue < 0) hue += 360;
}
return {
h: hue,
s: max === 0 ? 0 : delta / max,
v: max,
};
}
function hsvToHex(hue: number, saturation: number, value: number) {
const chroma = value * saturation;
const x = chroma * (1 - Math.abs(((hue / 60) % 2) - 1));
const match = value - chroma;
const [red, green, blue] =
hue < 60
? [chroma, x, 0]
: hue < 120
? [x, chroma, 0]
: hue < 180
? [0, chroma, x]
: hue < 240
? [0, x, chroma]
: hue < 300
? [x, 0, chroma]
: [chroma, 0, x];
return `#${[red, green, blue]
.map((channel) =>
Math.round((channel + match) * 255)
.toString(16)
.padStart(2, "0"),
)
.join("")}`;
}
function ProviderCustomColorPanel(props: {
readonly value: string;
readonly onCommit: (value: string) => void;
}) {
const { onCommit } = props;
const initialHsv = useMemo(() => hexToHsv(props.value), [props.value]);
const [hsv, setHsv] = useState(initialHsv);
const currentColor = hsvToHex(hsv.h, hsv.s, hsv.v);
const commitHsv = useCallback(
(nextHsv: typeof hsv) => {
setHsv(nextHsv);
onCommit(hsvToHex(nextHsv.h, nextHsv.s, nextHsv.v));
},
[onCommit],
);
const updateFromPlane = useCallback(
(event: PointerEvent<HTMLDivElement>) => {
const bounds = event.currentTarget.getBoundingClientRect();
const saturation = clamp((event.clientX - bounds.left) / bounds.width);
const value = 1 - clamp((event.clientY - bounds.top) / bounds.height);
commitHsv({ ...hsv, s: saturation, v: value });
},
[commitHsv, hsv],
);
const updateFromHue = useCallback(
(event: PointerEvent<HTMLDivElement>) => {
const bounds = event.currentTarget.getBoundingClientRect();
commitHsv({ ...hsv, h: clamp((event.clientX - bounds.left) / bounds.width) * 360 });
},
[commitHsv, hsv],
);
const handlePointerDown = (handler: (event: PointerEvent<HTMLDivElement>) => void) => {
return (event: PointerEvent<HTMLDivElement>) => {
event.currentTarget.setPointerCapture(event.pointerId);
handler(event);
};
};
return (
<div className="w-56 bg-popover">
<div
className="relative h-36 cursor-crosshair touch-none"
style={{
backgroundColor: `hsl(${hsv.h} 100% 50%)`,
backgroundImage:
"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",
}}
onPointerDown={handlePointerDown(updateFromPlane)}
onPointerMove={(event) => {
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
updateFromPlane(event);
}
}}
>
<span
className="pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.35)]"
style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%` }}
/>
</div>
<div className="grid gap-3 p-3">
<div
className="relative h-3 cursor-pointer touch-none rounded-full"
style={{
background: "linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)",
}}
onPointerDown={handlePointerDown(updateFromHue)}
onPointerMove={(event) => {
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
updateFromHue(event);
}
}}
>
<span
className="pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.35)]"
style={{ left: `${(hsv.h / 360) * 100}%`, backgroundColor: currentColor }}
/>
</div>
<input
value={currentColor}
onChange={(event) => {
const nextColor = event.currentTarget.value;
if (!/^#[\da-f]{6}$/i.test(nextColor)) return;
setHsv(hexToHsv(nextColor));
props.onCommit(nextColor);
}}
className="h-8 rounded-md border border-input bg-background px-2 font-mono text-xs text-foreground outline-none transition-colors focus:border-ring"
aria-label="Custom hex accent color"
spellCheck={false}
/>
</div>
</div>
);
}
function ProviderCustomColorPicker(props: {
readonly displayName: string;
readonly value: string | undefined;
readonly selected: boolean;
readonly onCommit: (value: string) => void;
}) {
const normalized = normalizeProviderAccentColor(props.value) ?? FALLBACK_ACCENT_COLOR;
return (
<Popover>
<PopoverTrigger
render={
<button
type="button"
className={cn(
"flex size-6 cursor-pointer items-center justify-center rounded-full text-white transition-transform duration-200 active:scale-90",
"hover:scale-105",
)}
style={{
backgroundColor: normalized,
...(props.selected
? {
boxShadow: `inset 0 0 0 2px var(--card), 0 0 0 2px ${normalized}`,
}
: {}),
}}
aria-label={`Choose custom accent color for ${props.displayName}`}
>
<PipetteIcon className="size-3 text-foreground/25" aria-hidden />
</button>
}
/>
<PopoverPopup
side="bottom"
align="start"
sideOffset={6}
className="overflow-hidden rounded-md p-0 [--viewport-inline-padding:0px] [&_[data-slot=popover-viewport]]:p-0"
>
<ProviderCustomColorPanel value={normalized} onCommit={props.onCommit} />
</PopoverPopup>
</Popover>
);
}
export function ProviderAccentColorPicker(props: {
readonly displayName: string;
readonly value: string | undefined;
readonly onCommit: (value: string) => void;
readonly description?: string;
readonly commitDelayMs?: number;
}) {
const { commitDelayMs = 0, description, displayName, onCommit, value } = props;
const [optimisticValue, setOptimisticValue] = useState(() => value ?? "");
const commitTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pendingCommitRef = useRef<string | null>(null);
const onCommitRef = useRef(onCommit);
useEffect(() => {
onCommitRef.current = onCommit;
}, [onCommit]);
useEffect(() => {
if (pendingCommitRef.current !== null) return;
setOptimisticValue(value ?? "");
}, [value]);
useEffect(() => {
return () => {
if (commitTimeoutRef.current !== null) {
clearTimeout(commitTimeoutRef.current);
}
const pendingCommit = pendingCommitRef.current;
if (pendingCommit !== null) {
onCommitRef.current(pendingCommit);
}
};
}, []);
const commitAccentColor = useCallback(
(value: string) => {
const normalizedValue = normalizeProviderAccentColor(value) ?? "";
setOptimisticValue(normalizedValue);
if (commitDelayMs <= 0) {
pendingCommitRef.current = null;
if (commitTimeoutRef.current !== null) {
clearTimeout(commitTimeoutRef.current);
commitTimeoutRef.current = null;
}
onCommit(normalizedValue);
return;
}
pendingCommitRef.current = normalizedValue;
if (commitTimeoutRef.current !== null) {
clearTimeout(commitTimeoutRef.current);
}
commitTimeoutRef.current = setTimeout(() => {
commitTimeoutRef.current = null;
const pendingCommit = pendingCommitRef.current;
pendingCommitRef.current = null;
if (pendingCommit !== null) {
onCommitRef.current(pendingCommit);
}
}, commitDelayMs);
},
[commitDelayMs, onCommit],
);
const normalized = normalizeProviderAccentColor(optimisticValue);
const selectedValue =
normalized &&
PROVIDER_ACCENT_SWATCHES.includes(normalized as (typeof PROVIDER_ACCENT_SWATCHES)[number])
? normalized
: "";
const customSelected = Boolean(normalized && selectedValue === "");
return (
<div className="grid gap-2">
<span className="text-xs font-medium text-foreground">Accent color</span>
<div className="flex min-w-0 flex-wrap items-center gap-2">
<ProviderCustomColorPicker
displayName={displayName}
value={normalized}
selected={customSelected}
onCommit={commitAccentColor}
/>
<ColorSelector
key={selectedValue}
colors={[...PROVIDER_ACCENT_SWATCHES]}
defaultValue={selectedValue}
size="lg"
onColorSelect={commitAccentColor}
className="flex-wrap gap-1.5"
/>
<Button
type="button"
size="icon"
variant="ghost"
className={cn(
"size-7 shrink-0 text-muted-foreground transition-opacity",
normalized ? "opacity-100" : "pointer-events-none opacity-0",
)}
onClick={() => commitAccentColor("")}
aria-label={`Clear accent color for ${displayName}`}
aria-hidden={!normalized}
tabIndex={normalized ? 0 : -1}
>
<XIcon className="size-3.5" aria-hidden />
</Button>
</div>
{description ? <span className="text-xs text-muted-foreground">{description}</span> : null}
</div>
);
}
@@ -28,17 +28,20 @@ import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
import { normalizeProviderAccentColor } from "../../providerInstances";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import { Checkbox } from "../ui/checkbox";
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
import { DraftInput } from "../ui/draft-input";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { ScrollArea } from "../ui/scroll-area";
import { Switch } from "../ui/switch";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table";
import { stackedThreadToast, toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import type { DriverOption } from "./providerDriverMeta";
import { ProviderSettingsForm } from "./ProviderSettingsForm";
import { ProviderModelsSection } from "./ProviderModelsSection";
import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon";
import { ProviderAccentColorPicker } from "./ProviderAccentColorPicker";
import { RedactedSensitiveText } from "./RedactedSensitiveText";
import {
getProviderVersionAdvisoryPresentation,
@@ -48,15 +51,6 @@ import {
type ProviderStatusKey,
} from "./providerStatus";
const PROVIDER_ACCENT_SWATCHES = [
"#2563eb",
"#16a34a",
"#ea580c",
"#dc2626",
"#7c3aed",
"#0891b2",
] as const;
const ENVIRONMENT_VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
let environmentVariableDraftId = 0;
@@ -159,94 +153,6 @@ function ProviderAuthEmail(props: {
);
}
function ProviderAccentColorPicker(props: {
readonly displayName: string;
readonly value: string | undefined;
readonly onCommit: (value: string) => void;
}) {
const [draft, setDraft] = useState(props.value ?? "");
const [isEditing, setIsEditing] = useState(false);
const draftColor = normalizeProviderAccentColor(draft);
useEffect(() => {
if (isEditing) return;
setDraft(props.value ?? "");
}, [isEditing, props.value]);
const commitDraft = () => {
setIsEditing(false);
props.onCommit(draftColor ?? "");
};
const commitSwatch = (swatch: string) => {
setIsEditing(false);
setDraft(swatch);
props.onCommit(swatch);
};
return (
<div className="grid gap-2">
<span className="text-xs font-medium text-foreground">Accent color</span>
<div className="flex min-w-0 flex-wrap items-center gap-2">
<input
type="color"
value={draftColor ?? PROVIDER_ACCENT_SWATCHES[0]}
onFocus={() => setIsEditing(true)}
onInput={(event) => {
setIsEditing(true);
setDraft(event.currentTarget.value);
}}
onChange={(event) => {
setIsEditing(true);
setDraft(event.currentTarget.value);
}}
onBlur={commitDraft}
aria-label={`Accent color for ${props.displayName}`}
className="h-8 w-10 cursor-pointer rounded border border-input bg-background p-0.5"
/>
<div className="flex flex-wrap gap-1.5">
{PROVIDER_ACCENT_SWATCHES.map((swatch) => {
const selected = draftColor?.toLowerCase() === swatch;
return (
<button
key={swatch}
type="button"
className={cn(
"size-6 cursor-pointer rounded-full border transition",
selected
? "border-foreground ring-2 ring-ring ring-offset-1 ring-offset-background"
: "border-black/10 hover:scale-105 dark:border-white/20",
)}
style={{ backgroundColor: swatch }}
onClick={() => commitSwatch(swatch)}
aria-label={`Use ${swatch} accent`}
/>
);
})}
</div>
{draftColor ? (
<Button
type="button"
size="sm"
variant="ghost"
className="h-7 px-2 text-xs text-muted-foreground"
onClick={() => {
setIsEditing(false);
setDraft("");
props.onCommit("");
}}
>
Clear
</Button>
) : null}
</div>
<span className="text-xs text-muted-foreground">
Used to distinguish this instance in picker rails and model lists.
</span>
</div>
);
}
function ProviderEnvironmentSection(props: {
readonly environment: ReadonlyArray<ProviderInstanceEnvironmentVariable>;
readonly onChange: (environment: ReadonlyArray<ProviderInstanceEnvironmentVariable>) => void;
@@ -330,59 +236,83 @@ function ProviderEnvironmentSection(props: {
Add variables to pass API keys, base URLs, or other per-instance CLI settings.
</p>
) : (
<div className="grid gap-2">
{rows.map((variable, index) => (
<div
key={variable.id}
className="grid gap-2 rounded-md border border-border/70 bg-muted/20 p-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto] sm:items-center"
>
<DraftInput
value={variable.name}
onCommit={(name) => updateVariable(variable.id, { name: name.trim() })}
placeholder="VARIABLE_NAME"
spellCheck={false}
aria-label={`Environment variable name ${index + 1}`}
/>
<DraftInput
value={variable.valueRedacted ? "" : variable.value}
onCommit={(value) => updateVariable(variable.id, { value })}
type={variable.sensitive ? "password" : undefined}
autoComplete="off"
placeholder={
variable.valueRedacted ? "Stored secret - enter a new value to replace" : "Value"
}
spellCheck={false}
aria-label={`Environment variable value ${index + 1}`}
/>
<label className="inline-flex h-8 items-center gap-2 text-xs text-muted-foreground">
<input
type="checkbox"
className="size-3.5"
checked={variable.sensitive}
onChange={(event) => {
const sensitive = event.currentTarget.checked;
updateVariable(variable.id, {
sensitive,
...(sensitive && variable.valueRedacted === undefined
? {}
: { valueRedacted: sensitive ? variable.valueRedacted : false }),
});
}}
/>
Sensitive
</label>
<Button
type="button"
size="icon-sm"
variant="ghost"
className="size-8 justify-self-start text-muted-foreground hover:text-destructive sm:justify-self-end"
onClick={() => removeVariable(variable.id)}
aria-label={`Remove environment variable ${variable.name || index + 1}`}
>
<XIcon className="size-3.5" />
</Button>
</div>
))}
<div className="overflow-hidden rounded-md border border-border/70">
<Table>
<TableHeader className="bg-muted/25 text-[11px] text-muted-foreground">
<TableRow className="hover:bg-transparent">
<TableHead>Variable</TableHead>
<TableHead>Value</TableHead>
<TableHead className="w-20">Sensitive</TableHead>
<TableHead className="w-12 text-right">
<span className="sr-only">Options</span>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((variable, index) => (
<TableRow
key={variable.id}
className="border-border/60 odd:bg-muted/20 even:bg-background/20"
>
<TableCell>
<DraftInput
value={variable.name}
onCommit={(name) => updateVariable(variable.id, { name: name.trim() })}
placeholder="VARIABLE_NAME"
spellCheck={false}
aria-label={`Environment variable name ${index + 1}`}
/>
</TableCell>
<TableCell>
<DraftInput
value={variable.valueRedacted ? "" : variable.value}
onCommit={(value) => updateVariable(variable.id, { value })}
type={variable.sensitive ? "password" : undefined}
autoComplete="off"
placeholder={
variable.valueRedacted
? "Stored secret - enter a new value to replace"
: "Value"
}
spellCheck={false}
aria-label={`Environment variable value ${index + 1}`}
/>
</TableCell>
<TableCell className="w-20">
<div className="flex h-8 items-center justify-center">
<Checkbox
checked={variable.sensitive}
onCheckedChange={(checked) => {
const sensitive = Boolean(checked);
updateVariable(variable.id, {
sensitive,
...(sensitive && variable.valueRedacted === undefined
? {}
: { valueRedacted: sensitive ? variable.valueRedacted : false }),
});
}}
aria-label={`Mark environment variable ${variable.name || index + 1} as sensitive`}
/>
</div>
</TableCell>
<TableCell className="w-12">
<div className="flex justify-end">
<Button
type="button"
size="icon-sm"
variant="ghost"
className="size-8 text-muted-foreground hover:text-destructive"
onClick={() => removeVariable(variable.id)}
aria-label={`Remove environment variable ${variable.name || index + 1}`}
>
<XIcon className="size-3.5" />
</Button>
</div>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
)}
<span className="text-xs text-muted-foreground">
@@ -582,16 +512,17 @@ export function ProviderInstanceCard({
accentColor={accentColor}
showBadge={Boolean(accentColor)}
statusDotClassName={statusStyle.dot}
indicatorBackground="var(--card)"
className="size-5"
iconClassName="size-4 text-foreground/80"
badgeClassName="right-[-0.125rem] bottom-[-0.125rem] h-3 min-w-3 text-[7px]"
badgeClassName="right-[-0.125rem] bottom-[-0.125rem] h-3 min-w-3 px-0.5 text-[7px]"
/>
) : FallbackIconComponent ? (
<span className="relative inline-flex size-5 shrink-0 items-center justify-center">
<FallbackIconComponent className="size-4 text-foreground/80" aria-hidden />
<span
className={cn(
"pointer-events-none absolute -left-0.5 -top-0.5 size-2 rounded-full ring-2 ring-background",
"pointer-events-none absolute -left-0.5 -top-0.5 size-2 rounded-full ring-2 ring-card",
statusStyle.dot,
)}
aria-hidden
@@ -825,6 +756,8 @@ export function ProviderInstanceCard({
displayName={displayName}
value={accentColor}
onCommit={updateAccentColor}
commitDelayMs={120}
description="Used to distinguish this instance in picker rails and model lists."
/>
</div>
@@ -38,7 +38,7 @@ export function SettingsSection({
</h2>
<div className="flex h-5 min-w-5 items-center justify-end">{headerAction}</div>
</div>
<div className="relative overflow-hidden rounded-2xl border bg-card text-card-foreground shadow-sm/4 not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:shadow-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]">
<div className="relative overflow-visible rounded-2xl border bg-card text-card-foreground shadow-sm/4 not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:shadow-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]">
{children}
</div>
</section>
+87
View File
@@ -0,0 +1,87 @@
import * as React from "react";
import { cn } from "~/lib/utils";
function Table({ className, ...props }: React.ComponentProps<"table">) {
return (
<div data-slot="table-container" className="relative w-full overflow-x-auto">
<table
data-slot="table"
className={cn("w-full caption-bottom text-xs", className)}
{...props}
/>
</div>
);
}
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
return <thead data-slot="table-header" className={cn("[&_tr]:border-b", className)} {...props} />;
}
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
return (
<tbody
data-slot="table-body"
className={cn("[&_tr:last-child]:border-0", className)}
{...props}
/>
);
}
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
return (
<tfoot
data-slot="table-footer"
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
{...props}
/>
);
}
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
return (
<tr
data-slot="table-row"
className={cn(
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
className,
)}
{...props}
/>
);
}
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
return (
<th
data-slot="table-head"
className={cn(
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
className,
)}
{...props}
/>
);
}
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
return (
<td
data-slot="table-cell"
className={cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className)}
{...props}
/>
);
}
function TableCaption({ className, ...props }: React.ComponentProps<"caption">) {
return (
<caption
data-slot="table-caption"
className={cn("mt-4 text-xs text-muted-foreground", className)}
{...props}
/>
);
}
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
+1 -1
View File
@@ -24,7 +24,7 @@ function RestoreDefaultsButton({ onRestored }: { onRestored: () => void }) {
disabled={changedSettingLabels.length === 0}
onClick={() => void restoreDefaults()}
>
<RotateCcwIcon className="size-3.5" />
<RotateCcwIcon className="mx-1 size-3.5" />
Restore defaults
</Button>
);