Files
NODEDC_DESIGN_GUIDELINE/packages/ui-react/src/Settings.tsx
T
Codex cb534dbe39 feat(ui): add docking, viewport controls and composed settings
Add shared dock layouts, navigation cube, range bands, progress actions and comparison surfaces. Extend toolbar menus and loading composition, and align tokens, registry entries, documentation and the living catalog.
2026-10-29 09:38:25 +03:00

51 lines
1.7 KiB
TypeScript

import type { HTMLAttributes, ReactNode } from "react";
import { Description } from "./Description.js";
import { cn } from "./cn.js";
export interface SettingsCardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
eyebrow?: ReactNode;
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
align?: "start" | "center";
}
export function SettingsCard({ eyebrow, title, description, actions, children, align = "start", className, ...props }: SettingsCardProps) {
return (
<section className={cn("nodedc-settings-card", className)} data-align={align === "center" ? "center" : undefined} {...props}>
<header className="nodedc-settings-card__head">
<div className="nodedc-settings-card__titles">
{eyebrow ? <span>{eyebrow}</span> : null}
<h2>{title}</h2>
{description ? <Description>{description}</Description> : null}
</div>
{actions ? <div className="nodedc-settings-card__actions">{actions}</div> : null}
</header>
{align === "center" && (children === undefined || children === null || children === false) ? null : <div className="nodedc-settings-card__body">{children}</div>}
</section>
);
}
export interface SwitchProps {
checked: boolean;
label: string;
disabled?: boolean;
onChange: (checked: boolean) => void;
}
export function Switch({ checked, label, disabled = false, onChange }: SwitchProps) {
return (
<button
type="button"
className="nodedc-switch"
role="switch"
aria-checked={checked}
disabled={disabled}
onClick={() => onChange(!checked)}
>
<span className="nodedc-switch__track" aria-hidden="true"><span /></span>
<span>{label}</span>
</button>
);
}