Files
ianitor/packages/domi-ui/src/components/Switch.svelte
T
mnovak c9aa55ec99 [web] Domi UI: the web UI on @domi/ui v1.0.4, vendored (CPAL-1.0), with the Built on Domi credit (PR #14, squashed)
@domi/ui v1.0.4 vendored unchanged in packages/domi-ui by domi-design's tools/vendor.mjs and used as workspace:*, so
the Nix build fetches nothing from Gitea (web.nix sources the folder; fetchPnpmDeps hash from the NixOS runner).
Its fonts, roles (data-domi-room="ianitor", the same hex) and controls replace Ianitor's copies: Button through
Ianitor's adapter (desktop sizes kept), every text field a TextField with its seal, Checkbox, Select, Segmented.
Ianitor's 22 role names renamed to --domi-*. <DomiCredit /> on every screen and in About, with the CPAL section 15
note beside the source link; the README names the vendored package. Disabled buttons are natively disabled.
2026-11-23 00:52:19 +01:00

24 lines
783 B
Svelte

<script lang="ts">
interface Props {
checked?: boolean;
/** Says what is on: "Sync over mobile data". The switch reads as on or off after it. */
label: string;
disabled?: boolean;
onchange?: (checked: boolean) => void;
force?: string;
class?: string;
}
let { checked = $bindable(false), label, disabled = false, onchange, force, class: cls = '' }: Props = $props();
function toggle() {
if (disabled) return;
checked = !checked;
onchange?.(checked);
}
</script>
<button type="button" role="switch" class={['domi-switch', cls]} aria-checked={checked} {disabled} data-force={force} onclick={toggle}>
<span class="domi-switch__track" aria-hidden="true"><span class="domi-switch__knob"></span></span>
<span>{label}</span>
</button>