swarm-ui: shared form-field kit (TextField, SelectField, Button)
Closes #3448. New ui/ primitives: FormField (shared label+control wrapper), TextField, SelectField, Button — each with a min-height touch target (2.75em ~= 44px, WCAG 2.5.5) per mara's #3447 ask, and a max-width instead of a fixed width so the control caps on desktop without overflowing a narrow/touch viewport. CreateAgentPage's name field + submit button now come from the kit instead of page-scoped CSS; ComponentsPage gets a section for each new primitive with an editable sample.
This commit is contained in:
parent
3643eccf22
commit
ba873926fa
9 changed files with 288 additions and 57 deletions
44
frontend/packages/swarm-ui/src/ui/text-field/TextField.tsx
Normal file
44
frontend/packages/swarm-ui/src/ui/text-field/TextField.tsx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// <TextField> — a labelled single-line text input, the shared control
|
||||
// every page-level form (`CreateAgentPage` today) reaches for instead
|
||||
// of hand-rolling its own label/input pair. No textarea/multi-line
|
||||
// mode — promote that the day a real caller needs one, same "don't
|
||||
// build ahead of a caller" rule the rest of `ui/` follows.
|
||||
import { FormField } from '../form-field/FormField.js';
|
||||
|
||||
export function TextField({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
onInput,
|
||||
type = 'text',
|
||||
pattern,
|
||||
title,
|
||||
required,
|
||||
placeholder,
|
||||
}: {
|
||||
id: string;
|
||||
label: string;
|
||||
value: string;
|
||||
onInput: (value: string) => void;
|
||||
type?: string;
|
||||
pattern?: string;
|
||||
title?: string;
|
||||
required?: boolean;
|
||||
placeholder?: string;
|
||||
}) {
|
||||
return (
|
||||
<FormField label={label} htmlFor={id}>
|
||||
<input
|
||||
id={id}
|
||||
class="ui-form-control"
|
||||
type={type}
|
||||
value={value}
|
||||
pattern={pattern}
|
||||
title={title}
|
||||
required={required}
|
||||
placeholder={placeholder}
|
||||
onInput={(e) => onInput((e.target as HTMLInputElement).value)}
|
||||
/>
|
||||
</FormField>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue