Skip to content

UI kit: Button component #2262

Open
Open

Description

@trillium

Trillium Firstmate 🤖

Overview

Create the shared Button that replaces the MUI Button (used in 20 files) and the raw <button> elements, with the same look as today.

Dependencies

Action Items

  • Create client/src/components/ui/button.tsx with cva variants that match today's buttons. Read how buttons look now: client/src/theme/index.js (MuiButton: Source Sans Pro, 18 px, weight 600, no uppercase) and the variant="secondary" style (3 px primary-color border), plus the contained, outlined, and text MUI variants used in the app (14 outlined, 9 contained, 1 text).
    • Variants: primary (contained), outline, secondary (3 px primary border), text, destructive (for delete actions currently using the error color).
    • Sizes: default, sm, icon (for the icon-only close/delete buttons).
    • Props: all native <button> props, asChild (use Radix Slot, so a button can render a React Router NavLink, which Navbar.jsx needs), and a loading state that shows the spinner once the spinner ticket exists (add it then; for now disabled).
  • Remember the old global rule button { width: 100%; height: 100% } in client/src/index.scss. The new Button must not inherit it (the important flag handles this; add a test or note proving it).
  • Add the Radix Slot package (@radix-ui/react-slot).
  • Add colocated button.test.tsx: renders text, each variant has its class, click fires, disabled does not fire, Enter/Space activate it, asChild renders a link element.
  • Add a catalogue entry (all variants and sizes, disabled, focus ring).

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.
  • A screenshot in the PR puts the new Button next to an MUI Button for each variant at the same size, showing they match.

Resources/Instructions

Additional Notes

  • If a visual variant is used only once, do not add a variant; the screen ticket can pass classes through className.
  • The loading prop is optional here to keep the PR small.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature: Design systemmilestone: missingp-feature: Buttonsrole: Front Endsize: 2pt

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions