Skip to content

Commit 52a3806

Browse files
authored
fix: icon builder illustrations (#8406)
* fix: icon builder illustration missing types * add magic flag :) * fix flag * use an svg, not the combined illustration file * try running tsc to test the types * update tsconfig * specify module resolution * try a different tact * run tsc * export our IllustrationProps types and Context * revert verdaccio
1 parent 027f96a commit 52a3806

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

packages/@react-spectrum/s2/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export type {DisclosureProps, DisclosurePanelProps} from './Disclosure';
119119
export type {DividerProps} from './Divider';
120120
export type {DropZoneProps} from './DropZone';
121121
export type {FormProps} from './Form';
122-
export type {IconProps, IconContextValue} from './Icon';
122+
export type {IconProps, IconContextValue, IllustrationProps, IllustrationContextValue} from './Icon';
123123
export type {InlineAlertProps} from './InlineAlert';
124124
export type {ImageProps} from './Image';
125125
export type {ImageCoordinatorProps} from './ImageCoordinator';

scripts/icon-builder-fixture/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"packageManager": "[email protected]",
33
"devDependencies": {
44
"parcel": "^2.13.0",
5-
"process": "^0.11.10"
5+
"process": "^0.11.10",
6+
"typescript": "^5.7.3"
67
},
78
"dependencies": {
89
"@react-spectrum/s2": "latest",
@@ -11,6 +12,7 @@
1112
"react-dom": "^18.2.0"
1213
},
1314
"scripts": {
15+
"tsc": "tsc",
1416
"dev": "parcel src/index.html",
1517
"build": "parcel build src/index.html"
1618
},

scripts/icon-builder-fixture/src/App.js renamed to scripts/icon-builder-fixture/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Text
1818
} from '@react-spectrum/s2';
1919
import AlignRight from '@react-spectrum/icon-library-test/AlignRight';
20+
import ThreeD from '@react-spectrum/icon-library-test/S2_lin_3D_48';
2021

2122
function App() {
2223
return (
@@ -25,6 +26,7 @@ function App() {
2526
<AlignRight />
2627
<Text>Action Button</Text>
2728
</ActionButton>
29+
<ThreeD />
2830
</main>
2931
);
3032
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"compilerOptions": {
3+
// we can explicitly declare `any`, but we don't want to infer `any`
4+
"noImplicitAny": false,
5+
// maybe bump to 'esNext'?
6+
"target": "es2018",
7+
// allows react jsx in tsx files
8+
// this is set to preserve so that different packages can use different JSX runtimes
9+
// depending on the React version they support. ESLint will ensure that React is imported
10+
// in packages using the old JSX runtime. Parcel will compile JSX according to the React
11+
// version specified in the package.json of each package.
12+
"jsx": "preserve",
13+
// Eventually turn off, one we have no more assumed default exports.
14+
// Allow default imports from modules with no default export.
15+
"allowSyntheticDefaultImports": true,
16+
// allows importing of json files, needed for locales as of right now
17+
"resolveJsonModule": true,
18+
// Search under node_modules for non-relative imports.
19+
"moduleResolution": "bundler",
20+
"module": "esnext",
21+
// Process & infer types from .js files.
22+
"allowJs": true,
23+
// Don't emit; allow Babel to transform files.
24+
"noEmit": true,
25+
// Disallow features that require cross-file information for emit.
26+
"isolatedModules": true,
27+
// Import non-ES modules as default imports.
28+
"esModuleInterop": true,
29+
// if 'target' is updated, this should be updated as well
30+
"lib": [
31+
"esnext",
32+
"dom",
33+
"dom.iterable"
34+
],
35+
"skipLibCheck": false,
36+
"strict": true
37+
},
38+
"include": [
39+
"src/**/*"
40+
],
41+
"exclude": [
42+
"**/node_modules"
43+
]
44+
}

scripts/verdaccio-build-icon-builder.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ mkdir -p $verdaccio_path
3737
echo 'test icon builder'
3838
cd examples/s2-webpack-5-example
3939
mkdir icon-test
40+
4041
cp ../../packages/@react-spectrum/s2/s2wf-icons/S2_Icon_3D_20_N.svg icon-test/S2_Icon_3D_20_N.svg
4142
npx @react-spectrum/s2-icon-builder -i ./icon-test/S2_Icon_3D_20_N.svg -o ./icon-dist
43+
cp ../../packages/@react-spectrum/s2/spectrum-illustrations/linear/S2_lin_3D_48.svg icon-test/S2_lin_3D_48.svg
44+
npx @react-spectrum/s2-icon-builder --type illustration -i ./icon-test/S2_lin_3D_48.svg -o ./icon-dist
4245
echo 'concluded icon builder'
4346

4447
echo 'testing icon builder library'
@@ -79,13 +82,16 @@ cat > icon-library-test/package.json << EOF
7982
EOF
8083

8184
mkdir icon-library-test/src
85+
mkdir icon-library-test/src/illustrations
8286
touch icon-library-test/yarn.lock
8387
cp ../../packages/@react-spectrum/s2/s2wf-icons/S2_Icon_3D_20_N.svg icon-library-test/src/S2_Icon_3D_20_N.svg
8488
cp ../../packages/@react-spectrum/s2/s2wf-icons/S2_Icon_AlignRight_20_N.svg icon-library-test/src/S2_Icon_AlignRight_20_N.svg
89+
cp ../../packages/@react-spectrum/s2/spectrum-illustrations/linear/S2_lin_3D_48.svg icon-library-test/src/illustrations/S2_lin_3D_48.svg
8590
cd icon-library-test
8691
echo "Installing and building icon library"
8792
yarn install --no-immutable
8893
yarn transform-icons -i './src/*.svg' -o ./ --isLibrary
94+
yarn transform-icons --type illustration -i './src/illustrations/*.svg' -o ./ --isLibrary
8995

9096
ls .
9197

@@ -106,6 +112,7 @@ yarn npm publish --tag latest
106112
echo "Building icon builder fixture"
107113
cd ../../../scripts/icon-builder-fixture
108114
yarn install --no-immutable
115+
yarn tsc
109116
yarn build --public-url ./
110117

111118
echo "Moving icon builder fixture to verdaccio"

0 commit comments

Comments
 (0)