"use client";
import type { ReactNode } from "react";
export function Panel({
title,
hint,
aside,
children,
className = "",
}: {
title: string;
hint?: string;
aside?: ReactNode;
children: ReactNode;
className?: string;
}) {
return (
{title}
{hint ?
{hint}
: null}
{aside}
{children}
);
}
export function Field({
label,
helper,
error,
htmlFor,
children,
}: {
label: string;
helper?: string;
error?: string | null;
htmlFor?: string;
children: ReactNode;
}) {
return (
{children}
{helper ?
{helper}
: null}
{error ?
{error}
: null}
);
}
const BUTTON_BASE =
"inline-flex items-center justify-center gap-2 rounded-console text-[13px] font-medium transition-colors duration-150 active:translate-y-px disabled:pointer-events-none disabled:opacity-40";
export function Button({
variant = "ghost",
size = "md",
className = "",
...props
}: React.ButtonHTMLAttributes & {
variant?: "primary" | "ghost" | "quiet";
size?: "sm" | "md";
}) {
const variants = {
primary: "bg-citron text-void hover:bg-[#d4f066]",
ghost: "border border-line-strong text-ink hover:border-ink-faint hover:bg-raised",
quiet: "text-ink-dim hover:text-ink hover:bg-raised",
} as const;
const sizes = { sm: "h-8 px-3", md: "h-10 px-4" } as const;
return (
);
}
export function Chip({
active = false,
className = "",
...props
}: React.ButtonHTMLAttributes & { active?: boolean }) {
return (
);
}
export function SegmentedControl({
value,
options,
onChange,
name,
}: {
value: T;
options: { value: T; label: string; hint?: string }[];
onChange: (value: T) => void;
name: string;
}) {
return (
{options.map((option) => {
const active = option.value === value;
return (
);
})}
);
}
export function Switch({
checked,
onChange,
label,
disabled = false,
}: {
checked: boolean;
onChange: (checked: boolean) => void;
label: string;
disabled?: boolean;
}) {
return (
);
}
export function NumberInput({
id,
value,
onChange,
min,
max,
step = 1,
suffix,
}: {
id: string;
value: number;
onChange: (value: number) => void;
min: number;
max: number;
step?: number;
suffix?: string;
}) {
return (
onChange(Number(event.target.value))}
className="h-9 w-full rounded-console border border-line-strong bg-void px-2.5 font-mono text-[13px] text-ink"
/>
{suffix ? {suffix} : null}
);
}
export function Slider({
id,
label,
value,
display,
min,
max,
step,
onChange,
}: {
id: string;
label: string;
value: number;
display?: string;
min: number;
max: number;
step: number;
onChange: (value: number) => void;
}) {
return (
);
}