@atlaskit/storybook-addon-design-system 0.8.0 → 1.1.0

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 (74) hide show
  1. package/CHANGELOG.md +101 -80
  2. package/constellation/index/props.mdx +9 -4
  3. package/constellation/index/usage.mdx +7 -4
  4. package/dist/cjs/decorator.js +127 -0
  5. package/dist/cjs/index.js +3 -7
  6. package/dist/cjs/manager.js +17 -0
  7. package/dist/cjs/preset.js +25 -0
  8. package/dist/cjs/preview.js +26 -0
  9. package/dist/cjs/{tokens/components/tool.js → tool.js} +19 -24
  10. package/dist/es2019/decorator.js +106 -0
  11. package/dist/es2019/index.js +2 -1
  12. package/dist/es2019/{tokens/register.js → manager.js} +2 -2
  13. package/dist/es2019/preset.js +3 -0
  14. package/dist/es2019/preview.js +19 -0
  15. package/dist/es2019/{tokens/components/tool.js → tool.js} +18 -23
  16. package/dist/esm/decorator.js +117 -0
  17. package/dist/esm/index.js +2 -1
  18. package/dist/esm/{tokens/register.js → manager.js} +2 -2
  19. package/dist/esm/preset.js +18 -0
  20. package/dist/esm/preview.js +19 -0
  21. package/dist/esm/{tokens/components/tool.js → tool.js} +19 -24
  22. package/dist/types/decorator.d.ts +4 -0
  23. package/dist/types/index.d.ts +2 -1
  24. package/dist/types/preset.d.ts +1 -0
  25. package/dist/types/preview.d.ts +13 -0
  26. package/dist/types-ts4.5/decorator.d.ts +4 -0
  27. package/dist/types-ts4.5/index.d.ts +2 -1
  28. package/dist/types-ts4.5/preset.d.ts +1 -0
  29. package/dist/types-ts4.5/preview.d.ts +13 -0
  30. package/manager.js +2 -0
  31. package/package.json +77 -67
  32. package/preset.js +2 -0
  33. package/preview.js +2 -0
  34. package/report.api.md +3 -2
  35. package/src/constants.tsx +5 -0
  36. package/src/decorator.tsx +125 -0
  37. package/src/index.tsx +2 -0
  38. package/src/manager.tsx +13 -0
  39. package/src/preset.tsx +3 -0
  40. package/src/preview.tsx +22 -0
  41. package/src/tool.tsx +76 -0
  42. package/src/types.tsx +1 -0
  43. package/dist/cjs/tokens/components/index.js +0 -13
  44. package/dist/cjs/tokens/decorator.js +0 -128
  45. package/dist/cjs/tokens/index.js +0 -13
  46. package/dist/cjs/tokens/register.js +0 -16
  47. package/dist/es2019/tokens/components/index.js +0 -1
  48. package/dist/es2019/tokens/decorator.js +0 -107
  49. package/dist/es2019/tokens/index.js +0 -1
  50. package/dist/esm/tokens/components/index.js +0 -1
  51. package/dist/esm/tokens/decorator.js +0 -118
  52. package/dist/esm/tokens/index.js +0 -1
  53. package/dist/types/tokens/components/index.d.ts +0 -1
  54. package/dist/types/tokens/decorator.d.ts +0 -2
  55. package/dist/types/tokens/index.d.ts +0 -1
  56. package/dist/types-ts4.5/tokens/components/index.d.ts +0 -1
  57. package/dist/types-ts4.5/tokens/decorator.d.ts +0 -2
  58. package/dist/types-ts4.5/tokens/index.d.ts +0 -1
  59. package/register-tokens.js +0 -2
  60. package/register.js +0 -2
  61. /package/dist/cjs/{tokens/constants.js → constants.js} +0 -0
  62. /package/dist/cjs/{tokens/types.js → types.js} +0 -0
  63. /package/dist/es2019/{tokens/constants.js → constants.js} +0 -0
  64. /package/dist/es2019/{tokens/types.js → types.js} +0 -0
  65. /package/dist/esm/{tokens/constants.js → constants.js} +0 -0
  66. /package/dist/esm/{tokens/types.js → types.js} +0 -0
  67. /package/dist/types/{tokens/constants.d.ts → constants.d.ts} +0 -0
  68. /package/dist/types/{tokens/register.d.ts → manager.d.ts} +0 -0
  69. /package/dist/types/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
  70. /package/dist/types/{tokens/types.d.ts → types.d.ts} +0 -0
  71. /package/dist/types-ts4.5/{tokens/constants.d.ts → constants.d.ts} +0 -0
  72. /package/dist/types-ts4.5/{tokens/register.d.ts → manager.d.ts} +0 -0
  73. /package/dist/types-ts4.5/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
  74. /package/dist/types-ts4.5/{tokens/types.d.ts → types.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,226 +1,247 @@
1
1
  # @atlaskit/storybook-addon-design-system
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#121858](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121858)
8
+ [`a1c4a37a57a0c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a1c4a37a57a0c) -
9
+ Fixed the build issue in the previous version.
10
+
11
+ ## 1.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - [#121263](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121263)
16
+ [`9b5e0cb70a67b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9b5e0cb70a67b) -
17
+ @atlaskit/storybook-addon-design-system has migrated to Storybook 8.0. Use the previous version if
18
+ your project is still on v6 or v7.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 0.8.0
4
25
 
5
26
  ### Minor Changes
6
27
 
7
- - [#94453](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94453)
8
- [`8b0ba81b30b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8b0ba81b30b3) -
9
- Add support for React 18.
28
+ - [#94453](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94453)
29
+ [`8b0ba81b30b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8b0ba81b30b3) -
30
+ Add support for React 18 in non-strict mode.
10
31
 
11
32
  ## 0.7.1
12
33
 
13
34
  ### Patch Changes
14
35
 
15
- - [#93943](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93943)
16
- [`611f5e98470c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/611f5e98470c) -
17
- Removes fallback colors from styles
36
+ - [#93943](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93943)
37
+ [`611f5e98470c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/611f5e98470c) -
38
+ Removes fallback colors from styles
18
39
 
19
40
  ## 0.7.0
20
41
 
21
42
  ### Minor Changes
22
43
 
23
- - [#94436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94436)
24
- [`c652e1c27a4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c652e1c27a4d) -
25
- Updates the default theme to 'auto' to ensure tokens are always applied. "Unthemed" or "No
26
- theme" is now considered an unsafe appearance.
44
+ - [#94436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94436)
45
+ [`c652e1c27a4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c652e1c27a4d) -
46
+ Updates the default theme to 'auto' to ensure tokens are always applied. "Unthemed" or "No theme"
47
+ is now considered an unsafe appearance.
27
48
 
28
- If you prefer to use a different theme, you can still override the default theme by setting the
29
- `adeTheme.defaultValue: 'none'` as mentioned in
30
- [the documentation](https://staging.atlassian.design/components/storybook-addon-design-system/code#storybook-v7-and-above).
49
+ If you prefer to use a different theme, you can still override the default theme by setting the
50
+ `adeTheme.defaultValue: 'none'` as mentioned in
51
+ [the documentation](https://staging.atlassian.design/components/storybook-addon-design-system/code#storybook-v7-and-above).
31
52
 
32
53
  ## 0.6.0
33
54
 
34
55
  ### Minor Changes
35
56
 
36
- - [#77691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77691)
37
- [`14d18ea34852`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/14d18ea34852) - -
38
- Enables new `typography` and `shape` themes
39
- - Sets the color theme to `auto` by default
57
+ - [#77691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77691)
58
+ [`14d18ea34852`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/14d18ea34852) - -
59
+ Enables new `typography` and `shape` themes
60
+ - Sets the color theme to `auto` by default
40
61
 
41
62
  ## 0.5.2
42
63
 
43
64
  ### Patch Changes
44
65
 
45
- - [#32935](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32935)
46
- [`b1bdec7cce2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b1bdec7cce2) -
47
- Internal change to enforce token usage for spacing properties. There is no expected visual or
48
- behaviour change.
66
+ - [#32935](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32935)
67
+ [`b1bdec7cce2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b1bdec7cce2) - Internal
68
+ change to enforce token usage for spacing properties. There is no expected visual or behaviour
69
+ change.
49
70
 
50
71
  ## 0.5.1
51
72
 
52
73
  ### Patch Changes
53
74
 
54
- - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793)
55
- [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure
56
- legacy types are published for TS 4.5-4.8
75
+ - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793)
76
+ [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure
77
+ legacy types are published for TS 4.5-4.8
57
78
 
58
79
  ## 0.5.0
59
80
 
60
81
  ### Minor Changes
61
82
 
62
- - [#33632](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33632)
63
- [`389ab86b2a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/389ab86b2a3) - Adding
64
- spacing tokens to storybook addon so that users spacing tokens appear in storybook
83
+ - [#33632](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33632)
84
+ [`389ab86b2a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/389ab86b2a3) - Adding
85
+ spacing tokens to storybook addon so that users spacing tokens appear in storybook
65
86
 
66
87
  ### Patch Changes
67
88
 
68
- - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649)
69
- [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) -
70
- Upgrade Typescript from `4.5.5` to `4.9.5`
89
+ - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649)
90
+ [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade
91
+ Typescript from `4.5.5` to `4.9.5`
71
92
 
72
93
  ## 0.4.0
73
94
 
74
95
  ### Minor Changes
75
96
 
76
- - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258)
77
- [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip
78
- minor dependency bump
97
+ - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258)
98
+ [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip
99
+ minor dependency bump
79
100
 
80
101
  ### Patch Changes
81
102
 
82
- - Updated dependencies
103
+ - Updated dependencies
83
104
 
84
105
  ## 0.3.9
85
106
 
86
107
  ### Patch Changes
87
108
 
88
- - [#27634](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27634)
89
- [`718d5ad3044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/718d5ad3044) -
90
- Updates to support the new `@atlaskit/tokens` theming API.
91
- - Updated dependencies
109
+ - [#27634](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27634)
110
+ [`718d5ad3044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/718d5ad3044) - Updates
111
+ to support the new `@atlaskit/tokens` theming API.
112
+ - Updated dependencies
92
113
 
93
114
  ## 0.3.8
94
115
 
95
116
  ### Patch Changes
96
117
 
97
- - Updated dependencies
118
+ - Updated dependencies
98
119
 
99
120
  ## 0.3.7
100
121
 
101
122
  ### Patch Changes
102
123
 
103
- - Updated dependencies
124
+ - Updated dependencies
104
125
 
105
126
  ## 0.3.6
106
127
 
107
128
  ### Patch Changes
108
129
 
109
- - [#27629](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27629)
110
- [`f824dcfff6e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f824dcfff6e) -
111
- Internal changes to satisfy various lint warnings & errors
130
+ - [#27629](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27629)
131
+ [`f824dcfff6e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f824dcfff6e) - Internal
132
+ changes to satisfy various lint warnings & errors
112
133
 
113
134
  ## 0.3.5
114
135
 
115
136
  ### Patch Changes
116
137
 
117
- - Updated dependencies
138
+ - Updated dependencies
118
139
 
119
140
  ## 0.3.4
120
141
 
121
142
  ### Patch Changes
122
143
 
123
- - [#26467](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26467)
124
- [`43464a5fb17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43464a5fb17) - Update
125
- split and stack theme settings to use tilde selectors
144
+ - [#26467](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26467)
145
+ [`43464a5fb17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43464a5fb17) - Update
146
+ split and stack theme settings to use tilde selectors
126
147
 
127
148
  ## 0.3.3
128
149
 
129
150
  ### Patch Changes
130
151
 
131
- - [#26303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26303)
132
- [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op
133
- change to introduce spacing tokens to design system components.
152
+ - [#26303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26303)
153
+ [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op
154
+ change to introduce spacing tokens to design system components.
134
155
 
135
156
  ## 0.3.2
136
157
 
137
158
  ### Patch Changes
138
159
 
139
- - [#24660](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24660)
140
- [`d4be43fdc44`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d4be43fdc44) - Set
141
- the innerText in our hack correctly - oops!
160
+ - [#24660](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24660)
161
+ [`d4be43fdc44`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d4be43fdc44) - Set the
162
+ innerText in our hack correctly - oops!
142
163
 
143
164
  ## 0.3.1
144
165
 
145
166
  ### Patch Changes
146
167
 
147
- - [#24626](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24626)
148
- [`6dd7050ad7a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6dd7050ad7a) -
149
- Reimplement the style tag hack required for enabling split & stack view in the Storybook addon
168
+ - [#24626](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24626)
169
+ [`6dd7050ad7a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6dd7050ad7a) -
170
+ Reimplement the style tag hack required for enabling split & stack view in the Storybook addon
150
171
 
151
172
  ## 0.3.0
152
173
 
153
174
  ### Minor Changes
154
175
 
155
- - [#21484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21484)
156
- [`6c65a3147c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c65a3147c1) -
157
- Removes root selector hack from lightmode, this is no longer necessary since the default theme
158
- no longer enables tokens by default
176
+ - [#21484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21484)
177
+ [`6c65a3147c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c65a3147c1) - Removes
178
+ root selector hack from lightmode, this is no longer necessary since the default theme no longer
179
+ enables tokens by default
159
180
 
160
181
  ### Patch Changes
161
182
 
162
- - Updated dependencies
183
+ - Updated dependencies
163
184
 
164
185
  ## 0.2.6
165
186
 
166
187
  ### Patch Changes
167
188
 
168
- - [#21487](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21487)
169
- [`4942487a9f6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4942487a9f6) - Fixes
170
- internal representation of CSS entrypoints for themes. This is an internal change only and does
171
- not effect public APIs.
189
+ - [#21487](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21487)
190
+ [`4942487a9f6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4942487a9f6) - Fixes
191
+ internal representation of CSS entrypoints for themes. This is an internal change only and does
192
+ not effect public APIs.
172
193
 
173
194
  ## 0.2.5
174
195
 
175
196
  ### Patch Changes
176
197
 
177
- - Updated dependencies
198
+ - Updated dependencies
178
199
 
179
200
  ## 0.2.4
180
201
 
181
202
  ### Patch Changes
182
203
 
183
- - Updated dependencies
204
+ - Updated dependencies
184
205
 
185
206
  ## 0.2.3
186
207
 
187
208
  ### Patch Changes
188
209
 
189
- - Updated dependencies
210
+ - Updated dependencies
190
211
 
191
212
  ## 0.2.2
192
213
 
193
214
  ### Patch Changes
194
215
 
195
- - Updated dependencies
216
+ - Updated dependencies
196
217
 
197
218
  ## 0.2.1
198
219
 
199
220
  ### Patch Changes
200
221
 
201
- - Updated dependencies
222
+ - Updated dependencies
202
223
 
203
224
  ## 0.2.0
204
225
 
205
226
  ### Minor Changes
206
227
 
207
- - [#18080](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18080)
208
- [`068c9a0b770`](https://bitbucket.org/atlassian/atlassian-frontend/commits/068c9a0b770) -
209
- Refactors the storybook addon into a "tool addon"
228
+ - [#18080](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18080)
229
+ [`068c9a0b770`](https://bitbucket.org/atlassian/atlassian-frontend/commits/068c9a0b770) -
230
+ Refactors the storybook addon into a "tool addon"
210
231
 
211
232
  ## 0.1.1
212
233
 
213
234
  ### Patch Changes
214
235
 
215
- - [#18020](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18020)
216
- [`32f8832d6c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/32f8832d6c5) -
217
- Temporarily disable css imports to side-step recent changes to the monorepo which trigged a bug
236
+ - [#18020](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18020)
237
+ [`32f8832d6c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/32f8832d6c5) -
238
+ Temporarily disable css imports to side-step recent changes to the monorepo which trigged a bug
218
239
 
219
240
  ## 0.1.0
220
241
 
221
242
  ### Minor Changes
222
243
 
223
- - [#17460](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/17460)
224
- [`ddbec37a16c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ddbec37a16c) -
225
- Initial release of the design system storybook addon package. Intended to be a generic package
226
- for all storybook releated DS tooling
244
+ - [#17460](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/17460)
245
+ [`ddbec37a16c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ddbec37a16c) - Initial
246
+ release of the design system storybook addon package. Intended to be a generic package for all
247
+ storybook releated DS tooling
@@ -1,4 +1,5 @@
1
- After installing the package, register the addon with your Storybook configuration in the `.storybook/main.js` file.
1
+ After installing the package, register the addon with your Storybook configuration in the
2
+ `.storybook/main.js` file.
2
3
 
3
4
  ```diff
4
5
  module.exports = {
@@ -10,7 +11,8 @@ module.exports = {
10
11
 
11
12
  ## Storybook v6 and below
12
13
 
13
- Add the decorator to `.storybook/preview.js`, which is responsible for applying the logic which has the ability to modify the DOM of your stories.
14
+ Add the decorator to `.storybook/preview.js`, which is responsible for applying the logic which has
15
+ the ability to modify the DOM of your stories.
14
16
 
15
17
  ```diff
16
18
  + import { withDesignTokens } from '@atlaskit/storybook-addon-design-system';
@@ -25,9 +27,12 @@ const { addDecorator } = require('@storybook/react');
25
27
  For Storybook version 7, the following changes are necessary:
26
28
 
27
29
  1. Initialising the `globalTypes.adsTheme` property in the global context
28
- 2. Disable the [built in `backgrounds` add on](https://storybook.js.org/docs/essentials/backgrounds#disable-backgrounds), as it conflicts with the ADS theming
30
+ 2. Disable the
31
+ [built in `backgrounds` add on](https://storybook.js.org/docs/essentials/backgrounds#disable-backgrounds),
32
+ as it conflicts with the ADS theming
29
33
 
30
- Both of these can be done in [the `preview` file](https://storybook.js.org/docs/configure#configure-story-rendering):
34
+ Both of these can be done in
35
+ [the `preview` file](https://storybook.js.org/docs/configure#configure-story-rendering):
31
36
 
32
37
  ```diff
33
38
  + import { withDesignTokens } from '@atlaskit/storybook-addon-design-system';
@@ -2,12 +2,15 @@
2
2
  order: 0
3
3
  ---
4
4
 
5
- The Design System Storybook Addon allows you to test your UI components in various themes, directly in Storybook.
6
- It allows you to visualize and compare component appearances across different themes, ensuring correct and consistent design token application.
5
+ The Design System Storybook Addon allows you to test your UI components in various themes, directly
6
+ in Storybook. It allows you to visualize and compare component appearances across different themes,
7
+ ensuring correct and consistent design token application.
7
8
 
8
9
  ![Design tokens storybook addon screenshot](../images/storybook-addon.png 'Design tokens storybook addon screenshot')
9
10
 
10
11
  ## Features
11
12
 
12
- - **Theme Testing:** Test UI components in multiple themes to ensure they look good across various styles and branding choices.
13
- - **Split View:** The split view functionality allows you compare components side-by-side in different themes.
13
+ - **Theme Testing:** Test UI components in multiple themes to ensure they look good across various
14
+ styles and branding choices.
15
+ - **Split View:** The split view functionality allows you compare components side-by-side in
16
+ different themes.
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _previewApi = require("@storybook/preview-api");
14
+ var _tokens = require("@atlaskit/tokens");
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ var splitColumnStyles = {
20
+ position: 'absolute',
21
+ boxSizing: 'border-box',
22
+ width: '50vw',
23
+ height: '100vh',
24
+ overflow: 'auto',
25
+ padding: '10px',
26
+ background: (0, _tokens.token)('elevation.surface'),
27
+ color: (0, _tokens.token)('color.text')
28
+ };
29
+ var stackColumnStyles = {
30
+ position: 'absolute',
31
+ boxSizing: 'border-box',
32
+ width: '100%',
33
+ height: '50%',
34
+ overflow: 'auto',
35
+ padding: '10px',
36
+ background: (0, _tokens.token)('elevation.surface'),
37
+ color: (0, _tokens.token)('color.text')
38
+ };
39
+ var withDesignTokens = function withDesignTokens(StoryFn, context) {
40
+ var theme = context.globals.adsTheme || 'auto';
41
+
42
+ // eslint-disable-next-line react-hooks/rules-of-hooks
43
+ (0, _previewApi.useEffect)(function () {
44
+ (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
45
+ return _regenerator.default.wrap(function _callee$(_context) {
46
+ while (1) switch (_context.prev = _context.next) {
47
+ case 0:
48
+ _context.t0 = theme;
49
+ _context.next = _context.t0 === 'light' ? 3 : _context.t0 === 'dark' ? 3 : _context.t0 === 'auto' ? 3 : _context.t0 === 'split' ? 6 : _context.t0 === 'stack' ? 6 : _context.t0 === 'none' ? 10 : 14;
50
+ break;
51
+ case 3:
52
+ _context.next = 5;
53
+ return (0, _tokens.setGlobalTheme)({
54
+ colorMode: theme,
55
+ spacing: 'spacing',
56
+ shape: 'shape',
57
+ typography: 'typography-minor3'
58
+ });
59
+ case 5:
60
+ return _context.abrupt("break", 15);
61
+ case 6:
62
+ _context.next = 8;
63
+ return (0, _tokens.setGlobalTheme)({
64
+ colorMode: 'light',
65
+ spacing: 'spacing',
66
+ shape: 'shape',
67
+ typography: 'typography-minor3'
68
+ });
69
+ case 8:
70
+ document.documentElement.querySelectorAll('style[data-theme]').forEach(function (el) {
71
+ var clone = el.cloneNode(true);
72
+ clone.setAttribute('data-theme', clone.getAttribute('data-theme') + '-clone');
73
+ // HACK: re-target theme selectors to split div containers
74
+ clone.textContent = clone.textContent.replace(/html\[/g, '[');
75
+ document.head.append(clone);
76
+ });
77
+ return _context.abrupt("break", 15);
78
+ case 10:
79
+ delete document.documentElement.dataset.theme;
80
+ delete document.documentElement.dataset.colorMode;
81
+ document.documentElement.querySelectorAll('style[data-theme]').forEach(function (el) {
82
+ return el.remove();
83
+ });
84
+ return _context.abrupt("break", 15);
85
+ case 14:
86
+ return _context.abrupt("break", 15);
87
+ case 15:
88
+ case "end":
89
+ return _context.stop();
90
+ }
91
+ }, _callee);
92
+ }))();
93
+ }, [context.id, theme]);
94
+ function renderStory() {
95
+ var story = StoryFn(_objectSpread(_objectSpread({}, context), {}, {
96
+ globals: _objectSpread(_objectSpread({}, context.globals), {}, {
97
+ adsTheme: theme
98
+ })
99
+ }));
100
+ if (theme === 'split' || theme === 'stack') {
101
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
102
+ "data-theme": "light:light",
103
+ "data-color-mode": "light"
104
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
105
+ ,
106
+ style: theme === 'split' ? _objectSpread(_objectSpread({}, splitColumnStyles), {}, {
107
+ inset: '0px 50vw 0px 0px'
108
+ }) : _objectSpread(_objectSpread({}, stackColumnStyles), {}, {
109
+ inset: '0px 0px 50% 0px'
110
+ })
111
+ }, story), /*#__PURE__*/_react.default.createElement("div", {
112
+ "data-theme": "dark:dark",
113
+ "data-color-mode": "dark"
114
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
115
+ ,
116
+ style: theme === 'split' ? _objectSpread(_objectSpread({}, splitColumnStyles), {}, {
117
+ inset: '0px 0px 0px 50vw'
118
+ }) : _objectSpread(_objectSpread({}, stackColumnStyles), {}, {
119
+ inset: '50% 0px 0px 0px'
120
+ })
121
+ }, story));
122
+ }
123
+ return /*#__PURE__*/_react.default.createElement("div", null, story);
124
+ }
125
+ return renderStory();
126
+ };
127
+ var _default = exports.default = withDesignTokens;
package/dist/cjs/index.js CHANGED
@@ -3,10 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "withDesignTokens", {
7
- enumerable: true,
8
- get: function get() {
9
- return _tokens.withDesignTokens;
10
- }
11
- });
12
- var _tokens = require("./tokens");
6
+ exports.default = void 0;
7
+ // eslint-disable-next-line import/no-anonymous-default-export
8
+ var _default = exports.default = {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _managerApi = require("@storybook/manager-api");
5
+ var _constants = require("./constants");
6
+ var _tool = _interopRequireDefault(require("./tool"));
7
+ _managerApi.addons.register(_constants.ADDON_ID, function () {
8
+ _managerApi.addons.add(_constants.TOOL_ID, {
9
+ type: _managerApi.types.TOOL,
10
+ title: _constants.TITLE,
11
+ match: function match(_ref) {
12
+ var viewMode = _ref.viewMode;
13
+ return !!(viewMode && viewMode.match(/^(story|docs)$/));
14
+ },
15
+ render: _tool.default
16
+ });
17
+ });
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.webpack = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var webpack = exports.webpack = /*#__PURE__*/function () {
11
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(config) {
12
+ return _regenerator.default.wrap(function _callee$(_context) {
13
+ while (1) switch (_context.prev = _context.next) {
14
+ case 0:
15
+ return _context.abrupt("return", config);
16
+ case 1:
17
+ case "end":
18
+ return _context.stop();
19
+ }
20
+ }, _callee);
21
+ }));
22
+ return function webpack(_x) {
23
+ return _ref.apply(this, arguments);
24
+ };
25
+ }();
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _decorator = _interopRequireDefault(require("./decorator"));
9
+ /**
10
+ * A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators
11
+ * in order to augment stories:
12
+ * - with extra rendering
13
+ * - gather details about how a story is rendered
14
+ *
15
+ * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.
16
+ *
17
+ * https://storybook.js.org/docs/react/writing-stories/decorators
18
+ */
19
+
20
+ var preview = {
21
+ decorators: [_decorator.default],
22
+ globals: {
23
+ adsTheme: 'auto'
24
+ }
25
+ };
26
+ var _default = exports.default = preview;