metabase-ui-component-from-figma
Metabase UI component from Figma
End-to-end workflow for bringing a metabase/ui (Mantine) component in line with a Figma design, driven by a Linear ticket.
The golden rule (existing components): build the Storybook showcase before changing any component styles. Build it while the old styles are still in place — so the team can see the current component at a glance and get accustomed to it before the migration, then watch it light up as you restyle. You end up with a visual-regression (Loki) candidate either way. A new component has nothing to render until it's built, so this rule doesn't apply to create mode — there the order flips: implement and style the component first, then build its showcase to present the result.
This is a frontend task — also load typescript-write (and typescript-review before handing off).
Two modes
The ticket is one of two shapes; identify which up front, because Phase 2 differs:
- Update an existing component — the component already exists with call sites, either in
metabase/ui*or* as a legacy component elsewhere (e.g.frontend/src/metabase/common/components/, possibly Emotion styled-components) that this ticket also migrates intometabase/ui. The risk is *regression* (call sites, behavior), so you map usage and lock behavior with tests before touching it. - Create a new component — nothing equivalent exists anywhere yet. Rarer. The risk is *API design*, so you scaffold the component and its public surface first.
Phases 1, 2, 5 and 6 are shared. The middle two differ in order: update mode builds the showcase (Phase 3) *before* styling (Phase 4); create mode does the reverse — implement and style first, then build the showcase as the last step — because there's nothing to render until the component exists.
Phase 1 — Check out the issue
- Fetch the Linear issue with the Linear MCP
get_issue. - Pull from it:
- Figma link(s) — extract the
node-id(?node-id=250-13588→250-13588) andfileKey(the/design/<fileKey>/…segment). gitBranchName— switch to it if not already there.- The component's intended API — variants, sizes, and states the design system supports for this component. This defines the axes of your showcase (Phase 3).
- Decide the mode (see Two modes above): search for an existing component — in
metabase/uior as a legacy component elsewhere. Found → update; nothing equivalent anywhere → create. Confirm with the user when unsure. - Verify a Figma desktop MCP is connected before doing the work — this skill depends on it for exact tokens in Phase 4 (and styling can't proceed accurately without it). Do a quick read against the issue's node (e.g.
get_metadata/get_variable_defs); if it errors with "nothing selected" or the server isn't connected, prompt the user to enable it (Switch to Dev Mode → MCP section in the right sidebar) and select the relevant layer before continuing.
Phase 2 — Understand the component
Mode: update an existing component
- Locate the component dir (typically containing
Component.config.tsorComponent.tsx,Component.module.css,Component.stories.tsx,index.ts). A ticket may also be migrating a legacy component — if it still uses Emotion styled-components, reach for the emotion-migrate skill. - Map every usage across
frontend/srcande2e(JSX<Component, sub-components likeComponent.Group, and wrapper components). - Write findings to
local/<TICKET>-<component>-usage-findings.md, one entry per usage: code location (file:line), short context, and non-standard usage (excessive customization, inline styling, invalid/legacy props). Invalid props are a signal that call sites will need migrating in Phase 6. This doc stays — the user walks it at the end to verify each real usage still looks right. - State the blast radius plainly: how many call sites, where, and whether they're confined.
- Lock behavior with tests before changing anything — when warranted. Only for components that have custom interactive behavior (their own event handlers, state, keyboard logic, controlled/uncontrolled wiring). Add unit tests covering that current API/behavior so a regression shows up as a failing test. Skip tests for thin Mantine wrappers — don't test built-in Mantine behavior, and a pure visual restyle is covered by the showcase/Loki, not unit tests.
Mode: create a new component
- Decide whether it wraps a Mantine primitive (most common — extend it via a
.config.tsusing<Mantine>.extend({...})and theme registration) or is bespoke. Prefer wrapping Mantine. - Scaffold the component dir + its public surface:
Component.tsx/Component.config.ts,Component.module.css,Component.stories.tsx,index.ts, and wire the export through the group barrel and themetabase/uibarrel. - There are no call sites to map yet; instead note the intended usage from the ticket so the eventual showcase reflects real props.
- Order note: for a new component, implement and style it (Phase 4) first, *then* build the showcase (Phase 3) to present the finished result — there's nothing to render until it exists. The phases below are written update-first; just run 4 before 3 in create mode.
