Polish Component

Polish a shippable React component in packages/life/src and/or its HTML catalog specimen. Use for uneven insets, off-center icons, accent focus rings, and mixed token layers. Configure wiring alone is not polish.

Production-ready: PRODUCTION_READY.md · Index. This skill closes light + dark (tokens in both themes) and focus-visible (greyscale only). Other checklist items → stress-test, component-cycle.

Polish the shippable React component (packages/life/src/<Name>/) and keep its HTML catalog specimen (preview.html) aligned. Preserve behavior, states, and hierarchy. Use AGENTS.md, Life DESIGN.md, the spec, specimen prototype, and shared recipe for geometry.

Definition of done: every row in the audit table below has a measured or derived value, every discrepancy is fixed in the layer that owns it, and both React and specimen read only Life tokens. Adding SpecimenPlatform.register, chrome classes, or Configure fields is specimen-only catalog plumbing — do it if missing, but it never counts as the polish.

1. Find the owner before touching anything

  1. Locate the React component (packages/life/src/<Name>/) and its Studio catalog preview (apps/studio/src/lib/life-specimens/previews/<Name>.tsx). Grep recipe classes only for Studio legacy specimens (life-specimen-legacy.css). Shippable components style with cva + @sarvam/life/tailwind-theme.css and register catalog meta in apps/studio/src/lib/life-specimens/catalog-meta.ts.
  2. Decide ownership per defect:
    • Defect visible in every caller → fix the shared recipe, scoped under the component's root class (e.g. .sc-modelmenu .sc-menu__item) so unrelated callers of generic classes (.sc-menu--plain, .sc-menu__item) are not changed.
    • Defect only in one container → fix the caller.
    • Specimen-local overrides that re-implement recipe geometry (heights, padding, radii on the component itself) are defects. Move them into the recipe or delete them. A specimen may only own stage layout and positioning.
  3. Record the reference: supplied design, component spec, or the nearest comparable Life recipe at the same density (e.g. dropdown.css for menus). Without a supplied design, use the closest moodboard screen in visual-direction and check surfaces against its Surface roles, Shape and Depth tables. Write down which one you chose.

2. Token audit (static, always)

Document every --sv-* the recipe reads in the component docs Tokens used section (COMPONENT_DOCS.md).

All Sarvam surfaces use one generated token layer from packages/life/design-system/tokens.css (DTCG via pnpm run tokens; light default on :root; dark on [data-theme="dark"]; [data-font-mode] for prototype font swaps only):

SourceUse
packages/life/design-system/tokens.css--sv-content-*, --sv-background-*, --sv-border-*, --sv-space-*, --sv-radius-<px>, --sv-text-<role>-size / -leading / -tracking, scale --sv-text-base / --sv-text-sm / pixel compat --sv-text-13, --sv-icon-box-<px>, --sv-weight-*
  • Text and icon color use --sv-content-<role> only (semantic content roles renamed from legacy --sv-text-<role>).
  • Every length is a token: --sv-space-* for padding, gaps, heights; --sv-radius-<px>; --sv-icon-box-<px> for icon and logo boxes; typography via Tatva roles --sv-text-<role>-{size,leading,tracking,weight,family} (see references/parity/typography-roles.md) or compat pixel steps (--sv-text-13, --sv-text-base). Raw px is allowed only for hairlines (1px) and documented optical offsets.
  • Prefer the 8px grid (--sv-space-0.5/16/24/32…); use 2/4/6/10/12 steps only where a recipe relationship requires them (insets, concentric radii).
  • If a token itself is wrong, follow AGENTS.md (Figma variables → Primitives page → comparison board) instead of hardcoding.

3. Geometry audit (derive, then measure)

Derive the intended value for each relationship from the recipe before looking at pixels. Fill this table in your notes and report it.

RelationshipRule
Surface insetOne value on all four sides of a floating surface (menu, popover, card). Block ≠ inline inset is a defect unless the spec says otherwise.
Concentric radiiInner radius = outer radius − inset (e.g. 16 − 6 = 10). Hover/selected backgrounds use the inner radius.
Surface roleEach surface is one of ground / surface / tray (visual-direction); no box-shadow or elevation except focus rings; selection is a flat fill; planes stay distinct in light and dark.
Shared leading edgeItem labels, search field text, group labels, and empty states start at the same x: surface inset + row padding.
Row heightRows, search fields, and parent rows inside one surface share one height token.
Row pitchOne gap between adjacent rows; group labels and separators define the only larger breaks.
Separator bleedNegative margin equals the surface inset exactly, on both axes.
Icon sourceEvery icon is a Hugeicons icon from the existing library: Standard stroke by default, solid where the state or context calls for it. No custom or inline SVG; SVG files are allowed only for logos and brand marks (for example model logos). CSS-drawn glyphs (such as a stop square) count as custom icons and get replaced.
Icon boxesIcons and logos in the same slot share one --sv-icon-box-*; leading glyphs align on a common center line.
Pill / rounded triggerFully rounded control: side padding ≥ height ÷ 3 (ModelMenu trigger: 36 tall → --sv-space-7). Triggers that live inside a host surface (composer bar) are borderless; hover supplies the surface. Wrapper spans inside flex triggers must be inline-flex; align-items: center so glyphs don't sit on the text baseline.
Trigger → surface offsetGap between trigger and floating surface is a --sv-space-* token (default --sv-space-0.5).
FitLong labels truncate, empty optional content collapses, state changes don't shift neighbors.

4. Cascade and state audit (static, always)

Check what actually wins, not what you wrote:

  • Focus rings (greyscale only). Use var(--sv-border-focus) / focus-ring tokens — never accent or chromatic palette vars on :focus-visible. bundle.css applies .sc :focus-visible { outline … } at specificity (0,2,0). A component rule like .sc-menu__search input { outline: 0 } (0,1,1) loses, so text inputs that autofocus show a ring. Inputs embedded in a composite control suppress the ring with a selector ≥ (0,2,1), e.g. .sc-modelmenu .sc-menu__search input:focus-visible { outline: none }, and rely on the caret or :focus-within on the container. Real buttons and rows keep a visible neutral ring; use a negative outline-offset inside clipped surfaces.

  • Later generic rules. Rules later in bundle.css (e.g. .sc-menu--plain .sc-menu__item { color }) override earlier scoped rules of equal specificity. Raise specificity on the scoped rule (.sc-modelmenu .sc-menu .sc-menu__item) rather than reordering the file or using !important.

  • Hover / pressed / expanded / checked / disabled. Each state uses one background role (--sv-background-hover for hover and expanded parents in menus) and is consistent across rows of the same kind.

  • Local resets. all: unset in a specimen is a smell; it hides recipe values and fights the cascade. Remove it and give the recipe explicit input styles.

  • Disabled versus read-only. If a trigger must stay legible but not open (a picker locked for a running session), add a readOnly state on that component (Listbox.Trigger, the composer pickers already have one) that blocks opening at full ink and sets aria-readonly. It is a state, not a new component. Do not rely on a consumer overriding opacity by aria-label.

  • Scroll bodies. A scrolling body reaches the component's edge with a thin scrollbar and keeps content on the padded edge (see the Dialog body). Check it does not clip borders or focus rings.

  • Radius. A consumer forcing one radius with a wrapper is a sign the component needs a shared radius token; log it.

5. Catalog presentation (when touching the specimen)

Catalog specimens follow the single-live-component pattern (see Plate My Component):

  • Embedded view (?embedded=1) shows only the interactive component, centered by _sync/specimen-embedded.css. Specimen stage rules must not fight that centering (e.g. justify-items: start needs an embedded override).
  • Variant × size components (Button, Tag, Badge) open on a group view; see the group-view test in Plate My Component. Do not add one to menus, overlays, or workflows.
  • Use Configure (SpecimenPlatform.register with boolean/select fields) for the states you compare while polishing. No stacked on-page copies.
  • Standalone preview may keep author chrome (.specimen-chrome, .preview-instructions, .preview-note, .preview-result).

6. Fix

  • Fix in the owning layer with shared flex/grid alignment, one inset, and Life tokens. Express recipe relationships as local custom properties (--mm-inset, --mm-row, --mm-row-pad) so the derived values stay in sync.
  • Use a measured optical offset only when the glyph still looks off after its box is aligned, and leave a one-line comment stating why.
  • Additive by default: scope new rules under the component root; don't rewrite generic classes other callers depend on.

7. Verify and report

  • Static checks always: re-read the final cascade for every audited selector, and grep the specimen for leftover local geometry or all: unset.
  • Runtime checks (live bounds, computed styles, screenshots in light and dark, keyboard focus) only when the user allows agent-driven browser verification. Otherwise, hand off with the exact states to check in Configure.
  • Report: the owner you changed, the audit table with before → after values, token replacements, cascade fixes, other callers affected by recipe changes, and anything you could not verify.

Polish alone does not earn the catalog green dot — complete PRODUCTION_READY.md on the React module (AGENTS.md).