Skip to content

Commit 5fbbd9d

Browse files
authored
Restore missing control tokens in ESM mode (#1447)
* backfill missing control tokens * move esm fixture to correct folder
1 parent 414e53f commit 5fbbd9d

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react-brand': patch
3+
---
4+
5+
Fixed missing size and animation tokens in tree-shaken ESM component bundles like `Button`. Now all control tokens are loaded globally as a side-effect.

.github/workflows/integration_test_nextjs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ jobs:
9696
run: |
9797
rm ./${{ env.NEXTJS_FOLDER }}/app/page.tsx
9898
cp ./packages/e2e/integration-tests/nextjs/page.tsx ./${{ env.NEXTJS_FOLDER }}/app
99+
mkdir ./${{ env.NEXTJS_FOLDER }}/app/button-only
100+
cp ./packages/e2e/integration-tests/nextjs/button-only/page.tsx ./${{ env.NEXTJS_FOLDER }}/app/button-only
99101
cp ./packages/e2e/cypress.config.js ./${{ env.NEXTJS_FOLDER }}
100102
mkdir ${{ env.NEXTJS_FOLDER }}/integration-tests
101103
cp -r ./packages/e2e/integration-tests/fixtures ./${{ env.NEXTJS_FOLDER }}/integration-tests
102104
cp -r ./packages/e2e/integration-tests/tests ./${{ env.NEXTJS_FOLDER }}/integration-tests
105+
cp ./packages/e2e/integration-tests/nextjs/check-size-tokens.cy.ts ./${{ env.NEXTJS_FOLDER }}/integration-tests/tests
103106
104107
- name: Excluded cypress tests in-place
105108
# includes temp workaround for cypress bug. remove when fixed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
import {Button} from '../../integration-tests/fixtures'
4+
5+
export default function ButtonOnlyPage() {
6+
return <Button data-testid="button-only">Button-only page</Button>
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
describe('Size token integration tests', () => {
2+
it('loads shared size tokens without Stack on the page', () => {
3+
cy.visit('http://localhost:3000/button-only')
4+
5+
cy.get('[data-testid="button-only"]').should(button => {
6+
const ownerWindow = button[0].ownerDocument.defaultView
7+
8+
if (!ownerWindow) throw new Error('Expected the Button document to have a window')
9+
10+
const controlSize = ownerWindow.getComputedStyle(button[0]).getPropertyValue('--brand-control-medium-size').trim()
11+
12+
expect(controlSize).not.to.equal('')
13+
})
14+
})
15+
})

packages/react/src/css/stylesheets.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import './reset.css'
99
import '@primer/brand-primitives/lib/design-tokens/css/tokens/base/colors/color-scales-with-modes.css'
1010
import '@primer/brand-primitives/lib/design-tokens/css/tokens/base/size/size.css'
1111
import '@primer/brand-primitives/lib/design-tokens/css/tokens/base/typography/typography.css'
12+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/animation/base.css'
13+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/size/size.css'
1214
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/typography/typography-responsive.css'
1315
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/size/breakpoints.css'
1416
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/size/border.css'

0 commit comments

Comments
 (0)