PolicyEngine / PolicyEngine/policyengine-app-v2

Migrate inline styles to vanilla-extract for non-chart components

Open
#665 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1
Forks
3
Avg merge
1d 50m
Merged PRs (30d)
39

Description

Summary

Set up vanilla-extract (zero-runtime, type-safe CSS) and migrate inline styles from non-chart components. Charts use Recharts prop-based styling and don't benefit from VE — this targets the 75+ components with substantial inline style={{}} blocks.

Motivation

  • Inline styles can't be statically extracted, meaning larger JS bundles and no caching of styles
  • vanilla-extract compiles to static CSS at build time with full TypeScript support
  • Design tokens (colors, spacing, typography) can be enforced via createThemeContract

Scope

Setup
  • Install @vanilla-extract/css and @vanilla-extract/vite-plugin
  • Add vanillaExtractPlugin() to app/vite.config.ts
  • Create app/src/styles/theme.css.ts with createThemeContract from existing design tokens
Migration targets (by impact)

Start with components that have the heaviest inline styles:

  • Layout components (StandardLayout, PathwayLayout, AppLayout, StaticLayout)
  • Modal components (RenameIngredientModal, etc.)
  • Page shells and navigation
  • Form components
  • Card/list item components
Out of scope
  • Recharts chart components (use prop-based styling — see #663)
  • Mantine component overrides (use Mantine theme)

Approach

Co-locate .css.ts files with their components:

src/components/
  StandardLayout.tsx
  StandardLayout.css.ts    ← new

Context

Related: #663 (Recharts migration) established shared chart components with inline style constants (TOOLTIP_STYLE). That pattern is correct for SVG charts but doesn't scale for DOM-heavy components.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/vite.config.ts and inspect the existing design tokens before creating app/src/styles/theme.css.ts. Then review the inline style blocks in the named layout, modal, page-shell, navigation, form, and card/list components, excluding Recharts and Mantine overrides. Done means vanilla-extract is configured and the targeted non-chart components use co-located .css.ts styles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, frontend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.