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
27
frontend/packages/swarm-ui/src/ui/form-field/FormField.tsx
Normal file
27
frontend/packages/swarm-ui/src/ui/form-field/FormField.tsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// <FormField> — label + control wrapper shared by every labelled form
|
||||
// control (`TextField`, `SelectField`, …). Not exported as a standalone
|
||||
// primitive callers reach for directly — it only exists so those two
|
||||
// don't each reinvent the label/spacing chrome; a bare labelled `<div>`
|
||||
// wrapper has no independent identity worth a `/components` entry of
|
||||
// its own.
|
||||
import type { ComponentChildren } from 'preact';
|
||||
import './FormField.css';
|
||||
|
||||
export function FormField({
|
||||
label,
|
||||
htmlFor,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
htmlFor: string;
|
||||
children: ComponentChildren;
|
||||
}) {
|
||||
return (
|
||||
<div class="ui-form-field">
|
||||
<label class="ui-form-field-label" for={htmlFor}>
|
||||
{label}
|
||||
</label>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue