Files
maestro/design/components/forms/Input.jsx
T
wangjia 5a1e185b1a docs(design): 解压 Maestro Design System 到 design/(重构参照材料)
phosphor console v1.1 设计系统(从现网 web/style.css 演化):tokens(colors/effects/
typography/fonts) + components(core/forms/surfaces .jsx) + ui_kits(console + console_mobile)
+ assets/icons(15 双色 SVG) + guidelines + CLAUDE/SKILL/readme。供 B1–B6 重构任务对照实现。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 14:29:07 +08:00

29 lines
1.4 KiB
React

const css = `
.m-label{display:flex;flex-direction:column;gap:4px;font-family:var(--mono);font-size:11px;color:var(--muted);letter-spacing:.08em}
.m-input{font-family:var(--mono);font-size:13px;background:var(--bg-deep);color:var(--ink);border:1px solid var(--line);padding:7px 10px;outline:none;transition:border-color .12s;border-radius:var(--radius-sm,4px)}
.m-input:focus{border-color:var(--green-dim);box-shadow:0 0 0 1px var(--green-dim)}
.m-input::placeholder{color:var(--faint)}
.m-req{color:var(--red)}
`;
export function ensureFieldCss() {
if (typeof document === 'undefined' || document.getElementById('m-field-css')) return;
const s = document.createElement('style'); s.id = 'm-field-css'; s.textContent = css;
document.head.appendChild(s);
}
export function Input({ label, required, type = 'text', placeholder, value, defaultValue, onChange, width, style }) {
ensureFieldCss();
const ctrl = (
<input className="m-input" type={type} placeholder={placeholder} value={value}
defaultValue={defaultValue} style={{ width, ...style }} autoComplete="off"
onChange={onChange ? (e) => onChange(e.target.value) : undefined} readOnly={value !== undefined && !onChange} />
);
if (!label) return ctrl;
return (
<label className="m-label">
<span>{label}{required ? <span className="m-req"> *</span> : null}</span>
{ctrl}
</label>
);
}