Files

118 lines
3.2 KiB
TypeScript
Raw Permalink Normal View History

import { cn } from '@/lib/utils';
2026-10-23 19:56:38 -07:00
import React from 'react';
export interface SettingsTabItem {
id: string;
label: string;
}
export function SettingsTabs({
items,
value,
onChange,
}: {
items: SettingsTabItem[];
value: string;
onChange: (value: string) => void;
}) {
return (
2026-11-16 23:10:44 +06:00
<div
className="flex w-full overflow-x-auto overflow-y-hidden border border-b-0 border-[var(--border)] bg-[var(--surface-2)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
2026-11-16 23:10:44 +06:00
role="tablist"
aria-label="Settings categories"
>
2026-10-23 19:56:38 -07:00
{items.map((item) => (
<button
key={item.id}
id={`settings-tab-${item.id}`}
type="button"
role="tab"
aria-selected={value === item.id}
aria-controls={`settings-panel-${item.id}`}
className={`shrink-0 border-b-2 border-r border-r-[var(--border)] px-3.5 py-2 text-[11.5px] transition-colors cursor-pointer whitespace-nowrap ${
2026-11-16 23:10:44 +06:00
value === item.id
? 'border-b-[var(--accent)] bg-[var(--surface)] text-[var(--text)] font-medium'
: 'border-b-transparent text-[var(--text-muted)] hover:bg-[var(--surface)] hover:text-[var(--text)]'
2026-11-16 23:10:44 +06:00
}`}
2026-10-23 19:56:38 -07:00
onClick={() => onChange(item.id)}
>
{item.label}
</button>
))}
</div>
);
}
export function SettingsPanel({
children,
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn(
'w-full border border-[var(--border)] bg-[var(--surface)]',
className
)}
{...props}
>
{children}
</div>
);
}
2026-10-23 19:56:38 -07:00
export function SettingsGroup({
title,
action,
2026-10-23 19:56:38 -07:00
children,
}: {
title: string;
action?: React.ReactNode;
2026-10-23 19:56:38 -07:00
children: React.ReactNode;
}) {
return (
<section className="border-b border-[var(--border)] p-3.5 last:border-b-0">
<div className="mb-2.5 flex flex-wrap items-center justify-between gap-2">
<h2 className="flex items-center gap-1.5 text-[9.5px] font-medium uppercase tracking-wider text-[var(--text-faint)]">
{title}
</h2>
{action && <div className="flex items-center gap-1">{action}</div>}
</div>
<div className="flex flex-col gap-1.5">{children}</div>
2026-10-23 19:56:38 -07:00
</section>
);
}
export function SettingsField({
label,
children,
}: {
label: string;
children: React.ReactNode;
}) {
return (
<div className="grid grid-cols-1 items-center gap-1.5 py-1 sm:grid-cols-[220px_minmax(0,520px)] sm:justify-start sm:gap-6">
<div className="min-w-0">
<div className="text-[11.5px] leading-snug text-[var(--text)]">{label}</div>
2026-10-23 19:56:38 -07:00
</div>
<div className="min-w-0 w-full">{children}</div>
2026-10-23 19:56:38 -07:00
</div>
);
}
export function SettingsFooter({
status,
children,
}: {
status?: React.ReactNode;
children: React.ReactNode;
}) {
return (
<footer className="flex w-full flex-wrap items-center justify-between gap-2 border-t border-[var(--border)] bg-[var(--surface-2)] px-3.5 py-2">
<div className="flex items-center gap-1.5 text-[11px] text-[var(--text-muted)]" role="status">
{status}
</div>
<div className="flex items-center gap-1.5">{children}</div>
</footer>
);
}