Skip to content

UI kit: Input, Textarea, Label, and field message #2263

Open

Description

@trillium

Trillium Firstmate 🤖

Overview

Create the shared text-entry components that replace MUI TextField, InputLabel, FormLabel, TextareaAutosize and the raw <input>/<textarea>/<label> elements, with the same look as today.

Dependencies

Action Items

  • Create client/src/components/ui/label.tsx: a label in the form-label style (16 px, weight 600, as in the MUI theme MuiInputLabel).
  • Create client/src/components/ui/input.tsx: a text input with the app's outlined style (1 px black border, 14 px/500 text, grey placeholder #757575), an error state (error color border), and a disabled state. Forward the ref and all native props so react-hook-form's register() works on it unchanged.
  • Create client/src/components/ui/textarea.tsx with the same styling (replaces TextareaAutosize in manageProjects/editableField.jsx). Auto-grow can be done with a small useEffect or CSS field-sizing: content with a fallback.
  • Create client/src/components/ui/field.tsx: a wrapper that connects a Label, a control, helper text, and an error message with the right id, htmlFor, aria-describedby and aria-invalid. The old forms reserve one line of space for the message (helperText=' ') so layout does not jump; keep that behavior as an option.
  • Add an optional floating-label look to Input (the check-in form newUserForm.jsx uses MUI floating labels). Implement with the CSS peer pattern, not JavaScript.
  • Colocated tests: label click focuses the input; typing works; register()-style ref forwarding; error text is announced via aria-describedby; disabled blocks typing; textarea grows.
  • Add catalogue entries for Label, Input, Textarea, and Field (default, focus, error, disabled, floating label).

Acceptance Criteria

  • The component lives in client/src/components/ui/ as a .tsx file, with typed props that pass yarn typecheck (strict mode).
  • Styling uses Tailwind classes only. Variants (if any) are declared with cva, and className is merged with cn() so callers can override.
  • The component does not import anything from @mui/* or @emotion/*.
  • A test file next to the component (for example button.test.tsx) covers: it renders, each variant/size, the disabled and error states where they apply, and keyboard use where it applies (Tab, Enter/Space, Escape, arrow keys). yarn test passes.
  • The component has an entry on the /design-system page: description, props/variants, states, a short do/don't, a code example, and a live demo.
  • Visible focus: there is a clear focus ring when the control is reached by keyboard.
  • The PR does not change any existing screen. Screens adopt the component in their own tickets.

Resources/Instructions

Additional Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature: Design systemfeature: Form Validationmilestone: missingrole: Front Endsize: 3pt

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions