Skip to content

Commit 2dcdc6e

Browse files
castastrophemarissahuysentruytgithub-actions[bot]
authored
chore: update s2 branch with latest (#3679)
* chore: adds support to parse "transparent" token references (#3452) * feat(tokens): add transparent token handling * adds transparent mapping into rgb-mapping plugin - custom properties that reference transparent tokens will now be mapped to their corresponding transparent rgb/opacity tokens - extends the work that the rgb-mapping plugin already does * test: add plugin test cases * chore(plugins/postcss-rgb-mapping): update README.md * chore: add changeset * chore: release (#3673) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(tokens): support style-dictionary build in windows env (#2500) --------- Co-authored-by: Marissa Huysentruyt <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e4556f1 commit 2dcdc6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1656
-866
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* text=auto eol=lf
12
README.md merge=ours
23

34
# Treat yarn assets as binaries for diffing

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,15 @@ jobs:
150150
echo "Changes detected"
151151
git status
152152
git add .
153-
git diff > changes.diff
154153
exit 1
155154
fi
156155
156+
# If there are changes, capture the changes and upload them as an artifact
157+
- name: Capture changes
158+
if: ${{ failure() }}
159+
id: capture-changes
160+
run: git diff --staged > changes.diff
161+
157162
- name: Upload changes
158163
if: ${{ failure() }}
159164
uses: actions/upload-artifact@v4

.github/workflows/development.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ jobs:
5252
system:
5353
- macos-latest
5454
- ubuntu-latest
55-
# - windows-latest # todo: debug token style-dictionary failures on windows
5655
node-version:
5756
- 20
57+
# experimental:
58+
# - false
59+
# include:
60+
# - system: windows-latest
61+
# experimental: true
62+
# - system: windows-latest
63+
# experimental: true
5864
uses: ./.github/workflows/build.yml
5965
with:
6066
system: ${{ matrix.system }}
@@ -188,7 +194,7 @@ jobs:
188194
# -------------------------------------------------------------
189195
vrt:
190196
name: Testing
191-
if: contains(github.event.pull_request.labels.*.name, 'run_vrt') || ((github.event.pull_request.draft != true || contains(github.event.pull_request.labels.*.name, 'run_ci')) && github.event.pull_request.mergeable == true)
197+
if: ${{ contains(github.event.pull_request.labels.*.name, 'run_vrt') || ((github.event.pull_request.draft != true || contains(github.event.pull_request.labels.*.name, 'run_ci')) && github.event.pull_request.mergeable == true) }}
192198
uses: ./.github/workflows/vrt.yml
193199
with:
194200
skip: ${{ github.base_ref == 'spectrum-two' || contains(github.event.pull_request.labels.*.name, 'skip_vrt') }}

.storybook/blocks/utilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function fetchToken(key, fallback = undefined, presets = {}) {
8686
// Check if the spectrum data is available
8787
if (!tokens || typeof tokens !== "object") return fallback;
8888

89-
return parseData(tokens[key], { color, platform }) ?? fallback;
89+
return parseData(tokens?.[key], { color, platform }) ?? fallback;
9090
}
9191

9292
/**

.storybook/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@
4848
"@babel/core": "^7.26.0",
4949
"@chromatic-com/storybook": "^3.2.3",
5050
"@etchteam/storybook-addon-status": "^5.0.0",
51-
"@storybook/addon-a11y": "~8.4.7",
52-
"@storybook/addon-actions": "~8.4.7",
53-
"@storybook/addon-designs": "^8.0.4",
54-
"@storybook/addon-docs": "~8.4.7",
55-
"@storybook/addon-essentials": "~8.4.7",
56-
"@storybook/addon-interactions": "~8.4.7",
57-
"@storybook/blocks": "~8.4.7",
58-
"@storybook/builder-vite": "~8.4.7",
59-
"@storybook/components": "~8.4.7",
60-
"@storybook/core-events": "~8.4.7",
61-
"@storybook/manager-api": "~8.4.7",
62-
"@storybook/preview-api": "~8.4.7",
63-
"@storybook/test-runner": "^0.21.0",
64-
"@storybook/theming": "~8.4.7",
65-
"@storybook/web-components-vite": "~8.4.7",
51+
"@storybook/addon-a11y": "8.4.7",
52+
"@storybook/addon-actions": "8.4.7",
53+
"@storybook/addon-designs": "^8.2.1",
54+
"@storybook/addon-docs": "8.4.7",
55+
"@storybook/addon-essentials": "8.4.7",
56+
"@storybook/addon-interactions": "8.4.7",
57+
"@storybook/blocks": "8.4.7",
58+
"@storybook/builder-vite": "8.4.7",
59+
"@storybook/components": "8.4.7",
60+
"@storybook/core-events": "8.4.7",
61+
"@storybook/manager-api": "8.4.7",
62+
"@storybook/preview-api": "8.4.7",
63+
"@storybook/test-runner": "^0.22.0",
64+
"@storybook/theming": "8.4.7",
65+
"@storybook/web-components-vite": "8.4.7",
6666
"@whitespace/storybook-addon-html": "^6.1.1",
6767
"chromatic": "^11.22.2",
6868
"lit": "^3.2.1",
@@ -75,7 +75,7 @@
7575
"react-syntax-highlighter": "^15.6.1",
7676
"remark-gfm": "^4.0.0",
7777
"rollup-plugin-postcss-lit": "^2.1.0",
78-
"storybook": "~8.4.7",
78+
"storybook": "8.4.7",
7979
"vite": "^5.4.11"
8080
},
8181
"keywords": [

nx.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@
8989
"cross-env NODE_OPTIONS=\"--no-warnings\" node -e 'require(\"./tasks/component-builder.js\").default()'"
9090
]
9191
},
92-
"outputs": ["{projectRoot}/dist/*.css", "{projectRoot}/dist/*.map"]
92+
"outputs": ["{projectRoot}/dist/*.css*", "{projectRoot}/dist/**/*.css*"]
9393
},
9494
"clean": {
9595
"cache": true,
9696
"executor": "nx:run-commands",
97-
"inputs": ["{projectRoot}/dist/*.css", "{projectRoot}/dist/*.map", { "externalDependencies": ["rimraf"] }],
97+
"inputs": ["{projectRoot}/dist/*.css*", "{projectRoot}/dist/**/*.css*", { "externalDependencies": ["rimraf"] }],
9898
"options": {
99-
"commands": ["rimraf {projectRoot}/dist/*.css {projectRoot}/dist/*.map"]
99+
"commands": ["rimraf {projectRoot}/dist/*.css* {projectRoot}/dist/**/"]
100100
},
101101
"outputs": ["{projectRoot}/dist"]
102102
},
103103
"compare": {
104104
"cache": true,
105-
"dependsOn": [{ "projects": "bundle", "target": "build" }],
105+
"dependsOn": ["build", { "projects": ["bundle"], "target": "build" }],
106106
"executor": "nx:run-commands",
107107
"inputs": [
108108
"{workspaceRoot}/tasks/compare-compiled-output.js",
@@ -217,6 +217,7 @@
217217
}
218218
},
219219
"validate": {
220+
"cache": true,
220221
"executor": "nx:run-commands",
221222
"inputs": [
222223
"{workspaceRoot}/schemas/metadata.schema.json",

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"clean:env": "rm -rf .env .storybook/chromatic.config.json",
2828
"clean:preview": "nx clean storybook --skip-nx-cache",
2929
"cleaner": "nx run-many --target clean --projects",
30-
"compare": "cross-env NODE_ENV=production node --no-warnings ./tasks/compare-compiled-output.js",
30+
"compare": "cross-env NODE_ENV=production yarn bundle && yarn component:compare",
3131
"component:build": "node --no-warnings ./tasks/component-builder.js",
3232
"component:compare": "node --no-warnings ./tasks/component-compare.js",
3333
"component:report": "node --no-warnings ./tasks/component-reporter.js",
@@ -70,9 +70,8 @@
7070
"@changesets/cli": "^2.27.11",
7171
"@commitlint/cli": "^19.6.1",
7272
"@commitlint/config-conventional": "^19.6.0",
73-
"@csstools/postcss-bundler": "^2.0.6",
7473
"@nx/devkit": "^19.8.2",
75-
"@spectrum-tools/postcss-rgb-mapping": "1.0.0",
74+
"@spectrum-tools/postcss-rgb-mapping": "1.1.0",
7675
"@yarnpkg/types": "^4.0.0",
7776
"at-rule-packer": "^0.4.2",
7877
"autoprefixer": "^10.4.21",
@@ -115,9 +114,9 @@
115114
"prettier": "^3.5.3",
116115
"rimraf": "^6.0.1",
117116
"semver": "^7.7.1",
118-
"stylelint": "^16.15.0",
119-
"stylelint-config-standard": "^36.0.1",
120-
"stylelint-header": "^2.1.0",
117+
"stylelint": "^16.18.0",
118+
"stylelint-config-standard": "^38.0.0",
119+
"stylelint-header": "^3.0.0",
121120
"stylelint-high-performance-animation": "^1.11.0",
122121
"stylelint-order": "^6.0.4",
123122
"stylelint-selector-bem-pattern": "^4.0.1",

plugins/postcss-rgb-mapping/CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Change Log
22

3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- [#3452](https://github.com/adobe/spectrum-css/pull/3452) [`287cff8`](https://github.com/adobe/spectrum-css/commit/287cff82b7706f0f56d6d37f48e1d9c60a6df4b9) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - Adds new functionality to better handle tokens that reference other transparent tokens.
8+
9+
When a custom properties below is defined as another, specifically "transparent," variable, such as:
10+
11+
```css
12+
--disabled-static-white-background-color: var(
13+
--spectrum-transparent-white-100
14+
);
15+
```
16+
17+
...the plugin can now convert this single custom property into its `-rgb` and `-opacity` postfixed variables, that each correspond to the `-rgb` and `-opacity` variables of the definition's transparent token. It then reassembles the original, using and referencing these newly created variables.
18+
19+
```css
20+
--disabled-static-white-background-color-rgb: var(
21+
--spectrum-transparent-white-100-rgb
22+
);
23+
--disabled-static-white-background-color-opacity: var(
24+
--spectrum-transparent-white-100-opacity
25+
);
26+
--disabled-static-white-background-color: rgba(
27+
var(--disabled-static-white-background-color-rgb),
28+
var(--disabled-static-white-background-color-opacity)
29+
);
30+
```
31+
332
## 1.0.0
433

534
### Major Changes

plugins/postcss-rgb-mapping/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# postcss-rgb-mapping
22

33
> Remaps rgb(a) values to an `rgb` postfixed variable. If an opacity is found, creates a separate `opacity` postfixed variable.
4+
> Also remaps values that reference a transparent token (for example, `transparent-black-300`) to `rgb` and `opacity` postfixed variables.
45
56
## Installation
67

@@ -11,6 +12,8 @@ postcss -u postcss-rgb-mapping -o dist/index.css src/index.css
1112

1213
## Usage
1314

15+
### Example 1: RGB and opacity postfixed variables
16+
1417
This plugin turns this:
1518

1619
```css
@@ -24,13 +27,63 @@ Into this:
2427

2528
```css
2629
.spectrum--lightest {
30+
/* Both --spectrum-seafoam-100 and --spectrum-seafoam-200 get split into separate
31+
"-rgb" and "-opacity" values when applicable. */
2732
--spectrum-seafoam-100-rgb: 206, 247, 243;
2833
--spectrum-seafoam-100: rgba(var(--spectrum-seafoam-100-rgb));
2934
--spectrum-seafoam-200-rgb: 170, 241, 234;
3035
--spectrum-seafoam-200-opacity: 0.5;
36+
/* The plugin then redefines the original custom variable to use the newly created
37+
"-rgb" and/or "-opacity" custom variables. */
3138
--spectrum-seafoam-200: rgba(
3239
var(--spectrum-seafoam-200-rgb),
3340
var(--spectrum-seafoam-200-opacity)
3441
);
3542
}
3643
```
44+
45+
### Example 2: Remapping of transparent tokens
46+
47+
This plugin turns this:
48+
49+
```css
50+
.spectrum--lightest {
51+
--spectrum-transparent-white-100-rgb: 100, 100, 100;
52+
--spectrum-transparent-white-100-opacity: 0.5;
53+
--spectrum-transparent-white-100: rgba(
54+
var(--spectrum-transparent-white-100-rgb),
55+
var(--spectrum-transparent-white-100-opacity)
56+
);
57+
/* The custom properties below is defined as another, specifically "transparent," variable. */
58+
--disabled-static-white-background-color: var(
59+
--spectrum-transparent-white-100
60+
);
61+
}
62+
```
63+
64+
Into this:
65+
66+
```css
67+
.spectrum--lightest {
68+
--spectrum-transparent-white-100-rgb: 100, 100, 100;
69+
--spectrum-transparent-white-100-opacity: 0.5;
70+
--spectrum-transparent-white-100: rgba(
71+
var(--spectrum-transparent-white-100-rgb),
72+
var(--spectrum-transparent-white-100-opacity)
73+
);
74+
/* In a similar fashion, the plugin creates new "-rgb" and "-opacity" postfixed custom
75+
variables, that correspond to the definition's transparent "-rgb" and "-opacity"
76+
postfixed custom variables. */
77+
--disabled-static-white-background-color-rgb: var(
78+
--spectrum-transparent-white-100-rgb
79+
);
80+
--disabled-static-white-background-color-opacity: var(
81+
--spectrum-transparent-white-100-opacity
82+
);
83+
/* Then reassembles the original to use and reference these newly created variables. */
84+
--disabled-static-white-background-color: rgba(
85+
var(--disabled-static-white-background-color-rgb),
86+
var(--disabled-static-white-background-color-opacity)
87+
);
88+
}
89+
```

plugins/postcss-rgb-mapping/expected/basic.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
--seafoam-200: rgba(var(--seafoam-200-rgb), var(--seafoam-200-opacity));
77
--seafoam-300-rgb: 206, 247, 243;
88
--seafoam-300: rgba(var(--seafoam-300-rgb));
9+
--spectrum-transparent-white-100-rgb: 100, 100, 100;
10+
--spectrum-transparent-white-100-opacity: 0.5;
11+
--spectrum-transparent-white-100: rgba(var(--spectrum-transparent-white-100-rgb), var(--spectrum-transparent-white-100-opacity));
12+
--disabled-static-white-background-color-rgb: var(--spectrum-transparent-white-100-rgb);
13+
--disabled-static-white-background-color-opacity: var(--spectrum-transparent-white-100-opacity);
14+
--disabled-static-white-background-color: rgba(var(--disabled-static-white-background-color-rgb), var(--disabled-static-white-background-color-opacity));
915
}

0 commit comments

Comments
 (0)