@atlaskit/storybook-addon-design-system 0.8.0 → 1.0.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 (75) hide show
  1. package/CHANGELOG.md +93 -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 +81 -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/tsup.config.ts +110 -0
  44. package/dist/cjs/tokens/components/index.js +0 -13
  45. package/dist/cjs/tokens/decorator.js +0 -128
  46. package/dist/cjs/tokens/index.js +0 -13
  47. package/dist/cjs/tokens/register.js +0 -16
  48. package/dist/es2019/tokens/components/index.js +0 -1
  49. package/dist/es2019/tokens/decorator.js +0 -107
  50. package/dist/es2019/tokens/index.js +0 -1
  51. package/dist/esm/tokens/components/index.js +0 -1
  52. package/dist/esm/tokens/decorator.js +0 -118
  53. package/dist/esm/tokens/index.js +0 -1
  54. package/dist/types/tokens/components/index.d.ts +0 -1
  55. package/dist/types/tokens/decorator.d.ts +0 -2
  56. package/dist/types/tokens/index.d.ts +0 -1
  57. package/dist/types-ts4.5/tokens/components/index.d.ts +0 -1
  58. package/dist/types-ts4.5/tokens/decorator.d.ts +0 -2
  59. package/dist/types-ts4.5/tokens/index.d.ts +0 -1
  60. package/register-tokens.js +0 -2
  61. package/register.js +0 -2
  62. /package/dist/cjs/{tokens/constants.js → constants.js} +0 -0
  63. /package/dist/cjs/{tokens/types.js → types.js} +0 -0
  64. /package/dist/es2019/{tokens/constants.js → constants.js} +0 -0
  65. /package/dist/es2019/{tokens/types.js → types.js} +0 -0
  66. /package/dist/esm/{tokens/constants.js → constants.js} +0 -0
  67. /package/dist/esm/{tokens/types.js → types.js} +0 -0
  68. /package/dist/types/{tokens/constants.d.ts → constants.d.ts} +0 -0
  69. /package/dist/types/{tokens/register.d.ts → manager.d.ts} +0 -0
  70. /package/dist/types/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
  71. /package/dist/types/{tokens/types.d.ts → types.d.ts} +0 -0
  72. /package/dist/types-ts4.5/{tokens/constants.d.ts → constants.d.ts} +0 -0
  73. /package/dist/types-ts4.5/{tokens/register.d.ts → manager.d.ts} +0 -0
  74. /package/dist/types-ts4.5/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
  75. /package/dist/types-ts4.5/{tokens/types.d.ts → types.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,226 +1,239 @@
1
1
  # @atlaskit/storybook-addon-design-system
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#121263](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121263)
8
+ [`9b5e0cb70a67b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9b5e0cb70a67b) -
9
+ @atlaskit/storybook-addon-design-system has migrated to Storybook 8.0. Use the previous version if
10
+ your project is still on v6 or v7.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 0.8.0
4
17
 
5
18
  ### Minor Changes
6
19
 
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.
20
+ - [#94453](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94453)
21
+ [`8b0ba81b30b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8b0ba81b30b3) -
22
+ Add support for React 18 in non-strict mode.
10
23
 
11
24
  ## 0.7.1
12
25
 
13
26
  ### Patch Changes
14
27
 
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
28
+ - [#93943](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93943)
29
+ [`611f5e98470c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/611f5e98470c) -
30
+ Removes fallback colors from styles
18
31
 
19
32
  ## 0.7.0
20
33
 
21
34
  ### Minor Changes
22
35
 
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.
36
+ - [#94436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94436)
37
+ [`c652e1c27a4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c652e1c27a4d) -
38
+ Updates the default theme to 'auto' to ensure tokens are always applied. "Unthemed" or "No theme"
39
+ is now considered an unsafe appearance.
27
40
 
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).
41
+ If you prefer to use a different theme, you can still override the default theme by setting the
42
+ `adeTheme.defaultValue: 'none'` as mentioned in
43
+ [the documentation](https://staging.atlassian.design/components/storybook-addon-design-system/code#storybook-v7-and-above).
31
44
 
32
45
  ## 0.6.0
33
46
 
34
47
  ### Minor Changes
35
48
 
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
49
+ - [#77691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77691)
50
+ [`14d18ea34852`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/14d18ea34852) - -
51
+ Enables new `typography` and `shape` themes
52
+ - Sets the color theme to `auto` by default
40
53
 
41
54
  ## 0.5.2
42
55
 
43
56
  ### Patch Changes
44
57
 
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.
58
+ - [#32935](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32935)
59
+ [`b1bdec7cce2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b1bdec7cce2) - Internal
60
+ change to enforce token usage for spacing properties. There is no expected visual or behaviour
61
+ change.
49
62
 
50
63
  ## 0.5.1
51
64
 
52
65
  ### Patch Changes
53
66
 
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
67
+ - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793)
68
+ [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure
69
+ legacy types are published for TS 4.5-4.8
57
70
 
58
71
  ## 0.5.0
59
72
 
60
73
  ### Minor Changes
61
74
 
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
75
+ - [#33632](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33632)
76
+ [`389ab86b2a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/389ab86b2a3) - Adding
77
+ spacing tokens to storybook addon so that users spacing tokens appear in storybook
65
78
 
66
79
  ### Patch Changes
67
80
 
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`
81
+ - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649)
82
+ [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade
83
+ Typescript from `4.5.5` to `4.9.5`
71
84
 
72
85
  ## 0.4.0
73
86
 
74
87
  ### Minor Changes
75
88
 
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
89
+ - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258)
90
+ [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip
91
+ minor dependency bump
79
92
 
80
93
  ### Patch Changes
81
94
 
82
- - Updated dependencies
95
+ - Updated dependencies
83
96
 
84
97
  ## 0.3.9
85
98
 
86
99
  ### Patch Changes
87
100
 
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
101
+ - [#27634](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27634)
102
+ [`718d5ad3044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/718d5ad3044) - Updates
103
+ to support the new `@atlaskit/tokens` theming API.
104
+ - Updated dependencies
92
105
 
93
106
  ## 0.3.8
94
107
 
95
108
  ### Patch Changes
96
109
 
97
- - Updated dependencies
110
+ - Updated dependencies
98
111
 
99
112
  ## 0.3.7
100
113
 
101
114
  ### Patch Changes
102
115
 
103
- - Updated dependencies
116
+ - Updated dependencies
104
117
 
105
118
  ## 0.3.6
106
119
 
107
120
  ### Patch Changes
108
121
 
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
122
+ - [#27629](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27629)
123
+ [`f824dcfff6e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f824dcfff6e) - Internal
124
+ changes to satisfy various lint warnings & errors
112
125
 
113
126
  ## 0.3.5
114
127
 
115
128
  ### Patch Changes
116
129
 
117
- - Updated dependencies
130
+ - Updated dependencies
118
131
 
119
132
  ## 0.3.4
120
133
 
121
134
  ### Patch Changes
122
135
 
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
136
+ - [#26467](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26467)
137
+ [`43464a5fb17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43464a5fb17) - Update
138
+ split and stack theme settings to use tilde selectors
126
139
 
127
140
  ## 0.3.3
128
141
 
129
142
  ### Patch Changes
130
143
 
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.
144
+ - [#26303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26303)
145
+ [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op
146
+ change to introduce spacing tokens to design system components.
134
147
 
135
148
  ## 0.3.2
136
149
 
137
150
  ### Patch Changes
138
151
 
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!
152
+ - [#24660](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24660)
153
+ [`d4be43fdc44`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d4be43fdc44) - Set the
154
+ innerText in our hack correctly - oops!
142
155
 
143
156
  ## 0.3.1
144
157
 
145
158
  ### Patch Changes
146
159
 
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
160
+ - [#24626](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24626)
161
+ [`6dd7050ad7a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6dd7050ad7a) -
162
+ Reimplement the style tag hack required for enabling split & stack view in the Storybook addon
150
163
 
151
164
  ## 0.3.0
152
165
 
153
166
  ### Minor Changes
154
167
 
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
168
+ - [#21484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21484)
169
+ [`6c65a3147c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c65a3147c1) - Removes
170
+ root selector hack from lightmode, this is no longer necessary since the default theme no longer
171
+ enables tokens by default
159
172
 
160
173
  ### Patch Changes
161
174
 
162
- - Updated dependencies
175
+ - Updated dependencies
163
176
 
164
177
  ## 0.2.6
165
178
 
166
179
  ### Patch Changes
167
180
 
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.
181
+ - [#21487](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21487)
182
+ [`4942487a9f6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4942487a9f6) - Fixes
183
+ internal representation of CSS entrypoints for themes. This is an internal change only and does
184
+ not effect public APIs.
172
185
 
173
186
  ## 0.2.5
174
187
 
175
188
  ### Patch Changes
176
189
 
177
- - Updated dependencies
190
+ - Updated dependencies
178
191
 
179
192
  ## 0.2.4
180
193
 
181
194
  ### Patch Changes
182
195
 
183
- - Updated dependencies
196
+ - Updated dependencies
184
197
 
185
198
  ## 0.2.3
186
199
 
187
200
  ### Patch Changes
188
201
 
189
- - Updated dependencies
202
+ - Updated dependencies
190
203
 
191
204
  ## 0.2.2
192
205
 
193
206
  ### Patch Changes
194
207
 
195
- - Updated dependencies
208
+ - Updated dependencies
196
209
 
197
210
  ## 0.2.1
198
211
 
199
212
  ### Patch Changes
200
213
 
201
- - Updated dependencies
214
+ - Updated dependencies
202
215
 
203
216
  ## 0.2.0
204
217
 
205
218
  ### Minor Changes
206
219
 
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"
220
+ - [#18080](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18080)
221
+ [`068c9a0b770`](https://bitbucket.org/atlassian/atlassian-frontend/commits/068c9a0b770) -
222
+ Refactors the storybook addon into a "tool addon"
210
223
 
211
224
  ## 0.1.1
212
225
 
213
226
  ### Patch Changes
214
227
 
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
228
+ - [#18020](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18020)
229
+ [`32f8832d6c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/32f8832d6c5) -
230
+ Temporarily disable css imports to side-step recent changes to the monorepo which trigged a bug
218
231
 
219
232
  ## 0.1.0
220
233
 
221
234
  ### Minor Changes
222
235
 
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
236
+ - [#17460](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/17460)
237
+ [`ddbec37a16c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ddbec37a16c) - Initial
238
+ release of the design system storybook addon package. Intended to be a generic package for all
239
+ 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;