@atlaskit/eslint-plugin-ui-styling-standard 0.16.3 → 0.16.5
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 +17 -0
- package/constellation/atlaskit-theme/usage.mdx +74 -55
- package/constellation/convert-props-syntax/usage.mdx +29 -24
- package/constellation/enforce-style-prop/usage.mdx +32 -26
- package/constellation/local-cx-xcss/usage.mdx +27 -15
- package/constellation/no-array-arguments/usage.mdx +12 -9
- package/constellation/no-classname-prop/usage.mdx +13 -5
- package/constellation/no-container-queries/usage.mdx +65 -16
- package/constellation/no-dynamic-styles/usage.mdx +16 -11
- package/constellation/no-exported-styles/usage.mdx +25 -30
- package/constellation/no-global-styles/usage.mdx +4 -3
- package/constellation/no-important-styles/usage.mdx +5 -3
- package/constellation/no-imported-style-values/usage.mdx +30 -27
- package/constellation/no-nested-selectors/usage.mdx +51 -18
- package/constellation/no-styled/usage.mdx +17 -14
- package/constellation/no-unsafe-selectors/usage.mdx +184 -58
- package/constellation/no-unsafe-values/usage.mdx +150 -48
- package/constellation/use-compiled/usage.mdx +8 -8
- package/dist/cjs/rules/no-imported-style-values/index.js +50 -2
- package/dist/es2019/rules/no-imported-style-values/index.js +49 -2
- package/dist/esm/rules/no-imported-style-values/index.js +50 -2
- package/package.json +1 -1
- package/src/rules/atlaskit-theme/README.md +74 -55
- package/src/rules/convert-props-syntax/README.md +29 -24
- package/src/rules/enforce-style-prop/README.md +32 -26
- package/src/rules/local-cx-xcss/README.md +27 -15
- package/src/rules/no-array-arguments/README.md +12 -9
- package/src/rules/no-classname-prop/README.md +13 -5
- package/src/rules/no-container-queries/README.md +65 -16
- package/src/rules/no-dynamic-styles/README.md +16 -11
- package/src/rules/no-exported-styles/README.md +25 -30
- package/src/rules/no-global-styles/README.md +4 -3
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-imported-style-values/README.md +30 -27
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +208 -0
- package/src/rules/no-imported-style-values/index.tsx +51 -4
- package/src/rules/no-nested-selectors/README.md +51 -18
- package/src/rules/no-styled/README.md +17 -14
- package/src/rules/no-unsafe-selectors/README.md +184 -58
- package/src/rules/no-unsafe-values/README.md +150 -48
- package/src/rules/use-compiled/README.md +8 -8
|
@@ -141,6 +141,90 @@ typescriptEslintTester.run(
|
|
|
141
141
|
`,
|
|
142
142
|
options: [],
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
name: 'Imported value in LHS of conditional expression in css prop',
|
|
146
|
+
code: `
|
|
147
|
+
import { css } from '@compiled/react';
|
|
148
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
149
|
+
import { IS_FF_ENABLED } from '../shared';
|
|
150
|
+
|
|
151
|
+
const baseStyles = css({ margin: 0 });
|
|
152
|
+
const styles = css({ color: token('color.text') });
|
|
153
|
+
const stylesFF = css({ color: token('color.text.danger') });
|
|
154
|
+
|
|
155
|
+
const Component = () => (
|
|
156
|
+
<>
|
|
157
|
+
<div css={IS_FF_ENABLED ? stylesFF : styles} />
|
|
158
|
+
<div css={[baseStyles, IS_FF_ENABLED ? stylesFF : styles]} />
|
|
159
|
+
<div css={ff('my-feature-flag') ? stylesFF : styles} />
|
|
160
|
+
<div css={[baseStyles, ff('my-feature-flag') ? stylesFF : styles]} />
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
163
|
+
`,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'Imported value as entire LHS of logical expression in css prop',
|
|
167
|
+
code: `
|
|
168
|
+
import { css } from '@compiled/react';
|
|
169
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
170
|
+
import { IS_FF_ENABLED } from '../shared';
|
|
171
|
+
|
|
172
|
+
const baseStyles = css({ margin: 0 });
|
|
173
|
+
const stylesFF = css({ color: token('color.text.danger') });
|
|
174
|
+
|
|
175
|
+
const Component = () => (
|
|
176
|
+
<>
|
|
177
|
+
<div css={IS_FF_ENABLED && stylesFF} />
|
|
178
|
+
<div css={[baseStyles, IS_FF_ENABLED && stylesFF]} />
|
|
179
|
+
<div css={ff('my-feature-flag') && stylesFF} />
|
|
180
|
+
<div css={[baseStyles, ff('my-feature-flag') && stylesFF]} />
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
`,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'Imported value in LHS of conditional expression in style prop',
|
|
187
|
+
code: `
|
|
188
|
+
import { css } from '@compiled/react';
|
|
189
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
190
|
+
import { IS_FF_ENABLED } from '../shared';
|
|
191
|
+
|
|
192
|
+
const Component = (props: { width: number }) => (
|
|
193
|
+
<>
|
|
194
|
+
<div style={{ width: IS_FF_ENABLED ? Math.abs(width) : width }} />
|
|
195
|
+
<div style={{ width: ff('my-feature-flag') ? Math.abs(width) : width }} />
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
`,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'Non-computed member access that collides with imported name',
|
|
202
|
+
code: `
|
|
203
|
+
import { abs } from '../shared';
|
|
204
|
+
|
|
205
|
+
const Component = (props: { width: number }) => (
|
|
206
|
+
<div style={{ width: Math.abs(width) }} />
|
|
207
|
+
);
|
|
208
|
+
`,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: 'Non-computed property key that collides with imported name',
|
|
212
|
+
code: `
|
|
213
|
+
import { css } from '@compiled/react';
|
|
214
|
+
import { color } from '../shared';
|
|
215
|
+
|
|
216
|
+
const styles = css({
|
|
217
|
+
color: token('color.text'),
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const Component = (props: { color: string }) => (
|
|
221
|
+
<div
|
|
222
|
+
css={styles}
|
|
223
|
+
style={{ color: props.color }}
|
|
224
|
+
/>
|
|
225
|
+
);
|
|
226
|
+
`,
|
|
227
|
+
},
|
|
144
228
|
],
|
|
145
229
|
invalid: [
|
|
146
230
|
{
|
|
@@ -278,6 +362,130 @@ typescriptEslintTester.run(
|
|
|
278
362
|
`,
|
|
279
363
|
errors: [{ messageId: 'no-imported-style-values' }],
|
|
280
364
|
},
|
|
365
|
+
{
|
|
366
|
+
name: 'Imported value in LHS of conditional expression in style declaration',
|
|
367
|
+
code: `
|
|
368
|
+
import { css } from '@compiled/react';
|
|
369
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
370
|
+
import { IS_FF_ENABLED } from '../shared';
|
|
371
|
+
|
|
372
|
+
const stylesA = css({
|
|
373
|
+
color: IS_FF_ENABLED ? token('color.text.danger'): token('color.text'),
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const stylesB = css({
|
|
377
|
+
color: ff('my-feature-flag') ? token('color.text.danger') : token('color.text'),
|
|
378
|
+
});
|
|
379
|
+
`,
|
|
380
|
+
errors: [
|
|
381
|
+
{ messageId: 'no-imported-style-values', line: 7 },
|
|
382
|
+
{ messageId: 'no-imported-style-values', line: 11 },
|
|
383
|
+
],
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: 'Imported value in RHS of conditional expression in css prop',
|
|
387
|
+
code: `
|
|
388
|
+
import { css } from '@compiled/react';
|
|
389
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
390
|
+
import { IS_FF_ENABLED, stylesFF } from '../shared';
|
|
391
|
+
|
|
392
|
+
const baseStyles = css({ margin: 0 });
|
|
393
|
+
const styles = css({ color: token('color.text' )});
|
|
394
|
+
|
|
395
|
+
const Component = () => (
|
|
396
|
+
<>
|
|
397
|
+
<div css={IS_FF_ENABLED ? stylesFF : styles} />
|
|
398
|
+
<div css={[baseStyles, IS_FF_ENABLED ? stylesFF : styles]} />
|
|
399
|
+
<div css={ff('my-feature-flag') ? stylesFF : styles} />
|
|
400
|
+
<div css={[baseStyles, ff('my-feature-flag') ? stylesFF : styles]} />
|
|
401
|
+
</>
|
|
402
|
+
);
|
|
403
|
+
`,
|
|
404
|
+
errors: [
|
|
405
|
+
{ messageId: 'no-imported-style-values', line: 11 },
|
|
406
|
+
{ messageId: 'no-imported-style-values', line: 12 },
|
|
407
|
+
{ messageId: 'no-imported-style-values', line: 13 },
|
|
408
|
+
{ messageId: 'no-imported-style-values', line: 14 },
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: 'Imported value in RHS of logical expression in css prop',
|
|
413
|
+
code: `
|
|
414
|
+
import { css } from '@compiled/react';
|
|
415
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
416
|
+
import { IS_FF_ENABLED, stylesFF } from '../shared';
|
|
417
|
+
|
|
418
|
+
const baseStyles = css({ margin: 0 });
|
|
419
|
+
const styles = css({ color: token('color.text' )});
|
|
420
|
+
|
|
421
|
+
const Component = () => (
|
|
422
|
+
<>
|
|
423
|
+
<div css={IS_FF_ENABLED && stylesFF} />
|
|
424
|
+
<div css={[baseStyles, IS_FF_ENABLED && stylesFF]} />
|
|
425
|
+
<div css={ff('my-feature-flag') && stylesFF} />
|
|
426
|
+
<div css={[baseStyles, ff('my-feature-flag') && stylesFF]} />
|
|
427
|
+
</>
|
|
428
|
+
);
|
|
429
|
+
`,
|
|
430
|
+
errors: [
|
|
431
|
+
{ messageId: 'no-imported-style-values', line: 11 },
|
|
432
|
+
{ messageId: 'no-imported-style-values', line: 12 },
|
|
433
|
+
{ messageId: 'no-imported-style-values', line: 13 },
|
|
434
|
+
{ messageId: 'no-imported-style-values', line: 14 },
|
|
435
|
+
],
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: 'Imported value in RHS of conditional expression in style prop',
|
|
439
|
+
code: `
|
|
440
|
+
import { css } from '@compiled/react';
|
|
441
|
+
import { ff } from '@atlassian/jira-feature-flagging';
|
|
442
|
+
import { IS_FF_ENABLED, abs } from '../shared';
|
|
443
|
+
|
|
444
|
+
const Component = (props: { width: number }) => (
|
|
445
|
+
<>
|
|
446
|
+
<div style={{ width: IS_FF_ENABLED ? abs(width) : width }} />
|
|
447
|
+
<div style={{ width: ff('my-feature-flag') ? abs(width) : width }} />
|
|
448
|
+
</>
|
|
449
|
+
);
|
|
450
|
+
`,
|
|
451
|
+
errors: [
|
|
452
|
+
{ messageId: 'no-imported-style-values', line: 8 },
|
|
453
|
+
{ messageId: 'no-imported-style-values', line: 9 },
|
|
454
|
+
],
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: 'Computed member access with imported name',
|
|
458
|
+
code: `
|
|
459
|
+
import { abs } from '../shared';
|
|
460
|
+
|
|
461
|
+
const Component = (props: { width: number }) => (
|
|
462
|
+
<div style={{ width: Math[abs](width) }} />
|
|
463
|
+
);
|
|
464
|
+
`,
|
|
465
|
+
errors: [{ messageId: 'no-imported-style-values' }],
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: 'Computed property key with imported name',
|
|
469
|
+
code: `
|
|
470
|
+
import { css } from '@compiled/react';
|
|
471
|
+
import { color } from '../shared';
|
|
472
|
+
|
|
473
|
+
const styles = css({
|
|
474
|
+
[color]: token('color.text'),
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
const Component = (props: { color: string }) => (
|
|
478
|
+
<div
|
|
479
|
+
css={styles}
|
|
480
|
+
style={{ [color]: props.color }}
|
|
481
|
+
/>
|
|
482
|
+
);
|
|
483
|
+
`,
|
|
484
|
+
errors: [
|
|
485
|
+
{ messageId: 'no-imported-style-values' },
|
|
486
|
+
{ messageId: 'no-imported-style-values' },
|
|
487
|
+
],
|
|
488
|
+
},
|
|
281
489
|
],
|
|
282
490
|
},
|
|
283
491
|
);
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
hasStyleObjectArguments,
|
|
5
5
|
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
6
|
import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
|
|
7
|
+
import type { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
|
|
7
8
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
8
9
|
import type { Rule } from 'eslint';
|
|
9
10
|
import {
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
} from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
15
16
|
import type * as ESTree from 'eslint-codemod-utils';
|
|
16
17
|
import esquery from 'esquery';
|
|
18
|
+
import estraverse from 'estraverse';
|
|
17
19
|
|
|
18
20
|
const schema: JSONSchema4 = [
|
|
19
21
|
{
|
|
@@ -81,6 +83,22 @@ const checkIdentifier = (
|
|
|
81
83
|
functionAllowList: AllowList,
|
|
82
84
|
keysAllowList: AllowList,
|
|
83
85
|
) => {
|
|
86
|
+
const { parent } = identifier as Rule.Node;
|
|
87
|
+
|
|
88
|
+
// Even though `member` in `object.member` is syntactically an identifier,
|
|
89
|
+
// it should be ignored as `.member` is syntax sugar for `['member']` here.
|
|
90
|
+
// We should still lint `object[member]` (when `parent.computed` === true)
|
|
91
|
+
if (parent.type === 'MemberExpression' && identifier === parent.property && !parent.computed) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Even though `key` in `{ key: 'value' }` is syntactically an identifier,
|
|
96
|
+
// it should be ignored as `key` is syntax sugar for `'key'` here.
|
|
97
|
+
// We should still lint `[key]` (when `parent.computed` === true)
|
|
98
|
+
if (parent && parent.type === 'Property' && identifier === parent.key && !parent.computed) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
if (isIdentifierImported(identifier, context, functionAllowList, keysAllowList)) {
|
|
85
103
|
context.report({
|
|
86
104
|
node: identifier,
|
|
@@ -129,10 +147,39 @@ export const rule = createLintRule({
|
|
|
129
147
|
}
|
|
130
148
|
node.arguments.forEach(checkForIdentifiers);
|
|
131
149
|
},
|
|
132
|
-
'JSXAttribute[name.name=/^style|css$/]
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
'JSXAttribute[name.name=/^style|css$/]'(jsxAttribute: ESTree.Node) {
|
|
151
|
+
estraverse.traverse(jsxAttribute, {
|
|
152
|
+
fallback(node) {
|
|
153
|
+
// estraverse does not know about nodes not in the ESTree standard.
|
|
154
|
+
// This includes JSX nodes, so we must provide a fallback method to handle them.
|
|
155
|
+
// Using `fallback: 'iteration'` can cause cycles because it will iterate
|
|
156
|
+
// over the `parent` attribute on JSX nodes.
|
|
157
|
+
return Object.keys(node).filter((key) => key !== 'parent');
|
|
158
|
+
},
|
|
159
|
+
enter(node, parent) {
|
|
160
|
+
// Ignore type contexts
|
|
161
|
+
// Cast required because ESTree is not aware of TypeScript nodes
|
|
162
|
+
if ((node.type as AST_NODE_TYPES) === 'TSTypeReference') {
|
|
163
|
+
return estraverse.VisitorOption.Skip;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Ignore conditions of ternary expressions
|
|
167
|
+
if (parent?.type === 'ConditionalExpression' && node === parent.test) {
|
|
168
|
+
return estraverse.VisitorOption.Skip;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Ignore LHS of logical expressions (&&, ||)
|
|
172
|
+
if (parent?.type === 'LogicalExpression' && node === parent.left) {
|
|
173
|
+
return estraverse.VisitorOption.Skip;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (node.type !== 'Identifier') {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
checkIdentifier(node, context, functionAllowList, keysAllowList);
|
|
181
|
+
},
|
|
182
|
+
});
|
|
136
183
|
},
|
|
137
184
|
};
|
|
138
185
|
},
|
|
@@ -1,52 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Blocks nested selectors in style declarations.
|
|
2
|
+
|
|
3
|
+
Use styles which do not require context from other elements.
|
|
3
4
|
|
|
4
5
|
## Examples
|
|
5
6
|
|
|
6
7
|
### Incorrect
|
|
7
8
|
|
|
8
|
-
```
|
|
9
|
+
```tsx
|
|
9
10
|
import { css } from '@compiled/react';
|
|
11
|
+
import { token } from '@atlaskit/tokens';
|
|
12
|
+
|
|
10
13
|
const styles = css({
|
|
11
14
|
h2: {
|
|
12
|
-
|
|
15
|
+
font: token('font.heading.large'),
|
|
13
16
|
},
|
|
14
17
|
});
|
|
18
|
+
|
|
19
|
+
const Component = () => (
|
|
20
|
+
<div css={styles}>
|
|
21
|
+
<h2>Heading</h2>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
15
24
|
```
|
|
16
25
|
|
|
17
|
-
```
|
|
26
|
+
```tsx
|
|
18
27
|
import { styled } from '@compiled/react';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
import { token } from '@atlaskit/tokens';
|
|
29
|
+
|
|
30
|
+
const Table = styled.table({
|
|
31
|
+
border: `1px solid ${token('color.border')}`,
|
|
32
|
+
td: {
|
|
33
|
+
padding: token('space.100'),
|
|
22
34
|
},
|
|
23
35
|
});
|
|
24
36
|
```
|
|
25
37
|
|
|
26
|
-
```
|
|
38
|
+
```tsx
|
|
27
39
|
import { styled } from '@compiled/react';
|
|
40
|
+
import { token } from '@atlaskit/tokens';
|
|
41
|
+
|
|
28
42
|
const Component = styled.div({
|
|
29
43
|
'.myclass': {
|
|
30
|
-
padding:
|
|
44
|
+
padding: token('space.100'),
|
|
31
45
|
},
|
|
32
46
|
});
|
|
33
47
|
```
|
|
34
48
|
|
|
35
49
|
### Correct
|
|
36
50
|
|
|
37
|
-
```
|
|
51
|
+
```tsx
|
|
38
52
|
import { css } from '@compiled/react';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
import { token } from '@atlaskit/tokens';
|
|
54
|
+
|
|
55
|
+
const headingStyles = css({
|
|
56
|
+
font: token('font.heading.large'),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const Component = () => (
|
|
60
|
+
<div>
|
|
61
|
+
<h2 css={headingStyles}>Heading</h2>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { css } from '@compiled/react';
|
|
68
|
+
import { token } from '@atlaskit/tokens';
|
|
69
|
+
|
|
70
|
+
const tableStyles = css({
|
|
71
|
+
border: `1px solid ${token('color.border')}`,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const tdStyles = css({
|
|
75
|
+
padding: token('space.100'),
|
|
42
76
|
});
|
|
43
77
|
```
|
|
44
78
|
|
|
45
79
|
## Options
|
|
46
80
|
|
|
47
|
-
### importSources
|
|
81
|
+
### `importSources: string[]`
|
|
48
82
|
|
|
49
|
-
By default, this rule will check
|
|
83
|
+
By default, this rule will check styles using:
|
|
50
84
|
|
|
51
85
|
- `@atlaskit/css`
|
|
52
86
|
- `@atlaskit/primitives`
|
|
@@ -56,5 +90,4 @@ By default, this rule will check `css` usages from:
|
|
|
56
90
|
- `@emotion/styled`
|
|
57
91
|
- `styled-components`
|
|
58
92
|
|
|
59
|
-
|
|
60
|
-
array of package names (strings).
|
|
93
|
+
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
Blocks the `styled` API, which creates unnecessary indirection.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This indirection:
|
|
4
|
+
|
|
5
|
+
- obfuscates which tag is being rendered
|
|
6
|
+
- adds linting complexity
|
|
7
|
+
- promotes exported styles
|
|
8
|
+
- can complicate refactoring
|
|
9
|
+
|
|
10
|
+
Use the `css` API instead. It has better performance and clarity.
|
|
4
11
|
|
|
5
12
|
## Examples
|
|
6
13
|
|
|
@@ -49,8 +56,9 @@ export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))`
|
|
|
49
56
|
|
|
50
57
|
```tsx
|
|
51
58
|
import { css, jsx } from '@emotion/react';
|
|
59
|
+
import { token } from '@atlaskit/tokens';
|
|
52
60
|
|
|
53
|
-
const styles = css({ color: '
|
|
61
|
+
const styles = css({ color: token('color.text.subtlest') });
|
|
54
62
|
|
|
55
63
|
const Component = ({ children }) => {
|
|
56
64
|
return <div css={styles}>{children}</div>;
|
|
@@ -58,7 +66,6 @@ const Component = ({ children }) => {
|
|
|
58
66
|
```
|
|
59
67
|
|
|
60
68
|
```tsx
|
|
61
|
-
// Using Primitives
|
|
62
69
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
63
70
|
|
|
64
71
|
const styles = xcss({
|
|
@@ -72,16 +79,12 @@ const Component = ({ children }) => {
|
|
|
72
79
|
|
|
73
80
|
## FAQ
|
|
74
81
|
|
|
75
|
-
###
|
|
82
|
+
### How will I extend like `styled(Button)`?
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`<div css={…}>` syntax is more performant and clear.
|
|
84
|
+
Don't modify the styles of components you don't own, unless they provide an explicit bounded
|
|
85
|
+
interface for doing so — such as the `xcss` prop.
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
Use props (excluding `className` which is prohibited) to modify component styles instead.
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
removed `styled(Button)` interactivity in our latest variants because they are unsafe for us to
|
|
86
|
-
evolve the system with. Instead, make use of reusable component patterns to pass props around which
|
|
87
|
-
impact the styles of that component.
|
|
89
|
+
The Atlassian Design System, for example, no longer supports `styled(Button)` because it is unsafe
|
|
90
|
+
for us to evolve the system with.
|