22 lines
925 B
TypeScript
22 lines
925 B
TypeScript
import { t as i18nT } from "i18next";
|
|
import { Switch } from "~/ui/components/Switch";
|
|
|
|
// Subframe migration (strangler shim):
|
|
// Keeps the original single-toggle API (`value`/`onChange`/`disabled`) but renders the
|
|
// Subframe design-system `Switch`. A single boolean toggle maps to `Switch` (not
|
|
// `ToggleGroup`, which is for multi-option segmented controls).
|
|
//
|
|
// The legacy field was fully controlled (`value: boolean`, required `onChange`), so the shim
|
|
// stays controlled too — `checked={value}` + `onCheckedChange={onChange}`. No internal state
|
|
// is needed because the caller always owns the value.
|
|
interface Props {
|
|
value: boolean;
|
|
onChange(checked: boolean): void;
|
|
disabled?: boolean;
|
|
}
|
|
export default function Toggle({ value, onChange, disabled }: Props) {
|
|
return (
|
|
<Switch checked={value} disabled={disabled} onCheckedChange={onChange} aria-label={i18nT("components.toggle.useSetting")} />
|
|
);
|
|
}
|