Skip to content

Add @policyengine/ui-kit/legacy compatibility shim for design-system migration#28

Merged
MaxGhenis merged 1 commit into
mainfrom
feat/legacy-compat
May 9, 2026
Merged

Add @policyengine/ui-kit/legacy compatibility shim for design-system migration#28
MaxGhenis merged 1 commit into
mainfrom
feat/legacy-compat

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

Mirrors the API surface of the deprecated @policyengine/design-system package under @policyengine/ui-kit/legacy/*. Migrating consumers from design-system to ui-kit is now a pure import-path rename — no source code changes required.

Migration map

Before After
@policyengine/design-system @policyengine/ui-kit/legacy
@policyengine/design-system/tokens @policyengine/ui-kit/legacy/tokens
@policyengine/design-system/tokens/colors @policyengine/ui-kit/legacy/tokens/colors
@policyengine/design-system/tokens/typography @policyengine/ui-kit/legacy/tokens/typography
@policyengine/design-system/tokens/spacing @policyengine/ui-kit/legacy/tokens/spacing
@policyengine/design-system/charts @policyengine/ui-kit/legacy/charts

What's inside

  • Source files copied verbatim from policyengine-app-v2/packages/design-system/src/{tokens,charts} so values are identical.
  • Every export carries @deprecated JSDoc pointing to the canonical ui-kit equivalent (palette, semanticFills, typography, namedSpacing, chartPalette, chartColors, etc.).
  • 73 existing upstream tests ported into tests/legacy/ so any future drift will fail CI loudly.
  • Vite multi-entry build emits ESM + CJS + .d.ts for each subpath. package.json exports are added for all six paths.

Why

Currently 18 PolicyEngine repos still consume @policyengine/design-system (taxsim, uk-spring-statement-2026, cbo-baseline-tracker, missouri-transitional-benefits, housing-policy-dashboard, household-api-docs, uk-land-value-tax, policyengine-slides, impact-iran-war-living-standards, uc-uplift, policyengine-us-improvements-2026, policyengine-model, snap-bbce-repeal, nics-exemption-inactive-employees, senior-state-tax-breaks, working-Americans-tax-cut-act-, scotland-income-tax-reform, aspen-eitc-ctc). Per PolicyEngine/CLAUDE.md, ui-kit is the canonical design system; design-system is legacy. This shim lets us migrate every one of those repos with a single sed-replace per repo, no API rewrites.

The plan: ship this as 0.8.0, then bulk-migrate consumers, then eventually delete src/legacy/ in a future major release once all consumers are off it.

Test plan

  • bun run typecheck clean
  • bun run test — 26 files, 292 tests pass (was 219; +73 ported from design-system)
  • bun run build clean — verified dist/legacy/, dist/legacy/tokens/, dist/legacy/charts/ all emit ESM + CJS + .d.ts
  • All exports carry @deprecated JSDoc

🤖 Generated with Claude Code

Mirrors the API surface of the deprecated @policyengine/design-system
package so consumers can migrate via pure import-path rename:

  '@policyengine/design-system'                  → '@policyengine/ui-kit/legacy'
  '@policyengine/design-system/tokens'           → '@policyengine/ui-kit/legacy/tokens'
  '@policyengine/design-system/tokens/colors'    → '@policyengine/ui-kit/legacy/tokens/colors'
  '@policyengine/design-system/tokens/typography'→ '@policyengine/ui-kit/legacy/tokens/typography'
  '@policyengine/design-system/tokens/spacing'   → '@policyengine/ui-kit/legacy/tokens/spacing'
  '@policyengine/design-system/charts'           → '@policyengine/ui-kit/legacy/charts'

Source files copied from policyengine-app-v2/packages/design-system, all
exports carry @deprecated JSDoc pointing at the canonical ui-kit equivalents
(palette, semanticFills, typography, namedSpacing, chartPalette). Original
upstream tests (73 cases) ported into tests/legacy/ to catch behavior drift.

Subpath exports added to package.json + Vite library entries + tsconfig
include glob already covered by src/**/*. dist/ artifacts include both ESM
and CJS plus .d.ts emit for each subpath.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@policyengine policyengine Bot added the ⚙️ Engineering... PolicyEngine's GitHub agent is working on this label May 9, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-ui-kit Ready Ready Preview, Comment May 9, 2026 0:57am

Request Review

@MaxGhenis MaxGhenis merged commit 9ba65fa into main May 9, 2026
4 checks passed
@MaxGhenis MaxGhenis deleted the feat/legacy-compat branch May 9, 2026 12:59
Copy link
Copy Markdown
Contributor

@policyengine policyengine Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work on this legacy compatibility shim. The approach is sound and the implementation is thorough.

What I reviewed

Architecture: Vite multi-entry build config correctly mirrors all 6 subpath exports in package.json
Deprecation: All legacy exports carry @deprecated JSDoc with migration guidance
Tests: 292 total tests (219 existing + 73 ported from design-system)
Documentation: Clear migration map in JSDoc and changelog entry

Issues found and fixed

Fixed a bug in getNiceTicks() where reversed domains (e.g., [100, 0]) would return an empty array. The function now normalizes domains by swapping min/max if needed. Added 8 comprehensive tests covering edge cases including reversed domains, negative ranges, very small ranges, and large values.

What looks good

  • Package.json exports exactly match vite config entries
  • All convenience exports (TEAL_PRIMARY, FONT_UI, etc.) maintained for givecalc compatibility
  • Typography correctly consolidates all non-mono fonts to Inter
  • Chart utilities include nice tick generation, currency/percent formatters, and Plotly config
  • Test coverage is comprehensive across colors, typography, spacing, and charts

Minor notes (non-blocking)

  • formatCurrency(999999) returns "$1000K" instead of "$1.0M" (boundary case), but this is legacy behavior and fine for compatibility
  • No tests for getNiceTicks were included originally (I added them)
  • The PR description mentions 73 ported tests, which is accurate

This PR achieves its goal perfectly: pure import-path migration with zero API changes required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant