@atlaskit/side-navigation 1.1.2

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +517 -0
  2. package/LICENSE +13 -0
  3. package/README.md +16 -0
  4. package/build/tsconfig.json +17 -0
  5. package/codemods/0.8.0-change-css-fn-prop.ts +184 -0
  6. package/codemods/__tests__/0.8.0-change-css-fn-prop.ts +360 -0
  7. package/codemods/helpers/generic.ts +674 -0
  8. package/dist/cjs/common/constants.js +10 -0
  9. package/dist/cjs/common/styles.js +104 -0
  10. package/dist/cjs/components/Footer/index.js +67 -0
  11. package/dist/cjs/components/Header/index.js +73 -0
  12. package/dist/cjs/components/Item/button-item.js +47 -0
  13. package/dist/cjs/components/Item/custom-item.js +52 -0
  14. package/dist/cjs/components/Item/go-back-item.js +65 -0
  15. package/dist/cjs/components/Item/index.js +47 -0
  16. package/dist/cjs/components/Item/link-item.js +47 -0
  17. package/dist/cjs/components/Item/skeleton-item.js +43 -0
  18. package/dist/cjs/components/LoadingItems/index.js +51 -0
  19. package/dist/cjs/components/NavigationContent/index.js +52 -0
  20. package/dist/cjs/components/NavigationContent/styles.js +152 -0
  21. package/dist/cjs/components/NavigationFooter/index.js +27 -0
  22. package/dist/cjs/components/NavigationHeader/index.js +27 -0
  23. package/dist/cjs/components/NestableNavigationContent/context.js +51 -0
  24. package/dist/cjs/components/NestableNavigationContent/index.js +182 -0
  25. package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +40 -0
  26. package/dist/cjs/components/NestingItem/hack-for-ert.js +8 -0
  27. package/dist/cjs/components/NestingItem/index.js +173 -0
  28. package/dist/cjs/components/NestingItem/styles.js +47 -0
  29. package/dist/cjs/components/Section/heading-item.js +35 -0
  30. package/dist/cjs/components/Section/index.js +31 -0
  31. package/dist/cjs/components/Section/section.js +45 -0
  32. package/dist/cjs/components/Section/skeleton-heading-item.js +39 -0
  33. package/dist/cjs/components/SideNavigation/index.js +41 -0
  34. package/dist/cjs/components/index.js +131 -0
  35. package/dist/cjs/index.js +131 -0
  36. package/dist/cjs/version.json +5 -0
  37. package/dist/es2019/common/constants.js +2 -0
  38. package/dist/es2019/common/styles.js +78 -0
  39. package/dist/es2019/components/Footer/index.js +52 -0
  40. package/dist/es2019/components/Header/index.js +46 -0
  41. package/dist/es2019/components/Item/button-item.js +25 -0
  42. package/dist/es2019/components/Item/custom-item.js +31 -0
  43. package/dist/es2019/components/Item/go-back-item.js +34 -0
  44. package/dist/es2019/components/Item/index.js +5 -0
  45. package/dist/es2019/components/Item/link-item.js +25 -0
  46. package/dist/es2019/components/Item/skeleton-item.js +28 -0
  47. package/dist/es2019/components/LoadingItems/index.js +38 -0
  48. package/dist/es2019/components/NavigationContent/index.js +38 -0
  49. package/dist/es2019/components/NavigationContent/styles.js +120 -0
  50. package/dist/es2019/components/NavigationFooter/index.js +18 -0
  51. package/dist/es2019/components/NavigationHeader/index.js +20 -0
  52. package/dist/es2019/components/NestableNavigationContent/context.js +41 -0
  53. package/dist/es2019/components/NestableNavigationContent/index.js +148 -0
  54. package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +21 -0
  55. package/dist/es2019/components/NestingItem/hack-for-ert.js +1 -0
  56. package/dist/es2019/components/NestingItem/index.js +128 -0
  57. package/dist/es2019/components/NestingItem/styles.js +39 -0
  58. package/dist/es2019/components/Section/heading-item.js +22 -0
  59. package/dist/es2019/components/Section/index.js +3 -0
  60. package/dist/es2019/components/Section/section.js +25 -0
  61. package/dist/es2019/components/Section/skeleton-heading-item.js +24 -0
  62. package/dist/es2019/components/SideNavigation/index.js +30 -0
  63. package/dist/es2019/components/index.js +11 -0
  64. package/dist/es2019/index.js +3 -0
  65. package/dist/es2019/version.json +5 -0
  66. package/dist/esm/common/constants.js +2 -0
  67. package/dist/esm/common/styles.js +82 -0
  68. package/dist/esm/components/Footer/index.js +51 -0
  69. package/dist/esm/components/Header/index.js +50 -0
  70. package/dist/esm/components/Item/button-item.js +25 -0
  71. package/dist/esm/components/Item/custom-item.js +31 -0
  72. package/dist/esm/components/Item/go-back-item.js +41 -0
  73. package/dist/esm/components/Item/index.js +5 -0
  74. package/dist/esm/components/Item/link-item.js +25 -0
  75. package/dist/esm/components/Item/skeleton-item.js +29 -0
  76. package/dist/esm/components/LoadingItems/index.js +39 -0
  77. package/dist/esm/components/NavigationContent/index.js +37 -0
  78. package/dist/esm/components/NavigationContent/styles.js +130 -0
  79. package/dist/esm/components/NavigationFooter/index.js +17 -0
  80. package/dist/esm/components/NavigationHeader/index.js +18 -0
  81. package/dist/esm/components/NestableNavigationContent/context.js +36 -0
  82. package/dist/esm/components/NestableNavigationContent/index.js +163 -0
  83. package/dist/esm/components/NestableNavigationContent/nesting-motion.js +28 -0
  84. package/dist/esm/components/NestingItem/hack-for-ert.js +1 -0
  85. package/dist/esm/components/NestingItem/index.js +144 -0
  86. package/dist/esm/components/NestingItem/styles.js +34 -0
  87. package/dist/esm/components/Section/heading-item.js +21 -0
  88. package/dist/esm/components/Section/index.js +3 -0
  89. package/dist/esm/components/Section/section.js +24 -0
  90. package/dist/esm/components/Section/skeleton-heading-item.js +25 -0
  91. package/dist/esm/components/SideNavigation/index.js +28 -0
  92. package/dist/esm/components/index.js +11 -0
  93. package/dist/esm/index.js +3 -0
  94. package/dist/esm/version.json +5 -0
  95. package/dist/types/common/constants.d.ts +2 -0
  96. package/dist/types/common/styles.d.ts +10 -0
  97. package/dist/types/components/Footer/index.d.ts +4 -0
  98. package/dist/types/components/Header/index.d.ts +43 -0
  99. package/dist/types/components/Item/button-item.d.ts +5 -0
  100. package/dist/types/components/Item/custom-item.d.ts +13 -0
  101. package/dist/types/components/Item/go-back-item.d.ts +5 -0
  102. package/dist/types/components/Item/index.d.ts +10 -0
  103. package/dist/types/components/Item/link-item.d.ts +5 -0
  104. package/dist/types/components/Item/skeleton-item.d.ts +4 -0
  105. package/dist/types/components/LoadingItems/index.d.ts +30 -0
  106. package/dist/types/components/NavigationContent/index.d.ts +17 -0
  107. package/dist/types/components/NavigationContent/styles.d.ts +91 -0
  108. package/dist/types/components/NavigationFooter/index.d.ts +7 -0
  109. package/dist/types/components/NavigationHeader/index.d.ts +5 -0
  110. package/dist/types/components/NestableNavigationContent/context.d.ts +20 -0
  111. package/dist/types/components/NestableNavigationContent/index.d.ts +58 -0
  112. package/dist/types/components/NestableNavigationContent/nesting-motion.d.ts +18 -0
  113. package/dist/types/components/NestingItem/hack-for-ert.d.ts +2 -0
  114. package/dist/types/components/NestingItem/index.d.ts +91 -0
  115. package/dist/types/components/NestingItem/styles.d.ts +28 -0
  116. package/dist/types/components/Section/heading-item.d.ts +4 -0
  117. package/dist/types/components/Section/index.d.ts +6 -0
  118. package/dist/types/components/Section/section.d.ts +25 -0
  119. package/dist/types/components/Section/skeleton-heading-item.d.ts +4 -0
  120. package/dist/types/components/SideNavigation/index.d.ts +23 -0
  121. package/dist/types/components/index.d.ts +22 -0
  122. package/dist/types/index.d.ts +4 -0
  123. package/docs/00-intro.tsx +70 -0
  124. package/docs/01-side-navigation.tsx +33 -0
  125. package/docs/02-navigation-header.tsx +39 -0
  126. package/docs/03-navigation-content.tsx +40 -0
  127. package/docs/04-nestable-navigation-content.tsx +95 -0
  128. package/docs/05-navigation-footer.tsx +38 -0
  129. package/docs/99-loading-states.tsx +95 -0
  130. package/docs/button-item.tsx +38 -0
  131. package/docs/custom-item.tsx +45 -0
  132. package/docs/go-back-item.tsx +31 -0
  133. package/docs/heading-item.tsx +30 -0
  134. package/docs/link-item.tsx +39 -0
  135. package/docs/nesting-item.tsx +52 -0
  136. package/docs/section.tsx +40 -0
  137. package/docs/skeleton-heading-item.tsx +30 -0
  138. package/docs/skeleton-item.tsx +30 -0
  139. package/package.json +71 -0
  140. package/tsconfig.json +15 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2019 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Side Navigation
