40760aa884
- server:Go 网关(WS 流式识别中继/计费配额/微信登录支付 mock/反馈/埋点),gummy provider 已真实联调 - desktop:Tauri 2(全局快捷键 push-to-talk/浮层/托盘/设置/登录购买/反馈/首启引导) - android:Compose 主 App + IME(键盘内录音直传) - ios:App + 键盘扩展(1A spike 实证键盘内不可录音,走 deep link 听写) - design/design-pipeline:设计系统 + token 导出 iOS/Android 主题 - doc:前后端设计文档(HTML);web:官网宣传页;todo:任务看板 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1.3 KiB
React
34 lines
1.3 KiB
React
const ddSwitchCss = `
|
|
.dd-switch {
|
|
position: relative; display: inline-block; width: 40px; height: 24px;
|
|
border-radius: var(--radius-full); background: var(--surface-3);
|
|
border: none; cursor: pointer; padding: 0; flex: none;
|
|
transition: background var(--dur-base) var(--ease-out);
|
|
}
|
|
.dd-switch::after {
|
|
content: ''; position: absolute; top: 3px; left: 3px;
|
|
width: 18px; height: 18px; border-radius: 50%;
|
|
background: #fff; box-shadow: 0 1px 3px rgba(17,19,26,0.25);
|
|
transition: transform var(--dur-base) var(--ease-out);
|
|
}
|
|
.dd-switch[aria-checked="true"] { background: var(--accent); }
|
|
.dd-switch[aria-checked="true"]::after { transform: translateX(16px); }
|
|
.dd-switch:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
.dd-switch[disabled] { opacity: 0.45; pointer-events: none; }
|
|
`;
|
|
|
|
if (typeof document !== 'undefined' && !document.getElementById('dd-switch-css')) {
|
|
const s = document.createElement('style');
|
|
s.id = 'dd-switch-css';
|
|
s.textContent = ddSwitchCss;
|
|
document.head.appendChild(s);
|
|
}
|
|
|
|
export function Switch({ checked = false, onChange, disabled = false, ...rest }) {
|
|
return (
|
|
<button type="button" role="switch" className="dd-switch"
|
|
aria-checked={checked ? 'true' : 'false'} disabled={disabled}
|
|
onClick={() => onChange && onChange(!checked)} {...rest}></button>
|
|
);
|
|
}
|