@atlaskit/storybook-addon-design-system 0.7.1 → 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.
- package/CHANGELOG.md +86 -20
- package/constellation/index/props.mdx +9 -4
- package/constellation/index/usage.mdx +7 -4
- package/dist/cjs/decorator.js +127 -0
- package/dist/cjs/index.js +3 -7
- package/dist/cjs/manager.js +17 -0
- package/dist/cjs/preset.js +25 -0
- package/dist/cjs/preview.js +26 -0
- package/dist/cjs/{tokens/components/tool.js → tool.js} +19 -24
- package/dist/es2019/decorator.js +106 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/{tokens/register.js → manager.js} +2 -2
- package/dist/es2019/preset.js +3 -0
- package/dist/es2019/preview.js +19 -0
- package/dist/es2019/{tokens/components/tool.js → tool.js} +18 -23
- package/dist/esm/decorator.js +117 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/{tokens/register.js → manager.js} +2 -2
- package/dist/esm/preset.js +18 -0
- package/dist/esm/preview.js +19 -0
- package/dist/esm/{tokens/components/tool.js → tool.js} +19 -24
- package/dist/types/decorator.d.ts +4 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/preset.d.ts +1 -0
- package/dist/types/preview.d.ts +13 -0
- package/dist/types-ts4.5/decorator.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/preset.d.ts +1 -0
- package/dist/types-ts4.5/preview.d.ts +13 -0
- package/manager.js +2 -0
- package/package.json +81 -66
- package/preset.js +2 -0
- package/preview.js +2 -0
- package/report.api.md +3 -2
- package/src/constants.tsx +5 -0
- package/src/decorator.tsx +125 -0
- package/src/index.tsx +2 -0
- package/src/manager.tsx +13 -0
- package/src/preset.tsx +3 -0
- package/src/preview.tsx +22 -0
- package/src/tool.tsx +76 -0
- package/src/types.tsx +1 -0
- package/tsup.config.ts +110 -0
- package/dist/cjs/tokens/components/index.js +0 -13
- package/dist/cjs/tokens/decorator.js +0 -128
- package/dist/cjs/tokens/index.js +0 -13
- package/dist/cjs/tokens/register.js +0 -16
- package/dist/es2019/tokens/components/index.js +0 -1
- package/dist/es2019/tokens/decorator.js +0 -107
- package/dist/es2019/tokens/index.js +0 -1
- package/dist/esm/tokens/components/index.js +0 -1
- package/dist/esm/tokens/decorator.js +0 -118
- package/dist/esm/tokens/index.js +0 -1
- package/dist/types/tokens/components/index.d.ts +0 -1
- package/dist/types/tokens/decorator.d.ts +0 -2
- package/dist/types/tokens/index.d.ts +0 -1
- package/dist/types-ts4.5/tokens/components/index.d.ts +0 -1
- package/dist/types-ts4.5/tokens/decorator.d.ts +0 -2
- package/dist/types-ts4.5/tokens/index.d.ts +0 -1
- package/register-tokens.js +0 -2
- package/register.js +0 -2
- /package/dist/cjs/{tokens/constants.js → constants.js} +0 -0
- /package/dist/cjs/{tokens/types.js → types.js} +0 -0
- /package/dist/es2019/{tokens/constants.js → constants.js} +0 -0
- /package/dist/es2019/{tokens/types.js → types.js} +0 -0
- /package/dist/esm/{tokens/constants.js → constants.js} +0 -0
- /package/dist/esm/{tokens/types.js → types.js} +0 -0
- /package/dist/types/{tokens/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/types/{tokens/register.d.ts → manager.d.ts} +0 -0
- /package/dist/types/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
- /package/dist/types/{tokens/types.d.ts → types.d.ts} +0 -0
- /package/dist/types-ts4.5/{tokens/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/types-ts4.5/{tokens/register.d.ts → manager.d.ts} +0 -0
- /package/dist/types-ts4.5/{tokens/components/tool.d.ts → tool.d.ts} +0 -0
- /package/dist/types-ts4.5/{tokens/types.d.ts → types.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,53 +1,94 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.8.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
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.
|
|
23
|
+
|
|
3
24
|
## 0.7.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
6
27
|
|
|
7
|
-
- [#93943](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93943)
|
|
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
|
|
8
31
|
|
|
9
32
|
## 0.7.0
|
|
10
33
|
|
|
11
34
|
### Minor Changes
|
|
12
35
|
|
|
13
|
-
- [#94436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94436)
|
|
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.
|
|
14
40
|
|
|
15
|
-
If you prefer to use a different theme, you can still override the default theme by setting the
|
|
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).
|
|
16
44
|
|
|
17
45
|
## 0.6.0
|
|
18
46
|
|
|
19
47
|
### Minor Changes
|
|
20
48
|
|
|
21
|
-
- [#77691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77691)
|
|
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
|
|
22
52
|
- Sets the color theme to `auto` by default
|
|
23
53
|
|
|
24
54
|
## 0.5.2
|
|
25
55
|
|
|
26
56
|
### Patch Changes
|
|
27
57
|
|
|
28
|
-
- [#32935](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32935)
|
|
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.
|
|
29
62
|
|
|
30
63
|
## 0.5.1
|
|
31
64
|
|
|
32
65
|
### Patch Changes
|
|
33
66
|
|
|
34
|
-
- [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793)
|
|
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
|
|
35
70
|
|
|
36
71
|
## 0.5.0
|
|
37
72
|
|
|
38
73
|
### Minor Changes
|
|
39
74
|
|
|
40
|
-
- [#33632](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33632)
|
|
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
|
|
41
78
|
|
|
42
79
|
### Patch Changes
|
|
43
80
|
|
|
44
|
-
- [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649)
|
|
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`
|
|
45
84
|
|
|
46
85
|
## 0.4.0
|
|
47
86
|
|
|
48
87
|
### Minor Changes
|
|
49
88
|
|
|
50
|
-
- [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258)
|
|
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
|
|
51
92
|
|
|
52
93
|
### Patch Changes
|
|
53
94
|
|
|
@@ -57,7 +98,9 @@
|
|
|
57
98
|
|
|
58
99
|
### Patch Changes
|
|
59
100
|
|
|
60
|
-
- [#27634](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27634)
|
|
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.
|
|
61
104
|
- Updated dependencies
|
|
62
105
|
|
|
63
106
|
## 0.3.8
|
|
@@ -76,7 +119,9 @@
|
|
|
76
119
|
|
|
77
120
|
### Patch Changes
|
|
78
121
|
|
|
79
|
-
- [#27629](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27629)
|
|
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
|
|
80
125
|
|
|
81
126
|
## 0.3.5
|
|
82
127
|
|
|
@@ -88,31 +133,42 @@
|
|
|
88
133
|
|
|
89
134
|
### Patch Changes
|
|
90
135
|
|
|
91
|
-
- [#26467](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26467)
|
|
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
|
|
92
139
|
|
|
93
140
|
## 0.3.3
|
|
94
141
|
|
|
95
142
|
### Patch Changes
|
|
96
143
|
|
|
97
|
-
- [#26303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26303)
|
|
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.
|
|
98
147
|
|
|
99
148
|
## 0.3.2
|
|
100
149
|
|
|
101
150
|
### Patch Changes
|
|
102
151
|
|
|
103
|
-
- [#24660](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24660)
|
|
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!
|
|
104
155
|
|
|
105
156
|
## 0.3.1
|
|
106
157
|
|
|
107
158
|
### Patch Changes
|
|
108
159
|
|
|
109
|
-
- [#24626](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24626)
|
|
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
|
|
110
163
|
|
|
111
164
|
## 0.3.0
|
|
112
165
|
|
|
113
166
|
### Minor Changes
|
|
114
167
|
|
|
115
|
-
- [#21484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21484)
|
|
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
|
|
116
172
|
|
|
117
173
|
### Patch Changes
|
|
118
174
|
|
|
@@ -122,7 +178,10 @@
|
|
|
122
178
|
|
|
123
179
|
### Patch Changes
|
|
124
180
|
|
|
125
|
-
- [#21487](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/21487)
|
|
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.
|
|
126
185
|
|
|
127
186
|
## 0.2.5
|
|
128
187
|
|
|
@@ -158,16 +217,23 @@
|
|
|
158
217
|
|
|
159
218
|
### Minor Changes
|
|
160
219
|
|
|
161
|
-
- [#18080](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18080)
|
|
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"
|
|
162
223
|
|
|
163
224
|
## 0.1.1
|
|
164
225
|
|
|
165
226
|
### Patch Changes
|
|
166
227
|
|
|
167
|
-
- [#18020](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18020)
|
|
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
|
|
168
231
|
|
|
169
232
|
## 0.1.0
|
|
170
233
|
|
|
171
234
|
### Minor Changes
|
|
172
235
|
|
|
173
|
-
- [#17460](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/17460)
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
6
|
-
It allows you to visualize and compare component appearances across different themes,
|
|
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
|

|
|
9
10
|
|
|
10
11
|
## Features
|
|
11
12
|
|
|
12
|
-
- **Theme Testing:** Test UI components in multiple themes to ensure they look good across various
|
|
13
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
@@ -8,35 +8,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _api = require("@storybook/api");
|
|
12
11
|
var _components = require("@storybook/components");
|
|
13
|
-
var
|
|
12
|
+
var _icons = require("@storybook/icons");
|
|
13
|
+
var _managerApi = require("@storybook/manager-api");
|
|
14
|
+
var _constants = require("./constants");
|
|
14
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); }
|
|
15
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; }
|
|
16
17
|
var themeOptions = [{
|
|
17
18
|
id: 'auto',
|
|
18
19
|
title: 'Same as system',
|
|
19
|
-
icon:
|
|
20
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.MirrorIcon, null)
|
|
20
21
|
}, {
|
|
21
22
|
id: 'light',
|
|
22
23
|
title: 'Light theme',
|
|
23
|
-
icon:
|
|
24
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.CircleHollowIcon, null)
|
|
24
25
|
}, {
|
|
25
26
|
id: 'dark',
|
|
26
27
|
title: 'Dark theme',
|
|
27
|
-
icon:
|
|
28
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.CircleIcon, null)
|
|
28
29
|
}, {
|
|
29
30
|
id: 'split',
|
|
30
31
|
title: 'Side by side',
|
|
31
|
-
icon:
|
|
32
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.SidebarIcon, null)
|
|
32
33
|
}, {
|
|
33
34
|
id: 'stack',
|
|
34
35
|
title: 'Stacked',
|
|
35
|
-
icon:
|
|
36
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.BottomBarIcon, null)
|
|
36
37
|
}, {
|
|
37
38
|
id: 'none',
|
|
38
39
|
title: 'Disable (Unsafe)',
|
|
39
|
-
icon:
|
|
40
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.CrossIcon, null)
|
|
40
41
|
}];
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -50,7 +51,7 @@ var Tool = function Tool() {
|
|
|
50
51
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
52
|
isVisible = _useState2[0],
|
|
52
53
|
setIsVisible = _useState2[1];
|
|
53
|
-
var _useGlobals = (0,
|
|
54
|
+
var _useGlobals = (0, _managerApi.useGlobals)(),
|
|
54
55
|
_useGlobals2 = (0, _slicedToArray2.default)(_useGlobals, 2),
|
|
55
56
|
adsTheme = _useGlobals2[0].adsTheme,
|
|
56
57
|
updateGlobals = _useGlobals2[1];
|
|
@@ -61,9 +62,10 @@ var Tool = function Tool() {
|
|
|
61
62
|
}, [updateGlobals]);
|
|
62
63
|
return /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
|
|
63
64
|
placement: "top",
|
|
64
|
-
trigger: "click"
|
|
65
|
-
closeOnClick
|
|
66
|
-
|
|
65
|
+
trigger: "click"
|
|
66
|
+
// closeOnClick
|
|
67
|
+
,
|
|
68
|
+
onVisibleChange: setIsVisible,
|
|
67
69
|
tooltip: function tooltip(_ref) {
|
|
68
70
|
var onHide = _ref.onHide;
|
|
69
71
|
return /*#__PURE__*/_react.default.createElement(_components.TooltipLinkList, {
|
|
@@ -75,12 +77,7 @@ var Tool = function Tool() {
|
|
|
75
77
|
id: id,
|
|
76
78
|
title: title,
|
|
77
79
|
active: adsTheme === id,
|
|
78
|
-
|
|
79
|
-
style: {
|
|
80
|
-
opacity: 1
|
|
81
|
-
},
|
|
82
|
-
icon: icon
|
|
83
|
-
}),
|
|
80
|
+
icon: icon,
|
|
84
81
|
onClick: function onClick() {
|
|
85
82
|
setTheme(id);
|
|
86
83
|
onHide();
|
|
@@ -93,11 +90,9 @@ var Tool = function Tool() {
|
|
|
93
90
|
key: _constants.TOOL_ID,
|
|
94
91
|
active: isVisible,
|
|
95
92
|
title: "Apply ADS themes to your story"
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
})) === null || _themeOptions$find === void 0 ? void 0 : _themeOptions$find.icon) || 'circlehollow'
|
|
101
|
-
}), '\xa0ADS Theme'));
|
|
93
|
+
}, (_themeOptions$find = themeOptions.find(function (_ref3) {
|
|
94
|
+
var id = _ref3.id;
|
|
95
|
+
return adsTheme === id;
|
|
96
|
+
})) === null || _themeOptions$find === void 0 ? void 0 : _themeOptions$find.icon, '\xa0ADS Theme'));
|
|
102
97
|
};
|
|
103
98
|
var _default = exports.default = Tool;
|