2
+
3
+ The new side navigation experience used in Atlassian products.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add @atlaskit/side-navigation
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/navigation/side-navigation).
14
+
15
+ To add a top navigation, use [@atlaskit/atlassian-navigation](https://atlaskit.atlassian.com/packages/navigation/atlassian-navigation)
16
+ To control the layout of these navigation elements and add expand/collapse functionality to `side-navigation`, use [@atlaskit/page-layout](https://atlaskit.atlassian.com/packages/design-system/page-layout).
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../tsconfig",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "target": "es5",
6
+ "paths": {}
7
+ },
8
+ "include": [
9
+ "../src/**/*.ts",
10
+ "../src/**/*.tsx"
11
+ ],
12
+ "exclude": [
13
+ "../src/**/__tests__/*",
14
+ "../src/**/*.test.*",
15
+ "../src/**/test.*"
16
+ ]
17
+ }
@@ -0,0 +1,184 @@
1
+ import { NodePath } from 'ast-types/lib/node-path';
2
+ import core, {
3
+ API,
4
+ ASTPath,
5
+ FileInfo,
6
+ ImportDeclaration,
7
+ ImportSpecifier,
8
+ Options,
9
+ } from 'jscodeshift';
10
+
11
+ import {
12
+ addCommentBeforeJSX,
13
+ getDefaultSpecifierName,
14
+ } from './helpers/generic';
15
+
16
+ function getJSXAttributesByName(
17
+ j: core.JSCodeshift,
18
+ element: ASTPath<any>,
19
+ attributeName: string,
20
+ ) {
21
+ return j(element)
22
+ .find(j.JSXOpeningElement)
23
+ .find(j.JSXAttribute)
24
+ .filter((attribute) => {
25
+ const matches = j(attribute)
26
+ .find(j.JSXIdentifier)
27
+ .filter((identifier) => identifier.value.name === attributeName);
28
+ return Boolean(matches.length);
29
+ });
30
+ }
31
+
32
+ function getImportSpecifier(
33
+ j: core.JSCodeshift,
34
+ source: ReturnType<typeof j>,
35
+ specifier: string,
36
+ imported: string,
37
+ ) {
38
+ const specifiers = source
39
+ .find(j.ImportDeclaration)
40
+ .filter(
41
+ (path: ASTPath<ImportDeclaration>) =>
42
+ path.node.source.value === specifier,
43
+ )
44
+ .find(j.ImportSpecifier)
45
+ .filter(
46
+ (path: ASTPath<ImportSpecifier>) => path.value.imported.name === imported,
47
+ );
48
+
49
+ if (!specifiers.length) {
50
+ return null;
51
+ }
52
+
53
+ return specifiers.nodes()[0]!.local!.name;
54
+ }
55
+
56
+ function updateCssFnProp(
57
+ j: core.JSCodeshift,
58
+ source: ReturnType<typeof j>,
59
+ specifier: string,
60
+ ) {
61
+ source.findJSXElements(specifier).forEach((element) => {
62
+ const cssFnPropCollection = getJSXAttributesByName(j, element, 'cssFn');
63
+
64
+ // no cssProp usage for this element
65
+ if (!cssFnPropCollection.length) {
66
+ return;
67
+ }
68
+
69
+ const cssFnProp = cssFnPropCollection.get();
70
+
71
+ const cssFnExpression: NodePath = j(cssFnProp)
72
+ .find(j.JSXExpressionContainer)
73
+ .find(j.Expression)
74
+ .get();
75
+
76
+ if (cssFnExpression) {
77
+ // just remove the state styles param
78
+ try {
79
+ const [stylePropName] = cssFnExpression!.value.params;
80
+ j(cssFnExpression)
81
+ .find(j.SpreadElement)
82
+ .forEach((n) => {
83
+ // discerns whether there are multiple identifiers here
84
+ const isComplexIdentifier = j(n).find(j.Identifier).length > 1;
85
+
86
+ if (isComplexIdentifier) {
87
+ throw new Error(
88
+ 'CSSFn Prop codemod: Unable to parse spread element',
89
+ );
90
+ }
91
+
92
+ const hasStyleProp = !!j(n)
93
+ .find(j.Identifier)
94
+ .filter((node) => node.value.name === stylePropName.name).length;
95
+ if (hasStyleProp) {
96
+ j(n).remove();
97
+ }
98
+ });
99
+
100
+ cssFnExpression!.value.params.shift();
101
+ } catch (e) {
102
+ addCommentBeforeJSX(
103
+ j,
104
+ cssFnProp,
105
+ `
106
+ The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
107
+ The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
108
+ For more info please reach out to #help-design-system-code.
109
+ `,
110
+ );
111
+ }
112
+ }
113
+ });
114
+ }
115
+
116
+ function hasImportDeclaration(
117
+ j: core.JSCodeshift,
118
+ source: ReturnType<typeof j>,
119
+ importPath: string,
120
+ ) {
121
+ return !!source
122
+ .find(j.ImportDeclaration)
123
+ .filter((path) => path.node.source.value === importPath).length;
124
+ }
125
+
126
+ export default function transformer(
127
+ fileInfo: FileInfo,
128
+ { jscodeshift: j }: API,
129
+ options: Options,
130
+ ) {
131
+ const source = j(fileInfo.source);
132
+
133
+ if (hasImportDeclaration(j, source, '@atlaskit/side-navigation')) {
134
+ const defaultSpecifier = getDefaultSpecifierName({
135
+ j,
136
+ base: source,
137
+ packageName: '@atlaskit/side-navigation',
138
+ });
139
+
140
+ if (defaultSpecifier != null) {
141
+ updateCssFnProp(j, source, defaultSpecifier);
142
+ }
143
+
144
+ [
145
+ 'SideNavigation',
146
+ 'Header',
147
+ 'NavigationHeader',
148
+ 'NavigationContent',
149
+ 'Section',
150
+ 'HeadingItem',
151
+ 'SkeletonHeadingItem',
152
+ 'NestableNavigationContent',
153
+ 'NestingItem',
154
+ 'ButtonItem',
155
+ 'LinkItem',
156
+ 'GoBackItem',
157
+ 'CustomItem',
158
+ 'SkeletonItem',
159
+ 'Footer',
160
+ 'NavigationFooter',
161
+ 'LoadingItems',
162
+ ].forEach((pkg) => {
163
+ const importSpecifier = getImportSpecifier(
164
+ j,
165
+ source,
166
+ '@atlaskit/side-navigation',
167
+ pkg,
168
+ );
169
+
170
+ if (importSpecifier != null) {
171
+ updateCssFnProp(j, source, importSpecifier);
172
+ }
173
+ });
174
+
175
+ return source.toSource(
176
+ options.printOptions || {
177
+ quote: 'single',
178
+ trailingComma: true,
179
+ },
180
+ );
181
+ }
182
+
183
+ return fileInfo.source;
184
+ }
@@ -0,0 +1,360 @@
1
+ jest.autoMockOff();
2
+
3
+ import * as transformer from '../0.8.0-change-css-fn-prop';
4
+
5
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
+
7
+ describe('Updates and removes current inline styles', () => {
8
+ defineInlineTest(
9
+ { ...transformer, parser: 'tsx' },
10
+ {},
11
+ `
12
+ import { ButtonItem } from '@atlaskit/something';
13
+
14
+ const App = () => {
15
+ return <ButtonItem />;
16
+ }
17
+ `,
18
+ `
19
+ import { ButtonItem } from '@atlaskit/something';
20
+
21
+ const App = () => {
22
+ return <ButtonItem />;
23
+ }
24
+ `,
25
+ 'leaves unrelated code untouched',
26
+ );
27
+
28
+ defineInlineTest(
29
+ { ...transformer, parser: 'tsx' },
30
+ {},
31
+ `
32
+ import { ButtonItem } from '@atlaskit/side-navigation';
33
+
34
+ const App = () => {
35
+ return <ButtonItem cssFn={(styles, state) => ({
36
+
37
+ })} />;
38
+ }
39
+ `,
40
+ `
41
+ import { ButtonItem } from '@atlaskit/side-navigation';
42
+
43
+ const App = () => {
44
+ return (
45
+ <ButtonItem cssFn={state => {
46
+
47
+ }} />
48
+ );
49
+ }
50
+ `,
51
+ 'should remove current styles from inline function',
52
+ );
53
+
54
+ defineInlineTest(
55
+ { ...transformer, parser: 'tsx' },
56
+ {},
57
+ `
58
+ import { ButtonItem } from '@atlaskit/side-navigation';
59
+
60
+ const App = () => {
61
+ return (
62
+ <div cssFn={(styles, state) => ({
63
+ ...styles,
64
+ })}>
65
+ <ButtonItem
66
+ cssFn={(styles, state) => ({
67
+ ...styles,
68
+ })}
69
+ />
70
+ </div>
71
+ );
72
+ };
73
+
74
+ `,
75
+ `
76
+ import { ButtonItem } from '@atlaskit/side-navigation';
77
+
78
+ const App = () => {
79
+ return (
80
+ <div cssFn={(styles, state) => ({
81
+ ...styles,
82
+ })}>
83
+ <ButtonItem
84
+ cssFn={state => ({})}
85
+ />
86
+ </div>
87
+ );
88
+ };
89
+ `,
90
+ 'should remove current styles from scope',
91
+ );
92
+
93
+ defineInlineTest(
94
+ { ...transformer, parser: 'tsx' },
95
+ {},
96
+ `
97
+ import { ButtonItem } from '@atlaskit/side-navigation';
98
+
99
+ const App = () => {
100
+ return <ButtonItem cssFn={(styles, state) => ({
101
+ ...styles,
102
+ color: 'red',
103
+ })} />;
104
+ }
105
+ `,
106
+ `
107
+ import { ButtonItem } from '@atlaskit/side-navigation';
108
+
109
+ const App = () => {
110
+ return (
111
+ <ButtonItem cssFn={state => ({
112
+ color: 'red',
113
+ })} />
114
+ );
115
+ }
116
+ `,
117
+ 'correctly removes spread styles',
118
+ );
119
+
120
+ defineInlineTest(
121
+ { ...transformer, parser: 'tsx' },
122
+ {},
123
+ `
124
+ import { ButtonItem } from '@atlaskit/side-navigation';
125
+
126
+ const App = () => {
127
+ return <ButtonItem cssFn={(styles, state) => ({
128
+ ...styles,
129
+ color: 'red',
130
+ ':hover': {
131
+ ...styles[':hover'],
132
+ color: 'blue',
133
+ }
134
+ })} />;
135
+ }
136
+ `,
137
+ `
138
+ import { ButtonItem } from '@atlaskit/side-navigation';
139
+
140
+ const App = () => {
141
+ return (
142
+ <ButtonItem cssFn={state => ({
143
+ color: 'red',
144
+
145
+ ':hover': {
146
+ color: 'blue',
147
+ },
148
+ })} />
149
+ );
150
+ }
151
+ `,
152
+ 'correctly removes spread styles with pseudo-selector access',
153
+ );
154
+
155
+ defineInlineTest(
156
+ { ...transformer, parser: 'tsx' },
157
+ {},
158
+ `
159
+ import { ButtonItem } from '@atlaskit/side-navigation';
160
+
161
+ const App = () => {
162
+ return (
163
+ <ButtonItem cssFn={(styles, state) => ({
164
+ ...(state.x ? styles : {}),
165
+ color: 'red',
166
+ })} />
167
+ );
168
+ }
169
+ `,
170
+ `
171
+ import { ButtonItem } from '@atlaskit/side-navigation';
172
+
173
+ const App = () => {
174
+ return (
175
+ <ButtonItem
176
+ /*
177
+ TODO: (from codemod) The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
178
+ The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
179
+ For more info please reach out to #help-design-system-code.
180
+ */
181
+ cssFn={(styles, state) => ({
182
+ ...(state.x ? styles : {}),
183
+ color: 'red',
184
+ })} />
185
+ );
186
+ }
187
+ `,
188
+ 'fail smoothly if the current styles are being used in a non-trivial way',
189
+ );
190
+
191
+ defineInlineTest(
192
+ { ...transformer, parser: 'tsx' },
193
+ {},
194
+ `
195
+ import { ButtonItem } from '@atlaskit/side-navigation';
196
+
197
+ const App = () => {
198
+ return <ButtonItem cssFn={() => ({
199
+ color: 'red',
200
+ })} />;
201
+ }
202
+ `,
203
+ `
204
+ import { ButtonItem } from '@atlaskit/side-navigation';
205
+
206
+ const App = () => {
207
+ return <ButtonItem cssFn={() => ({
208
+ color: 'red',
209
+ })} />;
210
+ }
211
+ `,
212
+ 'not change anything if user is not using the current state or styles',
213
+ );
214
+
215
+ defineInlineTest(
216
+ { ...transformer, parser: 'tsx' },
217
+ {},
218
+ `
219
+ import { ButtonItem } from '@atlaskit/side-navigation';
220
+
221
+ const App = () => {
222
+ return <ButtonItem cssFn={(styles, state) => ({
223
+ ...styles,
224
+ color: 'red',
225
+ })}>
226
+ <ButtonItem cssFn={(styles, state) => ({
227
+ ...styles,
228
+ color: 'red',
229
+ })}/>
230
+ </ButtonItem>;
231
+ }
232
+ `,
233
+ `
234
+ import { ButtonItem } from '@atlaskit/side-navigation';
235
+
236
+ const App = () => {
237
+ return (
238
+ <ButtonItem cssFn={state => ({
239
+ color: 'red',
240
+ })}>
241
+ <ButtonItem cssFn={state => ({
242
+ color: 'red',
243
+ })}/>
244
+ </ButtonItem>
245
+ );
246
+ }
247
+ `,
248
+ 'should remove styles in nested children',
249
+ );
250
+
251
+ defineInlineTest(
252
+ { ...transformer, parser: 'tsx' },
253
+ {},
254
+ `
255
+ import { ButtonItem } from '@atlaskit/side-navigation';
256
+
257
+ const App = () => {
258
+ return <ButtonItem />;
259
+ }
260
+ `,
261
+ `
262
+ import { ButtonItem } from '@atlaskit/side-navigation';
263
+
264
+ const App = () => {
265
+ return <ButtonItem />;
266
+ }
267
+ `,
268
+ 'should leave affected items with no use of cssFn untouched',
269
+ );
270
+ });
271
+
272
+ describe('Updates and removes current styles', () => {
273
+ defineInlineTest(
274
+ { ...transformer, parser: 'tsx' },
275
+ {},
276
+ `
277
+ import { ButtonItem } from '@atlaskit/side-navigation';
278
+
279
+ const cssFn = (styles, state) => ({
280
+ ...styles,
281
+ color: 'red',
282
+ });
283
+
284
+ const App = () => {
285
+ return <ButtonItem cssFn={cssFn} />;
286
+ }
287
+ `,
288
+ `
289
+ import { ButtonItem } from '@atlaskit/side-navigation';
290
+
291
+ const cssFn = (styles, state) => ({
292
+ ...styles,
293
+ color: 'red',
294
+ });
295
+
296
+ const App = () => {
297
+ return (
298
+ <ButtonItem
299
+ /*
300
+ TODO: (from codemod) The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
301
+ The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
302
+ For more info please reach out to #help-design-system-code.
303
+ */
304
+ cssFn={cssFn} />
305
+ );
306
+ }
307
+ `,
308
+ 'should add prompt for non-inline function',
309
+ );
310
+
311
+ defineInlineTest(
312
+ { ...transformer, parser: 'tsx' },
313
+ {},
314
+ `
315
+ import { ButtonItem, LinkItem } from '@atlaskit/side-navigation';
316
+
317
+ const cssFunction = (styles, state) => ({
318
+ ...styles,
319
+ color: 'red',
320
+ });
321
+
322
+ const App = () => {
323
+ return (
324
+ <ButtonItem cssFn={cssFunction}>
325
+ <LinkItem cssFn={cssFunction} />
326
+ </ButtonItem>
327
+ );
328
+ };
329
+ `,
330
+ `
331
+ import { ButtonItem, LinkItem } from '@atlaskit/side-navigation';
332
+
333
+ const cssFunction = (styles, state) => ({
334
+ ...styles,
335
+ color: 'red',
336
+ });
337
+
338
+ const App = () => {
339
+ return (
340
+ <ButtonItem
341
+ /*
342
+ TODO: (from codemod) The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
343
+ The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
344
+ For more info please reach out to #help-design-system-code.
345
+ */
346
+ cssFn={cssFunction}>
347
+ <LinkItem
348
+ /*
349
+ TODO: (from codemod) The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
350
+ The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
351
+ For more info please reach out to #help-design-system-code.
352
+ */
353
+ cssFn={cssFunction} />
354
+ </ButtonItem>
355
+ );
356
+ };
357
+ `,
358
+ 'should add prompt for non-inline function to multiple instances',
359
+ );
360
+ });