@atlaskit/icon 31.0.0 → 32.0.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/CHANGELOG.md +18 -0
- package/afm-cc/tsconfig.json +0 -1
- package/afm-jira/tsconfig.json +3 -6
- package/afm-products/tsconfig.json +0 -1
- package/codemods/__tests__/icon-spacing-to-box-primitive.test.tsx +320 -0
- package/codemods/icon-spacing-to-box-primitive/index.tsx +419 -0
- package/dist/cjs/components/icon-new.js +1 -1
- package/dist/cjs/components/icon-tile/icon-tile-new.js +1 -1
- package/dist/cjs/components/icon-tile/icon-tile-old.js +1 -1
- package/dist/cjs/components/icon.js +1 -1
- package/dist/cjs/components/skeleton.js +1 -1
- package/dist/cjs/components/svg.js +1 -1
- package/dist/es2019/components/icon-new.js +1 -1
- package/dist/es2019/components/icon-tile/icon-tile-new.js +1 -1
- package/dist/es2019/components/icon-tile/icon-tile-old.js +1 -1
- package/dist/es2019/components/icon.js +1 -1
- package/dist/es2019/components/skeleton.js +1 -1
- package/dist/es2019/components/svg.js +1 -1
- package/dist/esm/components/icon-new.js +1 -1
- package/dist/esm/components/icon-tile/icon-tile-new.js +1 -1
- package/dist/esm/components/icon-tile/icon-tile-old.js +1 -1
- package/dist/esm/components/icon.js +1 -1
- package/dist/esm/components/skeleton.js +1 -1
- package/dist/esm/components/svg.js +1 -1
- package/dist/types/components/icon-new.d.ts +1 -1
- package/dist/types/components/icon.d.ts +1 -1
- package/dist/types-ts4.5/components/icon-new.d.ts +1 -1
- package/dist/types-ts4.5/components/icon.d.ts +1 -1
- package/docs/ai/icon-instructions.md +25 -19
- package/package.json +8 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/icon
|
|
2
2
|
|
|
3
|
+
## 32.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a788a4cabea12`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a788a4cabea12) -
|
|
8
|
+
Add codemod to migrate icon spacing prop to Box primitive
|
|
9
|
+
|
|
10
|
+
## 32.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- [`f3af0f1353dd5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f3af0f1353dd5) -
|
|
15
|
+
Remove legacy icon glyphs and oldName prop support from metadata core.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 31.0.0
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../../../tsconfig.local-consumption.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
4
|
"target": "es5",
|
|
6
5
|
"outDir": "../../../../../jira/tsDist/@atlaskit__icon/app",
|
|
7
6
|
"rootDir": "../",
|
|
8
7
|
"composite": true,
|
|
9
|
-
"noCheck": true
|
|
8
|
+
"noCheck": true,
|
|
9
|
+
"isolatedDeclarations": true
|
|
10
10
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
"../src/**/*.ts",
|
|
13
|
-
"../src/**/*.tsx"
|
|
14
|
-
],
|
|
11
|
+
"include": ["../src/**/*.ts", "../src/**/*.tsx"],
|
|
15
12
|
"exclude": [
|
|
16
13
|
"../src/**/__tests__/*",
|
|
17
14
|
"../src/**/*.test.*",
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import transformer from '../icon-spacing-to-box-primitive';
|
|
2
|
+
|
|
3
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
+
|
|
5
|
+
const space050Block = `const iconSpacingStyles = cssMap({
|
|
6
|
+
space050: {
|
|
7
|
+
paddingTop: token("space.050"),
|
|
8
|
+
paddingRight: token("space.050"),
|
|
9
|
+
paddingBottom: token("space.050"),
|
|
10
|
+
paddingLeft: token("space.050")
|
|
11
|
+
}
|
|
12
|
+
});`;
|
|
13
|
+
|
|
14
|
+
const space075Block = `const iconSpacingStyles = cssMap({
|
|
15
|
+
space075: {
|
|
16
|
+
paddingTop: token("space.075"),
|
|
17
|
+
paddingRight: token("space.075"),
|
|
18
|
+
paddingBottom: token("space.075"),
|
|
19
|
+
paddingLeft: token("space.075")
|
|
20
|
+
}
|
|
21
|
+
});`;
|
|
22
|
+
|
|
23
|
+
const space025Block = `const iconSpacingStyles = cssMap({
|
|
24
|
+
space025: {
|
|
25
|
+
paddingTop: token("space.025"),
|
|
26
|
+
paddingRight: token("space.025"),
|
|
27
|
+
paddingBottom: token("space.025"),
|
|
28
|
+
paddingLeft: token("space.025")
|
|
29
|
+
}
|
|
30
|
+
});`;
|
|
31
|
+
|
|
32
|
+
describe('Migrate spacing prop to Box primitive', () => {
|
|
33
|
+
defineInlineTest(
|
|
34
|
+
{ default: transformer, parser: 'tsx' },
|
|
35
|
+
{},
|
|
36
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
37
|
+
const App = () => <AddIcon label="" spacing="none" />;`,
|
|
38
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
39
|
+
const App = () => <AddIcon label="" />;`,
|
|
40
|
+
'should remove spacing="none" with no Box wrap',
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
defineInlineTest(
|
|
44
|
+
{ default: transformer, parser: 'tsx' },
|
|
45
|
+
{},
|
|
46
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
47
|
+
const App = () => <AddIcon label="" spacing="spacious" />;`,
|
|
48
|
+
`import { cssMap } from "@atlaskit/css";
|
|
49
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
50
|
+
import { token } from "@atlaskit/tokens";
|
|
51
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
52
|
+
|
|
53
|
+
${space050Block}
|
|
54
|
+
|
|
55
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
56
|
+
'should wrap medium icon with spacing="spacious" in Box with space050',
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
defineInlineTest(
|
|
60
|
+
{ default: transformer, parser: 'tsx' },
|
|
61
|
+
{},
|
|
62
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
63
|
+
const App = () => <AddIcon label="" spacing="compact" />;`,
|
|
64
|
+
`import { cssMap } from "@atlaskit/css";
|
|
65
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
66
|
+
import { token } from "@atlaskit/tokens";
|
|
67
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
68
|
+
|
|
69
|
+
${space050Block}
|
|
70
|
+
|
|
71
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
72
|
+
'should wrap medium icon with spacing="compact" in Box with space050',
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
defineInlineTest(
|
|
76
|
+
{ default: transformer, parser: 'tsx' },
|
|
77
|
+
{},
|
|
78
|
+
`import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
79
|
+
const App = () => <ChevronRightIcon label="" size="small" spacing="spacious" />;`,
|
|
80
|
+
`import { cssMap } from "@atlaskit/css";
|
|
81
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
82
|
+
import { token } from "@atlaskit/tokens";
|
|
83
|
+
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
84
|
+
|
|
85
|
+
${space075Block}
|
|
86
|
+
|
|
87
|
+
const App = () => <Box xcss={iconSpacingStyles.space075}><ChevronRightIcon label="" size="small" /></Box>;`,
|
|
88
|
+
'should wrap small icon with spacing="spacious" in Box with space075',
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
defineInlineTest(
|
|
92
|
+
{ default: transformer, parser: 'tsx' },
|
|
93
|
+
{},
|
|
94
|
+
`import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
95
|
+
const App = () => <ChevronRightIcon label="" size="small" spacing="compact" />;`,
|
|
96
|
+
`import { cssMap } from "@atlaskit/css";
|
|
97
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
98
|
+
import { token } from "@atlaskit/tokens";
|
|
99
|
+
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
100
|
+
|
|
101
|
+
${space025Block}
|
|
102
|
+
|
|
103
|
+
const App = () => <Box xcss={iconSpacingStyles.space025}><ChevronRightIcon label="" size="small" /></Box>;`,
|
|
104
|
+
'should wrap small icon with spacing="compact" in Box with space025',
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
defineInlineTest(
|
|
108
|
+
{ default: transformer, parser: 'tsx' },
|
|
109
|
+
{},
|
|
110
|
+
`import MoreIcon from '@atlaskit/icon/core/more';
|
|
111
|
+
const App = () => <Button iconBefore={<MoreIcon label="" spacing="spacious" />} />;`,
|
|
112
|
+
`import { cssMap } from "@atlaskit/css";
|
|
113
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
114
|
+
import { token } from "@atlaskit/tokens";
|
|
115
|
+
import MoreIcon from '@atlaskit/icon/core/more';
|
|
116
|
+
|
|
117
|
+
${space050Block}
|
|
118
|
+
|
|
119
|
+
const App = () => <Button iconBefore={<Box xcss={iconSpacingStyles.space050}><MoreIcon label="" /></Box>} />;`,
|
|
120
|
+
'should wrap icon with spacing prop inside a component slot',
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
defineInlineTest(
|
|
124
|
+
{ default: transformer, parser: 'tsx' },
|
|
125
|
+
{},
|
|
126
|
+
`import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
127
|
+
const App = () => <DropdownMenu iconAfter={<ChevronDownIcon label="" size="small" spacing="spacious" />} />;`,
|
|
128
|
+
`import { cssMap } from "@atlaskit/css";
|
|
129
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
130
|
+
import { token } from "@atlaskit/tokens";
|
|
131
|
+
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
132
|
+
|
|
133
|
+
${space075Block}
|
|
134
|
+
|
|
135
|
+
const App = () => <DropdownMenu iconAfter={<Box xcss={iconSpacingStyles.space075}><ChevronDownIcon label="" size="small" /></Box>} />;`,
|
|
136
|
+
'should wrap small icon with spacing prop inside a component slot',
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
defineInlineTest(
|
|
140
|
+
{ default: transformer, parser: 'tsx' },
|
|
141
|
+
{},
|
|
142
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
143
|
+
const App = (props: any) => <AddIcon {...props} spacing="spacious" label="" />;`,
|
|
144
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
145
|
+
const App = (props: any) => // eslint-disable-next-line @atlaskit/design-system/no-icon-spacing-prop -- TODO: Manually migrate spacing prop to Box primitive (spread props detected)
|
|
146
|
+
<AddIcon {...props} spacing="spacious" label="" />;`,
|
|
147
|
+
'should add eslint-disable comment inline and skip when spread props are present',
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
defineInlineTest(
|
|
151
|
+
{ default: transformer, parser: 'tsx' },
|
|
152
|
+
{},
|
|
153
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
154
|
+
const App = ({ spacing }: any) => <AddIcon label="" spacing={spacing} />;`,
|
|
155
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
156
|
+
const App = ({ spacing }: any) => // eslint-disable-next-line @atlaskit/design-system/no-icon-spacing-prop -- TODO: Manually migrate spacing prop to Box primitive (dynamic spacing value detected)
|
|
157
|
+
<AddIcon label="" spacing={spacing} />;`,
|
|
158
|
+
'should add eslint-disable comment inline and skip when spacing is a dynamic expression',
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
defineInlineTest(
|
|
162
|
+
{ default: transformer, parser: 'tsx' },
|
|
163
|
+
{},
|
|
164
|
+
`import SomeComponent from 'some-library';
|
|
165
|
+
const App = () => <SomeComponent spacing="spacious" />;`,
|
|
166
|
+
`import SomeComponent from 'some-library';
|
|
167
|
+
const App = () => <SomeComponent spacing="spacious" />;`,
|
|
168
|
+
'should not transform non-icon components with spacing prop',
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
defineInlineTest(
|
|
172
|
+
{ default: transformer, parser: 'tsx' },
|
|
173
|
+
{},
|
|
174
|
+
`import AddIcon from '@atlaskit/icon/core/add';
|
|
175
|
+
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
176
|
+
|
|
177
|
+
const App = () => (
|
|
178
|
+
<>
|
|
179
|
+
<AddIcon label="" spacing="spacious" />
|
|
180
|
+
<ChevronRightIcon label="" size="small" spacing="spacious" />
|
|
181
|
+
<AddIcon label="" spacing="none" />
|
|
182
|
+
</>
|
|
183
|
+
);`,
|
|
184
|
+
`import { cssMap } from "@atlaskit/css";
|
|
185
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
186
|
+
import { token } from "@atlaskit/tokens";
|
|
187
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
188
|
+
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
189
|
+
|
|
190
|
+
const iconSpacingStyles = cssMap({
|
|
191
|
+
space050: {
|
|
192
|
+
paddingTop: token("space.050"),
|
|
193
|
+
paddingRight: token("space.050"),
|
|
194
|
+
paddingBottom: token("space.050"),
|
|
195
|
+
paddingLeft: token("space.050")
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
space075: {
|
|
199
|
+
paddingTop: token("space.075"),
|
|
200
|
+
paddingRight: token("space.075"),
|
|
201
|
+
paddingBottom: token("space.075"),
|
|
202
|
+
paddingLeft: token("space.075")
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const App = () => (
|
|
207
|
+
<>
|
|
208
|
+
<Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>
|
|
209
|
+
<Box xcss={iconSpacingStyles.space075}><ChevronRightIcon label="" size="small" /></Box>
|
|
210
|
+
<AddIcon label="" />
|
|
211
|
+
</>
|
|
212
|
+
);`,
|
|
213
|
+
'should handle multiple icons in the same file with a single cssMap and deduped keys',
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
defineInlineTest(
|
|
217
|
+
{ default: transformer, parser: 'tsx' },
|
|
218
|
+
{},
|
|
219
|
+
`import { Inline } from '@atlaskit/primitives/compiled';
|
|
220
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
221
|
+
const App = () => <AddIcon label="" spacing="spacious" />;`,
|
|
222
|
+
`import { cssMap } from "@atlaskit/css";
|
|
223
|
+
import { token } from "@atlaskit/tokens";
|
|
224
|
+
import { Inline, Box } from '@atlaskit/primitives/compiled';
|
|
225
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
226
|
+
|
|
227
|
+
${space050Block}
|
|
228
|
+
|
|
229
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
230
|
+
'should add Box to existing @atlaskit/primitives/compiled import',
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
defineInlineTest(
|
|
234
|
+
{ default: transformer, parser: 'tsx' },
|
|
235
|
+
{},
|
|
236
|
+
`import { Box } from '@atlaskit/primitives';
|
|
237
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
238
|
+
const App = () => <AddIcon label="" spacing="spacious" />;`,
|
|
239
|
+
`import { cssMap } from "@atlaskit/css";
|
|
240
|
+
import { token } from "@atlaskit/tokens";
|
|
241
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
242
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
243
|
+
|
|
244
|
+
${space050Block}
|
|
245
|
+
|
|
246
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
247
|
+
'should update @atlaskit/primitives to @atlaskit/primitives/compiled',
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
defineInlineTest(
|
|
251
|
+
{ default: transformer, parser: 'tsx' },
|
|
252
|
+
{},
|
|
253
|
+
`import { Box } from '@atlaskit/primitives/compiled';
|
|
254
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
255
|
+
const App = () => <AddIcon label="" spacing="spacious" />;`,
|
|
256
|
+
`import { cssMap } from "@atlaskit/css";
|
|
257
|
+
import { token } from "@atlaskit/tokens";
|
|
258
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
259
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
260
|
+
|
|
261
|
+
${space050Block}
|
|
262
|
+
|
|
263
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
264
|
+
'should keep existing Box import from compiled unchanged',
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
defineInlineTest(
|
|
268
|
+
{ default: transformer, parser: 'tsx' },
|
|
269
|
+
{},
|
|
270
|
+
`import { Inline } from '@atlaskit/primitives';
|
|
271
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
272
|
+
const App = () => <AddIcon label="" spacing="spacious" />;`,
|
|
273
|
+
`import { cssMap } from "@atlaskit/css";
|
|
274
|
+
import { token } from "@atlaskit/tokens";
|
|
275
|
+
import { Inline, Box } from "@atlaskit/primitives/compiled";
|
|
276
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
277
|
+
|
|
278
|
+
${space050Block}
|
|
279
|
+
|
|
280
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><AddIcon label="" /></Box>;`,
|
|
281
|
+
'should add Box and update @atlaskit/primitives to @atlaskit/primitives/compiled',
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
defineInlineTest(
|
|
285
|
+
{ default: transformer, parser: 'tsx' },
|
|
286
|
+
{},
|
|
287
|
+
`import MoreIcon from '@atlaskit/icon/core/more';
|
|
288
|
+
|
|
289
|
+
const IconBefore = (
|
|
290
|
+
<MoreIcon spacing="spacious" label="More" />
|
|
291
|
+
);`,
|
|
292
|
+
`import { cssMap } from "@atlaskit/css";
|
|
293
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
294
|
+
import { token } from "@atlaskit/tokens";
|
|
295
|
+
import MoreIcon from '@atlaskit/icon/core/more';
|
|
296
|
+
|
|
297
|
+
${space050Block}
|
|
298
|
+
|
|
299
|
+
const IconBefore = (
|
|
300
|
+
<Box xcss={iconSpacingStyles.space050}><MoreIcon label="More" /></Box>
|
|
301
|
+
);`,
|
|
302
|
+
'should not produce extra parentheses inside Box when icon is in a parenthesized expression',
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
defineInlineTest(
|
|
306
|
+
{ default: transformer, parser: 'tsx' },
|
|
307
|
+
{},
|
|
308
|
+
`import BitbucketBranchIcon from '@atlaskit/icon-lab/core/bitbucket-branch';
|
|
309
|
+
const App = () => <BitbucketBranchIcon label="" spacing="spacious" />;`,
|
|
310
|
+
`import { cssMap } from "@atlaskit/css";
|
|
311
|
+
import { Box } from "@atlaskit/primitives/compiled";
|
|
312
|
+
import { token } from "@atlaskit/tokens";
|
|
313
|
+
import BitbucketBranchIcon from '@atlaskit/icon-lab/core/bitbucket-branch';
|
|
314
|
+
|
|
315
|
+
${space050Block}
|
|
316
|
+
|
|
317
|
+
const App = () => <Box xcss={iconSpacingStyles.space050}><BitbucketBranchIcon label="" /></Box>;`,
|
|
318
|
+
'should migrate icon-lab icons',
|
|
319
|
+
);
|
|
320
|
+
});
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import type { API, ASTPath, Collection, default as core, FileInfo, JSXElement } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
const ICON_PACKAGES = ['@atlaskit/icon/core', '@atlaskit/icon-lab/core'];
|
|
4
|
+
const BOX_COMPILED_PACKAGE = '@atlaskit/primitives/compiled';
|
|
5
|
+
const BOX_NON_COMPILED_PACKAGE = '@atlaskit/primitives';
|
|
6
|
+
const TOKEN_PACKAGE = '@atlaskit/tokens';
|
|
7
|
+
const CSS_PACKAGE = '@atlaskit/css';
|
|
8
|
+
const CSSMAP_VARIABLE_NAME = 'iconSpacingStyles';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Spacing → Box padding token mapping.
|
|
12
|
+
*
|
|
13
|
+
* medium/unspecified:
|
|
14
|
+
* compact → space.050 (4px)
|
|
15
|
+
* spacious → space.050 (4px)
|
|
16
|
+
*
|
|
17
|
+
* small:
|
|
18
|
+
* compact → space.025 (2px) — NOTE: 2.66px doesn't map cleanly; confirm with designer
|
|
19
|
+
* spacious → space.075 (6px)
|
|
20
|
+
*/
|
|
21
|
+
const SPACING_TO_PADDING: Record<string, Record<string, string>> = {
|
|
22
|
+
medium: {
|
|
23
|
+
compact: 'space.050',
|
|
24
|
+
spacious: 'space.050',
|
|
25
|
+
},
|
|
26
|
+
small: {
|
|
27
|
+
compact: 'space.025',
|
|
28
|
+
spacious: 'space.075',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Maps a padding token to a cssMap key name.
|
|
34
|
+
* e.g. 'space.050' → 'space050'
|
|
35
|
+
*/
|
|
36
|
+
function getCssMapKey(paddingToken: string): string {
|
|
37
|
+
return paddingToken.replace('space.', 'space');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getIconImportSpecifiers(j: core.JSCodeshift, source: Collection<any>): string[] {
|
|
41
|
+
const specifiers: string[] = [];
|
|
42
|
+
for (const pkg of ICON_PACKAGES) {
|
|
43
|
+
source
|
|
44
|
+
.find(j.ImportDeclaration)
|
|
45
|
+
.filter(
|
|
46
|
+
(path) =>
|
|
47
|
+
typeof path.node.source.value === 'string' &&
|
|
48
|
+
path.node.source.value.startsWith(pkg),
|
|
49
|
+
)
|
|
50
|
+
.forEach((importDecl) => {
|
|
51
|
+
for (const specifier of importDecl.value.specifiers || []) {
|
|
52
|
+
if (specifier.local?.name) {
|
|
53
|
+
specifiers.push(specifier.local.name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return specifiers;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function ensureNamedImport(j: core.JSCodeshift, specifiers: any[], name: string): void {
|
|
62
|
+
const alreadyImported = specifiers.some(
|
|
63
|
+
(s) => s.type === 'ImportSpecifier' && s.imported?.name === name,
|
|
64
|
+
);
|
|
65
|
+
if (!alreadyImported) {
|
|
66
|
+
specifiers.push(j.importSpecifier(j.identifier(name)));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ensures `Box` is imported from `@atlaskit/primitives/compiled`.
|
|
72
|
+
* - If `/compiled` already exists → add `Box` if missing
|
|
73
|
+
* - If `@atlaskit/primitives` (non-compiled) exists → migrate path to `/compiled`, add `Box`
|
|
74
|
+
* - Otherwise → insert new import
|
|
75
|
+
*/
|
|
76
|
+
function insertBoxImport(j: core.JSCodeshift, source: Collection<any>): void {
|
|
77
|
+
const compiledImports = source
|
|
78
|
+
.find(j.ImportDeclaration)
|
|
79
|
+
.filter((path) => path.node.source.value === BOX_COMPILED_PACKAGE);
|
|
80
|
+
|
|
81
|
+
if (compiledImports.length > 0) {
|
|
82
|
+
compiledImports.forEach((path) => {
|
|
83
|
+
ensureNamedImport(j, path.node.specifiers || [], 'Box');
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const nonCompiledImports = source
|
|
89
|
+
.find(j.ImportDeclaration)
|
|
90
|
+
.filter((path) => path.node.source.value === BOX_NON_COMPILED_PACKAGE);
|
|
91
|
+
|
|
92
|
+
if (nonCompiledImports.length > 0) {
|
|
93
|
+
nonCompiledImports.forEach((path) => {
|
|
94
|
+
path.node.source = j.stringLiteral(BOX_COMPILED_PACKAGE);
|
|
95
|
+
ensureNamedImport(j, path.node.specifiers || [], 'Box');
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const newImport = j.importDeclaration(
|
|
101
|
+
[j.importSpecifier(j.identifier('Box'))],
|
|
102
|
+
j.stringLiteral(BOX_COMPILED_PACKAGE),
|
|
103
|
+
);
|
|
104
|
+
source.get().node.program.body.unshift(newImport);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Ensures `cssMap` is imported from `@atlaskit/css`.
|
|
109
|
+
* Note: `jsx` import and JSX pragma are NOT needed for cssMap — only for cx().
|
|
110
|
+
* - If `@atlaskit/css` already exists → add `cssMap` if missing
|
|
111
|
+
* - Otherwise → insert new import
|
|
112
|
+
*/
|
|
113
|
+
function insertCssMapImport(j: core.JSCodeshift, source: Collection<any>): void {
|
|
114
|
+
const cssImports = source
|
|
115
|
+
.find(j.ImportDeclaration)
|
|
116
|
+
.filter((path) => path.node.source.value === CSS_PACKAGE);
|
|
117
|
+
|
|
118
|
+
if (cssImports.length > 0) {
|
|
119
|
+
cssImports.forEach((path) => {
|
|
120
|
+
ensureNamedImport(j, path.node.specifiers || [], 'cssMap');
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const newImport = j.importDeclaration(
|
|
126
|
+
[j.importSpecifier(j.identifier('cssMap'))],
|
|
127
|
+
j.stringLiteral(CSS_PACKAGE),
|
|
128
|
+
);
|
|
129
|
+
source.get().node.program.body.unshift(newImport);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Ensures `token` is imported from `@atlaskit/tokens`.
|
|
134
|
+
*/
|
|
135
|
+
function insertTokenImport(j: core.JSCodeshift, source: Collection<any>): void {
|
|
136
|
+
const tokenImports = source
|
|
137
|
+
.find(j.ImportDeclaration)
|
|
138
|
+
.filter((path) => path.node.source.value === TOKEN_PACKAGE);
|
|
139
|
+
|
|
140
|
+
if (tokenImports.length > 0) {
|
|
141
|
+
tokenImports.forEach((path) => {
|
|
142
|
+
ensureNamedImport(j, path.node.specifiers || [], 'token');
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const newImport = j.importDeclaration(
|
|
148
|
+
[j.importSpecifier(j.identifier('token'))],
|
|
149
|
+
j.stringLiteral(TOKEN_PACKAGE),
|
|
150
|
+
);
|
|
151
|
+
source.get().node.program.body.unshift(newImport);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Inserts or updates a single `const iconSpacingStyles = cssMap({...})` declaration
|
|
156
|
+
* at module level (after the last import), with one key per padding token used.
|
|
157
|
+
*
|
|
158
|
+
* If the variable already exists, adds missing keys to the existing cssMap object.
|
|
159
|
+
*/
|
|
160
|
+
function insertOrUpdateCssMapVariable(
|
|
161
|
+
j: core.JSCodeshift,
|
|
162
|
+
source: Collection<any>,
|
|
163
|
+
paddingTokens: Set<string>,
|
|
164
|
+
): void {
|
|
165
|
+
// Check if iconSpacingStyles already exists
|
|
166
|
+
const existing = source.find(j.VariableDeclaration).filter((path) => {
|
|
167
|
+
const decl = path.node.declarations[0];
|
|
168
|
+
return (
|
|
169
|
+
decl?.type === 'VariableDeclarator' &&
|
|
170
|
+
(decl.id as any)?.name === CSSMAP_VARIABLE_NAME
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (existing.length > 0) {
|
|
175
|
+
// Add missing keys to the existing cssMap object
|
|
176
|
+
existing.forEach((path) => {
|
|
177
|
+
const decl = path.node.declarations[0] as any;
|
|
178
|
+
const cssMapCall = decl?.init;
|
|
179
|
+
if (cssMapCall?.type !== 'CallExpression') return;
|
|
180
|
+
const objExpr = cssMapCall.arguments[0];
|
|
181
|
+
if (objExpr?.type !== 'ObjectExpression') return;
|
|
182
|
+
|
|
183
|
+
const existingKeys = new Set(
|
|
184
|
+
objExpr.properties
|
|
185
|
+
.filter((p: any) => p.key)
|
|
186
|
+
.map((p: any) => p.key.name || p.key.value),
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
for (const paddingToken of Array.from(paddingTokens).sort()) {
|
|
190
|
+
const key = getCssMapKey(paddingToken);
|
|
191
|
+
if (!existingKeys.has(key)) {
|
|
192
|
+
const tokenCall = () =>
|
|
193
|
+
j.callExpression(j.identifier('token'), [j.stringLiteral(paddingToken)]);
|
|
194
|
+
objExpr.properties.push(
|
|
195
|
+
j.objectProperty(
|
|
196
|
+
j.identifier(key),
|
|
197
|
+
j.objectExpression([
|
|
198
|
+
j.objectProperty(j.identifier('paddingTop'), tokenCall()),
|
|
199
|
+
j.objectProperty(j.identifier('paddingRight'), tokenCall()),
|
|
200
|
+
j.objectProperty(j.identifier('paddingBottom'), tokenCall()),
|
|
201
|
+
j.objectProperty(j.identifier('paddingLeft'), tokenCall()),
|
|
202
|
+
]),
|
|
203
|
+
),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Build new cssMap variable declaration with all keys
|
|
212
|
+
const properties = Array.from(paddingTokens)
|
|
213
|
+
.sort()
|
|
214
|
+
.map((paddingToken) => {
|
|
215
|
+
const tokenCall = () =>
|
|
216
|
+
j.callExpression(j.identifier('token'), [j.stringLiteral(paddingToken)]);
|
|
217
|
+
return j.objectProperty(
|
|
218
|
+
j.identifier(getCssMapKey(paddingToken)),
|
|
219
|
+
j.objectExpression([
|
|
220
|
+
j.objectProperty(j.identifier('paddingTop'), tokenCall()),
|
|
221
|
+
j.objectProperty(j.identifier('paddingRight'), tokenCall()),
|
|
222
|
+
j.objectProperty(j.identifier('paddingBottom'), tokenCall()),
|
|
223
|
+
j.objectProperty(j.identifier('paddingLeft'), tokenCall()),
|
|
224
|
+
]),
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const cssMapCall = j.callExpression(j.identifier('cssMap'), [
|
|
229
|
+
j.objectExpression(properties),
|
|
230
|
+
]);
|
|
231
|
+
|
|
232
|
+
const variableDecl = j.variableDeclaration('const', [
|
|
233
|
+
j.variableDeclarator(j.identifier(CSSMAP_VARIABLE_NAME), cssMapCall),
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
// Insert after the last import
|
|
237
|
+
const body = source.get().node.program.body;
|
|
238
|
+
let insertIndex = 0;
|
|
239
|
+
for (let i = body.length - 1; i >= 0; i--) {
|
|
240
|
+
if (body[i].type === 'ImportDeclaration') {
|
|
241
|
+
insertIndex = i + 1;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
body.splice(insertIndex, 0, variableDecl);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Wraps a JSXElement in <Box xcss={iconSpacingStyles.spaceXXX}>...</Box>.
|
|
250
|
+
*/
|
|
251
|
+
function wrapWithBox(j: core.JSCodeshift, iconElement: JSXElement, paddingToken: string) {
|
|
252
|
+
const key = getCssMapKey(paddingToken);
|
|
253
|
+
return j.jsxElement(
|
|
254
|
+
j.jsxOpeningElement(j.jsxIdentifier('Box'), [
|
|
255
|
+
j.jsxAttribute(
|
|
256
|
+
j.jsxIdentifier('xcss'),
|
|
257
|
+
j.jsxExpressionContainer(
|
|
258
|
+
j.memberExpression(
|
|
259
|
+
j.identifier(CSSMAP_VARIABLE_NAME),
|
|
260
|
+
j.identifier(key),
|
|
261
|
+
),
|
|
262
|
+
),
|
|
263
|
+
),
|
|
264
|
+
]),
|
|
265
|
+
j.jsxClosingElement(j.jsxIdentifier('Box')),
|
|
266
|
+
[iconElement],
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function addEslintDisableComment(j: core.JSCodeshift, path: ASTPath<JSXElement>, reason: string): void {
|
|
271
|
+
const comment = j.line(
|
|
272
|
+
` eslint-disable-next-line @atlaskit/design-system/no-icon-spacing-prop -- TODO: ${reason}`,
|
|
273
|
+
);
|
|
274
|
+
const node = path.value as any;
|
|
275
|
+
node.comments = [comment, ...(node.comments || [])];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function getStaticPropValue(attributes: any[], propName: string): string | null {
|
|
279
|
+
const prop = attributes.find(
|
|
280
|
+
(attr: any) => attr.type === 'JSXAttribute' && attr.name?.name === propName,
|
|
281
|
+
);
|
|
282
|
+
if (!prop) return null;
|
|
283
|
+
if (prop.value?.type === 'StringLiteral' || prop.value?.type === 'Literal') {
|
|
284
|
+
return prop.value.value;
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function hasSpreadAttributes(attributes: any[]): boolean {
|
|
290
|
+
return attributes.some((attr: any) => attr.type === 'JSXSpreadAttribute');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function isSpacingDynamic(attributes: any[]): boolean {
|
|
294
|
+
const prop = attributes.find(
|
|
295
|
+
(attr: any) => attr.type === 'JSXAttribute' && attr.name?.name === 'spacing',
|
|
296
|
+
);
|
|
297
|
+
if (!prop) return false;
|
|
298
|
+
return prop.value?.type !== 'StringLiteral' && prop.value?.type !== 'Literal';
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function removeSpacingProp(attributes: any[]): any[] {
|
|
302
|
+
return attributes.filter(
|
|
303
|
+
(attr: any) => !(attr.type === 'JSXAttribute' && attr.name?.name === 'spacing'),
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function replaceWithWrapped(
|
|
308
|
+
j: core.JSCodeshift,
|
|
309
|
+
path: ASTPath<JSXElement>,
|
|
310
|
+
wrappedElement: JSXElement,
|
|
311
|
+
): void {
|
|
312
|
+
const node = path.value as any;
|
|
313
|
+
|
|
314
|
+
const leadingComments = node.comments?.filter((c: any) => c.leading) || [];
|
|
315
|
+
if (leadingComments.length) {
|
|
316
|
+
node.comments = node.comments?.filter((c: any) => !c.leading);
|
|
317
|
+
(wrappedElement as any).comments = [
|
|
318
|
+
...leadingComments,
|
|
319
|
+
...((wrappedElement as any).comments || []),
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const parentNode = path.parent?.node;
|
|
324
|
+
const isInsideJSX =
|
|
325
|
+
parentNode?.type === 'JSXElement' ||
|
|
326
|
+
parentNode?.type === 'JSXFragment' ||
|
|
327
|
+
parentNode?.type === 'JSXExpressionContainer';
|
|
328
|
+
|
|
329
|
+
const isParenthesized =
|
|
330
|
+
!isInsideJSX &&
|
|
331
|
+
parentNode &&
|
|
332
|
+
(parentNode.type === 'ParenthesizedExpression' || parentNode.extra?.parenthesized);
|
|
333
|
+
|
|
334
|
+
if (isParenthesized) {
|
|
335
|
+
j(path.parent).replaceWith(wrappedElement);
|
|
336
|
+
} else {
|
|
337
|
+
j(path).replaceWith(wrappedElement);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export default function transformer(file: FileInfo, api: API): string {
|
|
342
|
+
const j = api.jscodeshift;
|
|
343
|
+
const source = j(file.source);
|
|
344
|
+
|
|
345
|
+
const iconSpecifiers = getIconImportSpecifiers(j, source);
|
|
346
|
+
if (!iconSpecifiers.length) {
|
|
347
|
+
return file.source;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const iconJSXWithSpacing = source
|
|
351
|
+
.find(j.JSXElement)
|
|
352
|
+
.filter((path) => {
|
|
353
|
+
const name = path.value.openingElement.name;
|
|
354
|
+
return name.type === 'JSXIdentifier' && iconSpecifiers.includes(name.name);
|
|
355
|
+
})
|
|
356
|
+
.filter((path) =>
|
|
357
|
+
(path.value.openingElement.attributes || []).some(
|
|
358
|
+
(attr: any) => attr.type === 'JSXAttribute' && attr.name?.name === 'spacing',
|
|
359
|
+
),
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
if (!iconJSXWithSpacing.length) {
|
|
363
|
+
return file.source;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const paddingTokensUsed = new Set<string>();
|
|
367
|
+
let needsBoxImport = false;
|
|
368
|
+
|
|
369
|
+
iconJSXWithSpacing.forEach((path) => {
|
|
370
|
+
const attrs = path.value.openingElement.attributes || [];
|
|
371
|
+
|
|
372
|
+
if (hasSpreadAttributes(attrs)) {
|
|
373
|
+
addEslintDisableComment(j, path, 'Manually migrate spacing prop to Box primitive (spread props detected)');
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (isSpacingDynamic(attrs)) {
|
|
378
|
+
addEslintDisableComment(j, path, 'Manually migrate spacing prop to Box primitive (dynamic spacing value detected)');
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const spacingValue = getStaticPropValue(attrs, 'spacing')!;
|
|
383
|
+
path.value.openingElement.attributes = removeSpacingProp(attrs);
|
|
384
|
+
|
|
385
|
+
if (spacingValue === 'none') {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const sizeValue = getStaticPropValue(attrs, 'size') ?? 'medium';
|
|
390
|
+
const sizeKey = sizeValue === 'small' ? 'small' : 'medium';
|
|
391
|
+
const paddingToken = SPACING_TO_PADDING[sizeKey]?.[spacingValue];
|
|
392
|
+
|
|
393
|
+
if (!paddingToken) {
|
|
394
|
+
addEslintDisableComment(j, path, `Manually migrate spacing="${spacingValue}" prop to Box primitive (unknown spacing value)`);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if ((path.value as any).extra) {
|
|
399
|
+
(path.value as any).extra.parenthesized = false;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const wrappedElement = wrapWithBox(j, path.value, paddingToken);
|
|
403
|
+
replaceWithWrapped(j, path, wrappedElement);
|
|
404
|
+
|
|
405
|
+
needsBoxImport = true;
|
|
406
|
+
paddingTokensUsed.add(paddingToken);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
if (needsBoxImport) {
|
|
410
|
+
// Insert in reverse order since each unshift prepends — last inserted appears first
|
|
411
|
+
// Desired order: @atlaskit/css, @atlaskit/primitives/compiled, @atlaskit/tokens
|
|
412
|
+
insertTokenImport(j, source);
|
|
413
|
+
insertBoxImport(j, source);
|
|
414
|
+
insertCssMapImport(j, source);
|
|
415
|
+
insertOrUpdateCssMapVariable(j, source, paddingTokensUsed);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return source.toSource();
|
|
419
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* icon.tsx generated by @compiled/babel-plugin v0.
|
|
1
|
+
/* icon.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import "./icon.compiled.css";
|
|
@@ -17,5 +17,5 @@ export type InternalIconPropsNew = UNSAFE_NewGlyphProps & {
|
|
|
17
17
|
*
|
|
18
18
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
19
19
|
*/
|
|
20
|
-
export declare const Icon: import(
|
|
20
|
+
export declare const Icon: import('react').NamedExoticComponent<import('../types').UNSAFE_NewCoreGlyphProps>;
|
|
21
21
|
export default Icon;
|
|
@@ -8,5 +8,5 @@ import type { IconProps } from '../types';
|
|
|
8
8
|
*
|
|
9
9
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
10
10
|
*/
|
|
11
|
-
export declare const Icon: import(
|
|
11
|
+
export declare const Icon: import('react').NamedExoticComponent<IconProps>;
|
|
12
12
|
export default Icon;
|
|
@@ -17,5 +17,5 @@ export type InternalIconPropsNew = UNSAFE_NewGlyphProps & {
|
|
|
17
17
|
*
|
|
18
18
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
19
19
|
*/
|
|
20
|
-
export declare const Icon: import(
|
|
20
|
+
export declare const Icon: import('react').NamedExoticComponent<import('../types').UNSAFE_NewCoreGlyphProps>;
|
|
21
21
|
export default Icon;
|
|
@@ -8,5 +8,5 @@ import type { IconProps } from '../types';
|
|
|
8
8
|
*
|
|
9
9
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
10
10
|
*/
|
|
11
|
-
export declare const Icon: import(
|
|
11
|
+
export declare const Icon: import('react').NamedExoticComponent<IconProps>;
|
|
12
12
|
export default Icon;
|
|
@@ -79,7 +79,7 @@ in `elemBefore`. This applies to `LinkMenuItem`, `ButtonMenuItem` and `FlyoutMen
|
|
|
79
79
|
For navigation links to different pages/sections:
|
|
80
80
|
|
|
81
81
|
```tsx
|
|
82
|
-
import { LinkMenuItem } from '@atlaskit/
|
|
82
|
+
import { LinkMenuItem } from '@atlaskit/side-nav-items/link-menu-item';
|
|
83
83
|
|
|
84
84
|
<LinkMenuItem
|
|
85
85
|
href="/dashboard"
|
|
@@ -95,7 +95,7 @@ import { LinkMenuItem } from '@atlaskit/navigation-system/side-nav-items/link-me
|
|
|
95
95
|
For actions that trigger functionality without navigation:
|
|
96
96
|
|
|
97
97
|
```tsx
|
|
98
|
-
import { ButtonMenuItem } from '@atlaskit/
|
|
98
|
+
import { ButtonMenuItem } from '@atlaskit/side-nav-items/button-menu-item';
|
|
99
99
|
|
|
100
100
|
<ButtonMenuItem
|
|
101
101
|
onClick={handleAction}
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
FlyoutMenuItem,
|
|
116
116
|
FlyoutMenuItemContent,
|
|
117
117
|
FlyoutMenuItemTrigger,
|
|
118
|
-
} from '@atlaskit/
|
|
118
|
+
} from '@atlaskit/side-nav-items/flyout-menu-item';
|
|
119
119
|
|
|
120
120
|
<FlyoutMenuItem>
|
|
121
121
|
<FlyoutMenuItemTrigger elemBefore={<ProjectIcon label="" />}>Projects</FlyoutMenuItemTrigger>
|
|
@@ -133,21 +133,27 @@ import {
|
|
|
133
133
|
Create expandable sections using state with `ButtonMenuItem`:
|
|
134
134
|
|
|
135
135
|
```tsx
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
const styles = cssMap({ spacer: { width: '24px' } });
|
|
137
|
+
|
|
138
|
+
function Component {
|
|
139
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
140
|
+
|
|
141
|
+
return <>
|
|
142
|
+
<ButtonMenuItem
|
|
143
|
+
onClick={() => setIsExpanded(!isExpanded)}
|
|
144
|
+
elemBefore={<SettingsIcon label="" />}
|
|
145
|
+
elemAfter={isExpanded ? <ChevronDownIcon label="" /> : <ChevronRightIcon label="" />}
|
|
146
|
+
>
|
|
147
|
+
Team Settings
|
|
148
|
+
</ButtonMenuItem>
|
|
149
|
+
{
|
|
150
|
+
isExpanded && (
|
|
151
|
+
<LinkMenuItem href="/team/members" elemBefore={<div css={styles.spacer} />}>
|
|
152
|
+
Members
|
|
153
|
+
</LinkMenuItem>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
</>
|
|
151
157
|
}
|
|
152
158
|
```
|
|
153
159
|
|
|
@@ -417,7 +423,7 @@ import COMPONENT_NAME from '@atlaskit/icon/core/ENTRYPOINT';
|
|
|
417
423
|
| ShapesIcon | shapes | shapes, icon, core, objects, whiteboard, asset, graphic |
|
|
418
424
|
| ShareIcon | share | share, icon, core, share, access |
|
|
419
425
|
| ShieldIcon | shield | shield, icon, core, security, secure, safety, defence, protection, guard |
|
|
420
|
-
| ShieldStrikethroughIcon | shield-strikethrough | shield-strikethrough, shieldstrikethrough, icon, core, ️security, secure, safety, defence, protection, guard, strikethrough, classification
|
|
426
|
+
| ShieldStrikethroughIcon | shield-strikethrough | shield-strikethrough, shieldstrikethrough, icon, core, ️security, secure, safety, defence, protection, guard, strikethrough, classification |
|
|
421
427
|
| ShortcutIcon | shortcut | shortcut, export, icon, core, addshortcut, square, plus |
|
|
422
428
|
| ShowMoreHorizontalIcon | show-more-horizontal | show-more-horizontal, showmorehorizontal, icon, core, ellipses, three dots, meatball, more actions |
|
|
423
429
|
| ShowMoreVerticalIcon | show-more-vertical | show-more-vertical, showmorevertical, more, menu, options, kebab-menu, ellipsis-vertical, three-dots, vertical-dots, actions, overflow, settings |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/icon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "32.0.1",
|
|
4
4
|
"description": "An icon is a symbol representing a command, device, directory, or common action.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
38
|
"@atlaskit/tile": "^1.0.0",
|
|
39
|
-
"@atlaskit/tokens": "^11.
|
|
39
|
+
"@atlaskit/tokens": "^11.1.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
|
-
"@compiled/react": "^0.
|
|
41
|
+
"@compiled/react": "^0.20.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^18.2.0"
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"@af/icon-build-process": "workspace:^",
|
|
49
49
|
"@af/integration-testing": "workspace:^",
|
|
50
50
|
"@af/visual-regression": "workspace:^",
|
|
51
|
-
"@atlaskit/button": "^23.
|
|
51
|
+
"@atlaskit/button": "^23.10.0",
|
|
52
52
|
"@atlaskit/code": "^17.4.0",
|
|
53
53
|
"@atlaskit/css": "^0.19.0",
|
|
54
|
-
"@atlaskit/docs": "^11.
|
|
55
|
-
"@atlaskit/form": "^15.
|
|
54
|
+
"@atlaskit/docs": "^11.6.0",
|
|
55
|
+
"@atlaskit/form": "^15.4.0",
|
|
56
56
|
"@atlaskit/heading": "^5.3.0",
|
|
57
57
|
"@atlaskit/icon-file-type": "^7.0.0",
|
|
58
58
|
"@atlaskit/icon-object": "^7.4.0",
|
|
59
59
|
"@atlaskit/link": "^3.3.0",
|
|
60
60
|
"@atlaskit/logo": "^19.10.0",
|
|
61
61
|
"@atlaskit/menu": "^8.4.0",
|
|
62
|
-
"@atlaskit/modal-dialog": "^14.
|
|
62
|
+
"@atlaskit/modal-dialog": "^14.11.0",
|
|
63
63
|
"@atlaskit/primitives": "^18.0.0",
|
|
64
64
|
"@atlaskit/section-message": "^8.12.0",
|
|
65
65
|
"@atlaskit/textfield": "^8.2.0",
|
|
66
|
-
"@atlaskit/theme": "^
|
|
66
|
+
"@atlaskit/theme": "^22.0.0",
|
|
67
67
|
"@atlaskit/toggle": "^15.2.0",
|
|
68
68
|
"@atlaskit/tooltip": "^20.14.0",
|
|
69
69
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
@@ -111,12 +111,6 @@
|
|
|
111
111
|
},
|
|
112
112
|
"homepage": "https://atlassian.design/components/icon/",
|
|
113
113
|
"platform-feature-flags": {
|
|
114
|
-
"platform-visual-refresh-icons": {
|
|
115
|
-
"type": "boolean"
|
|
116
|
-
},
|
|
117
|
-
"platform-visual-refresh-icons-facade-button-fix": {
|
|
118
|
-
"type": "boolean"
|
|
119
|
-
},
|
|
120
114
|
"platform_dst_new_icon_tile": {
|
|
121
115
|
"type": "boolean"
|
|
122
116
|
},
|