2026-11-17 00:24:33 +06:00
|
|
|
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
|
2026-11-17 00:24:33 +06:00
|
|
|
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}`}
|
2026-11-17 00:24:33 +06:00
|
|
|
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
|
2026-11-17 00:24:33 +06:00
|
|
|
? '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>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-17 00:24:33 +06:00
|
|
|
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,
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
title: string;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
2026-11-17 00:24:33 +06:00
|
|
|
<section className="border-b border-[var(--border)] p-3.5 last:border-b-0">
|
|
|
|
|
<h2 className="mb-2.5 flex items-center gap-1.5 text-[9.5px] font-medium uppercase tracking-wider text-[var(--text-faint)]">
|
2026-10-23 19:56:38 -07:00
|
|
|
{title}
|
|
|
|
|
</h2>
|
2026-11-17 00:24:33 +06:00
|
|
|
<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 (
|
2026-11-17 00:24:33 +06:00
|
|
|
<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">
|
2026-11-16 21:58:18 +06:00
|
|
|
<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>
|
2026-11-17 00:24:33 +06:00
|
|
|
<div className="min-w-0 w-full">{children}</div>
|
2026-10-23 19:56:38 -07:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-11-17 00:24:33 +06:00
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|