Scaffold CommiTea: yarn workspaces, Electron shell, core label schema, design system
- apps/desktop: electron-vite + React + Tailwind mapped onto design tokens (preflight off; tokens/base.css owns the reset); boots to a Reginald placeholder proving fonts/tokens/core wiring - packages/core: pure TS; gitea label schema (est/*, p/*, deadline/hard) with pessimistic conflict resolution + 15 unit tests - docs/design: full design handoff (tokens, 16 component contracts, interactive 14-screen prototype, Reginald voice rules) - docs/PLAN.md: product plan (purity rule, pm-state repo, deterministic scheduler + Monte Carlo, directive log) - Deliberate deviation from novelpad stack: no ElectricSQL/PGlite — local store is a rebuildable cache over gitea REST/webhooks (better-sqlite3 in main process, arriving in P1) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
50
docs/design/components/forms/Switch.js.txt
Normal file
50
docs/design/components/forms/Switch.js.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
|
||||
const CSS = `
|
||||
.ct-switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font: var(--text-body); color: var(--ink-1); }
|
||||
.ct-switch--disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.ct-switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
|
||||
.ct-switch__track {
|
||||
width: 34px; height: 20px; flex-shrink: 0;
|
||||
border-radius: var(--radius-round);
|
||||
background: var(--paper-3);
|
||||
border: 1px solid var(--line-2);
|
||||
position: relative;
|
||||
transition: background var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
|
||||
}
|
||||
.ct-switch__track::after {
|
||||
content: '';
|
||||
position: absolute; top: 2px; left: 2px;
|
||||
width: 14px; height: 14px; border-radius: 50%;
|
||||
background: var(--surface-card);
|
||||
box-shadow: var(--shadow-1);
|
||||
transition: transform var(--duration-base) var(--ease-out);
|
||||
}
|
||||
.ct-switch__input:checked + .ct-switch__track { background: var(--accent); border-color: var(--accent); }
|
||||
.ct-switch__input:checked + .ct-switch__track::after { transform: translateX(14px); }
|
||||
.ct-switch__input:focus-visible + .ct-switch__track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
||||
`;
|
||||
(function inject() {
|
||||
if (typeof document !== 'undefined' && !document.getElementById('ct-switch-css')) {
|
||||
const s = document.createElement('style'); s.id = 'ct-switch-css'; s.textContent = CSS;
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
})();
|
||||
|
||||
export function Switch({ label, checked, onChange, disabled = false, style, ...rest }) {
|
||||
return (
|
||||
<label className={`ct-switch${disabled ? ' ct-switch--disabled' : ''}`} style={style}>
|
||||
<input
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
className="ct-switch__input"
|
||||
checked={checked}
|
||||
onChange={onChange}
|
||||
disabled={disabled}
|
||||
{...rest}
|
||||
/>
|
||||
<span className="ct-switch__track"></span>
|
||||
{label ? <span>{label}</span> : null}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user