@react-spectrum/parcel-transformer-s2-icon 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/IconTransformer.js +21 -18
- package/package.json +13 -13
package/IconTransformer.js
CHANGED
|
@@ -23,9 +23,8 @@ module.exports = new Transformer({
|
|
|
23
23
|
let hash = crypto.createHash('md5');
|
|
24
24
|
hash.update(iconName);
|
|
25
25
|
let prefix = hash.digest('hex').slice(-6);
|
|
26
|
-
let optimized = (
|
|
27
|
-
contents,
|
|
28
|
-
{
|
|
26
|
+
let optimized = (
|
|
27
|
+
await transform(contents, {
|
|
29
28
|
jsxRuntime: 'automatic',
|
|
30
29
|
svgoConfig: {
|
|
31
30
|
plugins: [
|
|
@@ -59,10 +58,10 @@ module.exports = new Transformer({
|
|
|
59
58
|
]
|
|
60
59
|
},
|
|
61
60
|
replaceAttrValues: {
|
|
62
|
-
'var(--iconPrimary, #222)': `var(--iconPrimary,
|
|
63
|
-
'var(--iconPrimary, #222222)': `var(--iconPrimary,
|
|
64
|
-
'var(--iconPrimary, #292929)': `var(--iconPrimary,
|
|
65
|
-
'var(--spectrum-global-color-gray-800, #292929)': `var(--iconPrimary,
|
|
61
|
+
'var(--iconPrimary, #222)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
62
|
+
'var(--iconPrimary, #222222)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
63
|
+
'var(--iconPrimary, #292929)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
64
|
+
'var(--spectrum-global-color-gray-800, #292929)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`
|
|
66
65
|
},
|
|
67
66
|
typescript: true,
|
|
68
67
|
ref: true,
|
|
@@ -70,26 +69,30 @@ module.exports = new Transformer({
|
|
|
70
69
|
})
|
|
71
70
|
).replace('export default ForwardRef;', '');
|
|
72
71
|
let newFile = template(asset, optimized);
|
|
73
|
-
return [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
type: 'tsx',
|
|
75
|
+
content: newFile,
|
|
76
|
+
meta: {
|
|
77
|
+
isRSPIcon: true
|
|
78
|
+
}
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
+
];
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
function template(asset, svg) {
|
|
84
85
|
let normalizedPath = asset.filePath.replaceAll('\\', '/');
|
|
85
|
-
let fn =
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
let fn =
|
|
87
|
+
asset.pipeline === 'illustration' ||
|
|
88
|
+
normalizedPath.includes('@react-spectrum/s2/spectrum-illustrations')
|
|
89
|
+
? 'createIllustration'
|
|
90
|
+
: 'createIcon';
|
|
91
|
+
return `"use client";
|
|
88
92
|
import {${fn}} from '${normalizedPath.includes('@react-spectrum/s2') ? '~/src/Icon' : '@react-spectrum/s2'}';
|
|
89
93
|
|
|
90
94
|
${svg.replace('import { SVGProps } from "react";', '')}
|
|
91
95
|
|
|
92
96
|
export default /*#__PURE__*/ ${fn}(ForwardRef);
|
|
93
|
-
|
|
94
|
-
);
|
|
97
|
+
`;
|
|
95
98
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/parcel-transformer-s2-icon",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
8
|
+
},
|
|
4
9
|
"main": "IconTransformer.js",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
7
12
|
},
|
|
8
13
|
"dependencies": {
|
|
9
|
-
"@adobe/spectrum-tokens": "
|
|
14
|
+
"@adobe/spectrum-tokens": "14.0.0",
|
|
10
15
|
"@parcel/plugin": "^2.0.0",
|
|
11
16
|
"@svgr/core": "^8.1.0",
|
|
12
17
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
@@ -16,16 +21,11 @@
|
|
|
16
21
|
"devDependencies": {
|
|
17
22
|
"prettier": "^3.3.3"
|
|
18
23
|
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"parcel": "^2.0.0"
|
|
26
|
+
},
|
|
19
27
|
"rsp": {
|
|
20
28
|
"type": "cli"
|
|
21
29
|
},
|
|
22
|
-
"
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/adobe/react-spectrum"
|
|
26
|
-
},
|
|
27
|
-
"publishConfig": {
|
|
28
|
-
"access": "public"
|
|
29
|
-
},
|
|
30
|
-
"gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
|
|
30
|
+
"gitHead": "3577a20859b9585a000010c720f6ee39c1c588cc"
|
|
31
31
|
}
|