Skip to content

feat(gamut-styles): groundwork for static component styles - #69

Draft
dreamwasp wants to merge 13 commits into
cass-gmt-1825-color-white-labelfrom
cass-static-styles-groundwork
Draft

dreamwasp wants to merge 13 commits into
cass-gmt-1825-color-white-labelfrom
cass-static-styles-groundwork

Conversation

@dreamwasp

@dreamwasp dreamwasp commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Stand-alone. Base: #66 (color-white-label). Static component styles groundwork; it does not depend on the components work.
The colorSystem/README.md edits on this branch were dropped in the merge, because white-label moved that README to packages/gamut-brand/README.md. They are now ported to packages/gamut-brand/README.md (white-label, #66), which this branch picks up through that merge.


Overview

Groundwork for moving gamut's components off runtime Emotion styles. It adds the pieces a component needs to ship its styles as compiled CSS, and nothing uses them yet. Nothing renders differently. Draft, stacked on #52, so it merges after #52. Plan and reasoning: gamut/color-tokens/static-styles-spike.md in Base Camp.

What's added (packages/gamut-styles/src/static/)

  • defineRecipe: a component's styles as data (base, named variants, defaultVariants, compoundVariants), in Chakra's and Panda's recipe shape, written with the same style objects as css() and variant().
    • recipe.styles is the same recipe as an Emotion style function, so a component can move to a recipe while still on Emotion.
    • recipe.classNames(props) gives stable class names like gamut-chip gamut-chip--intent_danger.
    • recipe.splitProps separates variant props from the rest so they aren't forwarded to the DOM.
  • compileRecipe: plain CSS for a recipe's class names, inside @layer recipes.
  • checkRecipe: compiles the recipe for every brand theme and reports whether the output differs. A recipe that uses a per-brand value (for example fontFamily: 'accent') fails and names the brand.
  • StaticStyles: puts compiled CSS on the page once, through the Emotion cache, so SSR, nonces and stylis plugins work as they do today.
  • packages/gamut-styles/src/static/README.md has the steps for moving a component and the rules a recipe has to follow to compile.

What's not in this PR

  • No component uses a recipe. Moving one is a later PR.
  • states() has no recipe shape yet. Boolean variant keys (true/false) come in a later step, and false in a selection currently turns a group off, so that needs a decision first.
  • No build step. compileRecipe runs once per module in the browser.
  • Fonts, font weights and elevation are still per-brand literals, so most components will fail checkRecipe until they become CSS variables.

Small unrelated change: script/jest/base-setup.js skips window.scrollTo when there's no window, so @jest-environment node tests (server rendering) run.

PR Checklist

  • Related to designs: no design change; no visual output changes
  • Related to JIRA ticket: none yet. Step 7 of the static-styles plan has no ticket; GMT-1744 covers styled from gamut
  • Changeset added (.changeset/static-styles-groundwork.md, minor)
  • I have run this code to verify it works. Ran the static folder's tests only; not the full suite, and not in a consuming app
  • This PR includes unit tests for the code change (__tests__/recipe.test.tsx, __tests__/StaticStyles.ssr.test.tsx)
  • This PR includes testing instructions
  • Package previews from this PR are passing end-to-end tests in all relevant consuming repositories. N/A: nothing consumes it yet

Testing Instructions

  1. Check out this branch (it's stacked on feat(gamut-styles)!: brands, overrides and Original Codecademy on the color system #52, so the diff also shows feat(gamut-styles)!: brands, overrides and Original Codecademy on the color system #52's changes until feat(gamut-styles)!: brands, overrides and Original Codecademy on the color system #52 merges).
  2. Run the static folder's tests:
    npx jest packages/gamut-styles/src/static
    
    Expect 2 suites and 14 tests to pass.
  3. Read packages/gamut-styles/src/static/README.md, then look at the sample chip recipe in __tests__/recipe.test.tsx. It shows recipe.styles, classNames, compileRecipe, and a checkRecipe failure case.
  4. Check that nothing changed for existing components: run the gamut-styles test suite. Existing components don't import anything from static/.

PR Links and Envs

Repository PR Link
Stack #52 (base), #50 (its base)
Consumers None yet

Breaking changes: none. Additive only.

🤖 Generated with Claude Code

Build: yarn build fails on this PR: gamut:build type-checks components that still use the old color names. The migration to color roles is in #54, and the build passes there (cass-gmt-1825-color-components, af734ec).

dreamwasp and others added 2 commits November 9, 2026 11:23
Adds defineRecipe, compileRecipe, checkRecipe and StaticStyles. No
component uses them yet. The jest base setup skips window.scrollTo in
node-environment tests.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
dreamwasp and others added 3 commits November 10, 2026 11:32
… cass-static-styles-groundwork

# Conflicts:
#	.changeset/color-system-brands.md
#	packages/gamut-styles/src/colorSystem/README.md
#	packages/gamut-styles/src/themes/__tests__/__snapshots__/theme.test.ts.snap
#	packages/gamut/src/Alert/__tests__/Alert.test.tsx
The SSR test runs in a Node environment through a Vitest comment. The shared jsdom setup now skips its window guard when there is no window.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
dreamwasp added a commit that referenced this pull request Nov 20, 2026
Replaces this branch's tree with the color stack as it now stands: the
site branch (#67, which includes #63, #59, #54, #66, #58, #52 and #50,
each merged with main through 45586df), plus the codemod branch (#53).
Static styles (#69) is still out, as before.

The preview's earlier head is the parent. This commit only moves the
tree forward, so nothing is rewritten.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
1314 3 1311 0
View the top 3 failed test(s) by shortest run time
packages/gamut/src/Alert/__tests__/Alert.test.tsx > packages/gamut/src/Alert/__tests__/Alert.test.tsx
Stack Traces | 0s run time
Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock
 ❯ .../src/Alert/Alert.tsx:5:1

Caused by: Caused by: ReferenceError: jest is not defined
 ❯ .../Alert/__tests__/Alert.test.tsx:18:29
 ❯ .../src/Alert/Alert.tsx:5:1
packages/gamut/src/Card/Card.test.tsx > useCardElevation > resolves borderRadius from percipioTheme
Stack Traces | 0.00203s run time
TypeError: Cannot read properties of undefined (reading 'borderRadii')
 ❯ forEach .../src/Card/Card.test.tsx:78:21
 ❯ .../src/Card/Card.test.tsx:64:35
packages/gamut/src/Card/Card.test.tsx > useCardElevation > resolves borderRadius from coreTheme
Stack Traces | 0.00782s run time
TypeError: Cannot read properties of undefined (reading 'borderRadii')
 ❯ forEach .../src/Card/Card.test.tsx:78:21
 ❯ .../src/Card/Card.test.tsx:64:35

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

dreamwasp and others added 3 commits November 20, 2026 11:50
# Conflicts:
#	script/jest/base-setup.js
#	yarn.lock
Takes white-label's layout for the generator, changeset and Alert test. Drops
static's colorSystem README (moved to gamut-brand) and an orphaned theme
snapshot under themes/__tests__.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@dreamwasp
dreamwasp changed the base branch from cass-gmt-1825-color-brands to cass-gmt-1825-color-white-label December 2, 2026 20:24

This branch has not been deployed

No deployments
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