- app.css: HEL-649 §一 tokens (bg/line/accent/status/text/type/space/radius/shadow/motion), legacy names aliased, reduced-motion via prefers-reduced-motion and data-reduce - shared .a-btn/.status-chip/.a-panel/inputs reskinned; new .a-tag/.a-progress/.a-sprocket/.a-stage/.a-float - tailwind colors/radii reference the same CSS variables - ui primitives (StatusChip/ProgressBar/Modal/Button/ConfirmDialog/Skeleton/Switch/Card/Toast) on tokens - running state -> --run, awaiting confirm -> --warn, --cloud purple removed, old palette literals -> tokens Co-authored-by: multica-agent <github@multica.ai>
66 lines
1.3 KiB
Svelte
66 lines
1.3 KiB
Svelte
<script lang="ts">
|
||
interface Props {
|
||
checked: boolean;
|
||
label: string;
|
||
disabled?: boolean;
|
||
onchange?: (next: boolean) => void;
|
||
}
|
||
|
||
let { checked, label, disabled = false, onchange }: Props = $props();
|
||
</script>
|
||
|
||
<!-- §3.10 开关: 34×19 capsule; on = --accent-lo track + ink knob, off = --bg-4. -->
|
||
<button
|
||
type="button"
|
||
class="switch"
|
||
class:on={checked}
|
||
role="switch"
|
||
aria-checked={checked}
|
||
aria-label={label}
|
||
{disabled}
|
||
onclick={() => onchange?.(!checked)}
|
||
>
|
||
<span class="knob"></span>
|
||
</button>
|
||
|
||
<style>
|
||
.switch {
|
||
flex-shrink: 0;
|
||
width: 34px;
|
||
height: 19px;
|
||
border-radius: var(--r-pill);
|
||
border: 1px solid var(--line-2);
|
||
background: var(--bg-4);
|
||
position: relative;
|
||
cursor: pointer;
|
||
padding: 0;
|
||
transition:
|
||
background-color var(--d-state) ease,
|
||
border-color var(--d-state) ease;
|
||
}
|
||
.switch:disabled {
|
||
opacity: 0.45;
|
||
cursor: not-allowed;
|
||
}
|
||
.knob {
|
||
position: absolute;
|
||
top: 1px;
|
||
left: 1px;
|
||
width: 15px;
|
||
height: 15px;
|
||
border-radius: var(--r-pill);
|
||
background: var(--text-3);
|
||
transition:
|
||
transform var(--d-state) var(--ease-out),
|
||
background-color var(--d-state) ease;
|
||
}
|
||
.switch.on {
|
||
background: var(--accent-lo);
|
||
border-color: var(--accent-lo);
|
||
}
|
||
.switch.on .knob {
|
||
transform: translateX(15px);
|
||
background: var(--accent-ink);
|
||
}
|
||
</style>
|