Skip to content

Commit 24b0db2

Browse files
committed
feat(icon,ui-icons)!: migrate the icon compiler to a distinct package
BREAKING CHANGE: - icon will no longer contain SVG assets
1 parent a987407 commit 24b0db2

File tree

168 files changed

+402
-450
lines changed

Some content is hidden

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

168 files changed

+402
-450
lines changed

.github/actions/file-diff/index.js

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,12 @@ async function run() {
113113
if (hasDiff) {
114114
// If a diff path was provided and the component folder doesn't exist,
115115
// report that the compiled assets were removed
116-
if (!existsSync(join(diffPath, "components", name))) {
116+
if (
117+
!existsSync(join(diffPath, "components", name)) ||
118+
(totalSize === 0 && totalDiffSize > 0)
119+
) {
117120
data.push("🚨 package deleted/moved/renamed");
118-
summaryTable.push(data);
119-
return;
120-
}
121-
122-
if (totalSize > 0 && totalDiffSize === 0) {
123-
data.push("⚠️ assets deleted/moved/renamed");
124-
summaryTable.push(data);
125-
return;
126-
}
127-
128-
if (totalSize === 0 && totalDiffSize > 0) {
121+
} else if (totalSize > 0 && totalDiffSize === 0) {
129122
data.push("🎉 new package");
130123
} else {
131124
data.push(printChange(totalDiffSize - totalSize));
@@ -136,16 +129,15 @@ async function run() {
136129

137130
md.push(
138131
...[
139-
["File", "Size", ...(hasDiff ? ["Original size", ", "Δ%"] : [])],
140-
[" - ", " - ", ...(hasDiff ? [" - ", " - ", " - "] : [])],
132+
["File", "Size", ...(hasDiff ? ["Base", "Δ"] : [])],
133+
[" - ", " - ", ...(hasDiff ? [" - ", " - "] : [])],
141134
[
142-
"**Total changes**",
135+
"**Total**",
143136
bytesToSize(totalSize),
144137
...(hasDiff
145138
? [
146139
bytesToSize(totalDiffSize),
147-
printChange(totalDiffSize - totalSize),
148-
printPercentChange((totalDiffSize - totalSize) / totalSize),
140+
`${printChange(totalDiffSize - totalSize)} (${printPercentChange((totalDiffSize - totalSize) / totalSize)})`,
149141
]
150142
: []),
151143
],
@@ -158,20 +150,17 @@ async function run() {
158150
) => {
159151
// @todo readable filename can be linked to html diff of the file?
160152
// https://github.com/adobe/spectrum-css/pull/2093/files#diff-6badd53e481452b5af234953767029ef2e364427dd84cdeed25f5778b6fca2e6
161-
const row = [
162-
readableFilename,
163-
byteSize === 0 ? "**removed**" : bytesToSize(byteSize),
164-
diffByteSize === 0 ? "" : bytesToSize(diffByteSize),
153+
return [
154+
...table,
155+
[
156+
readableFilename,
157+
byteSize === 0 && diffByteSize > 0 ? "**removed**" : bytesToSize(byteSize),
158+
...(hasDiff ? [
159+
bytesToSize(diffByteSize),
160+
`${printChange(diffByteSize - byteSize)} (${printPercentChange((diffByteSize - byteSize) / byteSize)})`,
161+
] : []),
162+
]
165163
];
166-
167-
if (hasDiff && diffByteSize > 0) {
168-
if (byteSize === 0) row.push("", "");
169-
else {
170-
row.push(printChange(diffByteSize - byteSize), "");
171-
}
172-
}
173-
174-
return [...table, row];
175164
},
176165
[]
177166
)
@@ -248,10 +237,8 @@ run();
248237
*/
249238
const printChange = function (difference) {
250239
return difference === 0
251-
? `No change 🎉`
252-
: `${difference > 0 ? "+" : "-"}${bytesToSize(Math.abs(difference))} ${
253-
difference > 0 ? "⬆" : "⬇"
254-
}`;
240+
? `-`
241+
: `${difference > 0 ? "⬆" : "⬇"} ${bytesToSize(Math.abs(difference))}`;
255242
};
256243

257244
/**
@@ -262,9 +249,8 @@ const printChange = function (difference) {
262249
* @returns {string}
263250
*/
264251
const printPercentChange = function (delta) {
265-
if (delta === 0) return `0%`;
266-
const direction = delta > 0 ? "+" : "-";
267-
return `${direction}${Math.abs(delta * 100).toFixed(2)}%`;
252+
if (delta === 0) return `no change`;
253+
return `${Math.abs(delta * 100).toFixed(2)}%`;
268254
};
269255

270256
/**

.github/workflows/compare-results.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ jobs:
7373
shell: bash
7474
run: yarn install --frozen-lockfile --cache-folder .cache/yarn
7575

76-
- name: Download build artifacts for head ${{ inputs.head-sha }}
76+
- name: Download build artifacts for head
7777
uses: actions/download-artifact@v3
7878
with:
7979
name: ubuntu-latest-node18-compiled-assets-${{ inputs.head-sha }}
80-
path: ${{ github.workspace }}/${{ inputs.head-sha }}/components
80+
path: ${{ github.workspace }}/${{ inputs.head-sha }}
8181

82-
- name: Download build artifacts for base ${{ inputs.base-sha }}
82+
- name: Download build artifacts for base
8383
uses: actions/download-artifact@v3
8484
with:
8585
name: ubuntu-latest-node18-compiled-assets-${{ inputs.base-sha }}
86-
path: ${{ github.workspace }}/${{ inputs.base-sha }}/components
86+
path: ${{ github.workspace }}/${{ inputs.base-sha }}
8787

8888
- name: Compare compiled output file size
8989
id: compare
@@ -92,7 +92,10 @@ jobs:
9292
with:
9393
path: ${{ github.workspace }}/${{ inputs.head-sha }}/
9494
diff-path: ${{ github.workspace }}/${{ inputs.base-sha }}/
95-
file-glob-pattern: components/*/dist/**
95+
file-glob-pattern: |
96+
components/*/dist/**
97+
tokens/dist/**
98+
ui-icons/dist/**
9699
token: ${{ secrets.GITHUB_TOKEN }}
97100

98101
fetch-build-artifacts:
@@ -161,16 +164,13 @@ jobs:
161164
uses: actions/cache@v3
162165
with:
163166
path: |
164-
components/*/dist/**
167+
components/*/dist/**
168+
tokens/dist/**
169+
ui-icons/dist/**
165170
key: ${{ steps.derive-key.outputs.key }}
166171

167-
- name: Build components
168-
if: ${{ matrix.branch == inputs.base-sha && steps.cache-build.outputs.cache-hit != 'true' }}
169-
shell: bash
170-
run: yarn build
171-
172-
- name: Build components
173-
if: ${{ matrix.branch == inputs.head-sha && steps.cache-build.outputs.cache-hit != 'true' }}
172+
- name: Build
173+
if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
174174
shell: bash
175175
run: yarn build
176176

@@ -179,7 +179,9 @@ jobs:
179179
uses: actions/upload-artifact@v3
180180
with:
181181
path: |
182-
${{ github.workspace }}/components/*/dist/**
182+
${{ github.workspace }}/components/*/dist/**
183+
${{ github.workspace }}/tokens/dist/**
184+
${{ github.workspace }}/ui-icons/dist/**
183185
name: ${{ steps.derive-key.outputs.key }}
184186
# this is important, it lets us catch if the build failed silently
185187
# by alterting us that no compiled assets were generated

.storybook/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const componentPkgs = readdirSync(componentsPath, {
88
.map((dirent) => dirent.name);
99
module.exports = {
1010
stories: [
11-
"../components/*/stories/*.stories.mdx",
1211
"../components/*/stories/*.stories.@(js|jsx|ts|tsx)",
1312
],
1413
rootDir: "../",

.storybook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"dependencies": {
1010
"@adobe/spectrum-css-workflow-icons": "^1.5.4",
1111
"@spectrum-css/expressvars": "^3.0.9",
12-
"@spectrum-css/icon": "^4.0.5",
1312
"@spectrum-css/site": "^4.0.2",
1413
"@spectrum-css/tokens": "^13.0.5",
14+
"@spectrum-css/ui-icons": "^0.0.0",
1515
"@spectrum-css/vars": "^9.0.8"
1616
},
1717
"devDependencies": {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ For most use cases, you'll want to use `spectrum-css-icons.svg` so you have supp
149149
```js
150150
<script src="node_modules/loadicons/index.js"></script>
151151
<script>
152-
loadIcons('node_modules/@spectrum-css/icon/dist/spectrum-css-icons.svg');
152+
loadIcons('node_modules/@spectrum-css/ui-icons/dist/spectrum-css-icons.svg');
153153
</script>
154154
```
155155

156156
Based on which scales you'll be using, you can choose to load different files:
157157

158-
- `@spectrum-css/icon/dist/spectrum-css-icons.svg` - Both medium and large icons for responsive UIs that support both `.spectrum--medium` and `.spectrum--large`
158+
- `@spectrum-css/ui-icons/dist/spectrum-css-icons.svg` - Both medium and large icons for responsive UIs that support both `.spectrum--medium` and `.spectrum--large`
159159
- `@spectrum-css/icon/dist/spectrum-css-icons-medium.svg` - Medium icons only, supports `.spectrum--medium` only
160160
- `@spectrum-css/icon/dist/spectrum-css-icons-large.svg` - Large icons only, supports `.spectrum--large` only
161161

components/icon/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# `@spectrum-css/icon`
22

3-
The icons component contains all UI icons used for components as well as the CSS for UI and workflow icons.
3+
The icons component contains the CSS for UI and workflow icons.

components/icon/combined/Arrow100.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow200.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow300.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow400.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow500.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow600.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Arrow75.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Asterisk100.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Asterisk200.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Asterisk300.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Asterisk75.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark100.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark200.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark300.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark400.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark50.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark500.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/icon/combined/Checkmark600.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)