Skip to content

Commit

Permalink
update to sdv4 with async
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Sep 18, 2024
1 parent 83df85e commit f678243
Show file tree
Hide file tree
Showing 212 changed files with 5,020 additions and 3,977 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-stingrays-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': minor
---

update to SDv4
5 changes: 2 additions & 3 deletions .github/workflows/visual_regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ jobs:
cache: 'npm'

- name: Install dependencies
run: npm ci
run: npm ci && npm run install:storybook

- name: Build tokens
run: npm run build

- name: Build storybook
working-directory: docs/storybook
run: |
npm ci
npm run build-storybook
- name: Run storybook
Expand All @@ -46,7 +45,7 @@ jobs:
sleep 5
- name: Run Visual Regression Tests
uses: docker://mcr.microsoft.com/playwright:v1.45.1-jammy
uses: docker://mcr.microsoft.com/playwright:v1.47.1-jammy
env:
STORYBOOK_URL: 'http://172.17.0.1:6006'
with:
Expand Down
27 changes: 0 additions & 27 deletions buildConfig.tsconfig.jsonc

This file was deleted.

1,328 changes: 642 additions & 686 deletions docs/storybook/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions e2e/storybook.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {type Page, test, expect} from '@playwright/test'
// eslint-disable-next-line import/extensions, import/no-unresolved
import data from '../docs/storybook/storybook-static/stories.json'
import data from '../docs/storybook/storybook-static/stories.json' assert {type: 'json'}
// eslint-disable-next-line import/extensions, import/no-unresolved
import colorData from '../dist/docs/functional/themes/light.json'
import colorData from '../dist/docs/functional/themes/light.json' assert {type: 'json'}

const extractNameAndValue = Object.entries(colorData)
.map(([_key, details]) => ({
Expand Down
34 changes: 17 additions & 17 deletions integration/baseline.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary'
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary.js'
import fs from 'fs'

describe('PrimerStyleDictionary', () => {
describe('PrimerStyleDictionary', async () => {
const basePath = `./integration`
const buildPath = `${basePath}/build/baseline`

beforeAll(() => {
const extendedSD = PrimerStyleDictionary.extend({
beforeAll(async () => {
const extendedSD = await PrimerStyleDictionary.extend({
source: [`${basePath}/tokens/**/*.json5`],
platforms: {
css: {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('PrimerStyleDictionary', () => {
jsonFlat: {
prefix: 'PREFIX',
buildPath: `${buildPath}/json/`,
transforms: ['name/cti/pascal'],
transforms: ['name/pathToPascalCase'],
files: [
{
options: {
Expand All @@ -53,15 +53,15 @@ describe('PrimerStyleDictionary', () => {
},
})

extendedSD.cleanAllPlatforms()
extendedSD.buildAllPlatforms()
await extendedSD.cleanAllPlatforms()
await extendedSD.buildAllPlatforms()
})

it('runs baseline css/variables format', () => {
const output = fs.readFileSync(`${buildPath}/css/variables.css`, 'utf8')
const expectedOutput = `:root {
--prefix-base-color-aqua-blue-500: #2C29FF; /* The primary color for interactive elements. */
--prefix-fg-color-link-rest-01: #2C29FF;
--prefix-base-color-aqua-blue-500: #2c29ff; /* The primary color for interactive elements. */
--prefix-fg-color-link-rest-01: #2c29ff;
}
`
expect(output).toBe(expectedOutput)
Expand All @@ -74,15 +74,15 @@ describe('PrimerStyleDictionary', () => {
"color": {
"aquaBlue": {
"500": {
"value": "#2C29FF",
"$value": "#2C29FF",
"$type": "color",
"comment": "The primary color for interactive elements.",
"$description": "The primary color for interactive elements.",
"filePath": "integration/tokens/base.json5",
"isSource": true,
"original": {
"value": "#2C29FF",
"$value": "#2C29FF",
"$type": "color",
"comment": "The primary color for interactive elements."
"$description": "The primary color for interactive elements."
},
"name": "500",
"attributes": {},
Expand All @@ -98,12 +98,12 @@ describe('PrimerStyleDictionary', () => {
},
"fgColor": {
"link-rest-01": {
"value": "#2C29FF",
"$value": "#2C29FF",
"$type": "color",
"filePath": "integration/tokens/functional.json5",
"isSource": true,
"original": {
"value": "{base.color.aquaBlue.500}",
"$value": "{base.color.aquaBlue.500}",
"$type": "color"
},
"name": "link-rest-01",
Expand All @@ -122,8 +122,8 @@ describe('PrimerStyleDictionary', () => {
it('runs baseline flat json format', () => {
const output = fs.readFileSync(`${buildPath}/json/flat.json`, 'utf8')
const expectedOutput = `{
"PrefixBaseColorAquaBlue500": "#2C29FF",
"PrefixFgColorLinkRest01": "#2C29FF"
"PREFIXBaseColorAquaBlue500": "#2C29FF",
"PREFIXFgColorLinkRest01": "#2C29FF"
}
`
expect(output).toBe(expectedOutput)
Expand Down
31 changes: 18 additions & 13 deletions integration/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary'
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary.js'
import fs from 'fs'

describe('PrimerStyleDictionary', () => {
describe('PrimerStyleDictionary', async () => {
const basePath = `./integration`
const buildPath = `${basePath}/build/integreation`
const buildPath = `${basePath}/build/integration`

beforeAll(() => {
const extendedSD = PrimerStyleDictionary.extend({
beforeAll(async () => {
const extendedSD = await PrimerStyleDictionary.extend({
source: [`${basePath}/tokens/**/*.json5`],
platforms: {
advancedCss: {
prefix: 'PREFIX',
usesDtcg: true,
transforms: [
'name/pathToKebabCase',
'color/hex',
Expand All @@ -36,6 +37,7 @@ describe('PrimerStyleDictionary', () => {
},
commonJs: {
prefix: 'PREFIX',
usesDtcg: true,
transforms: [
'color/hex',
'color/hexMix',
Expand All @@ -59,6 +61,7 @@ describe('PrimerStyleDictionary', () => {
},
javascriptEsm: {
prefix: 'PREFIX',
usesDtcg: true,
buildPath: `${buildPath}/js/`,
transforms: [
'color/hex',
Expand All @@ -82,6 +85,7 @@ describe('PrimerStyleDictionary', () => {
},
jsonFigma: {
prefix: 'PREFIX',
usesDtcg: true,
buildPath: `${buildPath}/json/`,
transforms: [
'color/rgbaFloat',
Expand All @@ -104,6 +108,7 @@ describe('PrimerStyleDictionary', () => {
},
jsonNestedPrefixed: {
prefix: 'PREFIX',
usesDtcg: true,
buildPath: `${buildPath}/json/`,
transforms: [
'color/hex',
Expand Down Expand Up @@ -150,8 +155,8 @@ describe('PrimerStyleDictionary', () => {
},
})

extendedSD.cleanAllPlatforms()
extendedSD.buildAllPlatforms()
await extendedSD.cleanAllPlatforms()
await extendedSD.buildAllPlatforms()
})

it('runs css/advanced format', () => {
Expand Down Expand Up @@ -208,30 +213,30 @@ describe('PrimerStyleDictionary', () => {
const output = fs.readFileSync(`${buildPath}/json/figma.json`, 'utf8')
const expectedOutput = `[
{
"name": "PREFIX/base/color/aquaBlue/500",
"name": "PREFIX/fgColor/link-rest-01",
"value": {
"r": 0.17254901960784313,
"g": 0.1607843137254902,
"b": 1,
"a": 1
},
"type": "COLOR",
"description": "The primary color for interactive elements.",
"refId": "PREFIX/base/color/aquaBlue/500",
"refId": "PREFIX/fgColor/link-rest-01",
"reference": "PREFIX/base/color/aquaBlue/500",
"mode": "default",
"scopes": ["ALL_SCOPES"]
},
{
"name": "PREFIX/fgColor/link-rest-01",
"name": "PREFIX/base/color/aquaBlue/500",
"value": {
"r": 0.17254901960784313,
"g": 0.1607843137254902,
"b": 1,
"a": 1
},
"type": "COLOR",
"refId": "PREFIX/fgColor/link-rest-01",
"reference": "PREFIX/base/color/aquaBlue/500",
"description": "The primary color for interactive elements.",
"refId": "PREFIX/base/color/aquaBlue/500",
"mode": "default",
"scopes": ["ALL_SCOPES"]
}
Expand Down
Loading

0 comments on commit f678243

Please sign in to comment.