@atlaskit/storybook-addon-design-system 3.0.0 → 3.1.1
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 +15 -0
- package/constellation/index/props.mdx +19 -0
- package/dist/cjs/decorator.js +1 -2
- package/dist/cjs/tool.js +8 -3
- package/dist/es2019/tool.js +9 -3
- package/dist/esm/tool.js +9 -3
- package/package.json +2 -2
- package/src/tool.tsx +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/storybook-addon-design-system
|
|
2
2
|
|
|
3
|
+
## 3.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#154276](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154276)
|
|
14
|
+
[`917104b6edd11`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/917104b6edd11) -
|
|
15
|
+
Introduced `adsTheme` parameter for customizing the theme in preview.js that allows overriding the
|
|
16
|
+
theme with custom values 'light' or 'dark'.
|
|
17
|
+
|
|
3
18
|
## 3.0.0
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
|
@@ -11,6 +11,25 @@
|
|
|
11
11
|
};
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
By default, the theme is set to auto (which matches the browser's theme). However, you can easily
|
|
15
|
+
override this default by specifying a custom theme using the adsTheme parameter in your
|
|
16
|
+
`.storybook/preview.js` file.
|
|
17
|
+
|
|
18
|
+
### Example Usage
|
|
19
|
+
|
|
20
|
+
In your `.storybook/preview.js` file, you can set the adsTheme parameter to either 'light' or
|
|
21
|
+
'dark':
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const preview: Preview = {
|
|
25
|
+
parameters: {
|
|
26
|
+
adsTheme: 'light' | 'dark',
|
|
27
|
+
}
|
|
28
|
+
// ... other parameters
|
|
29
|
+
}
|
|
30
|
+
export default preview;
|
|
31
|
+
```
|
|
32
|
+
|
|
14
33
|
## Storybook v7
|
|
15
34
|
|
|
16
35
|
1. Install a pre-1.0 version of the addon (e.g., `0.8.0`).
|
package/dist/cjs/decorator.js
CHANGED
|
@@ -12,8 +12,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _previewApi = require("@storybook/preview-api");
|
|
14
14
|
var _tokens = require("@atlaskit/tokens");
|
|
15
|
-
function
|
|
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 && {}.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; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
17
16
|
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
17
|
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
18
|
var splitColumnStyles = {
|
package/dist/cjs/tool.js
CHANGED
|
@@ -12,8 +12,7 @@ var _components = require("@storybook/components");
|
|
|
12
12
|
var _icons = require("@storybook/icons");
|
|
13
13
|
var _managerApi = require("@storybook/manager-api");
|
|
14
14
|
var _constants = require("./constants");
|
|
15
|
-
function
|
|
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 && {}.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; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
17
16
|
var themeOptions = [{
|
|
18
17
|
id: 'auto',
|
|
19
18
|
title: 'Same as system',
|
|
@@ -53,8 +52,14 @@ var Tool = function Tool() {
|
|
|
53
52
|
setIsVisible = _useState2[1];
|
|
54
53
|
var _useGlobals = (0, _managerApi.useGlobals)(),
|
|
55
54
|
_useGlobals2 = (0, _slicedToArray2.default)(_useGlobals, 2),
|
|
56
|
-
|
|
55
|
+
originalAdsTheme = _useGlobals2[0].adsTheme,
|
|
57
56
|
updateGlobals = _useGlobals2[1];
|
|
57
|
+
var adsTheme = (0, _managerApi.useParameter)('adsTheme', originalAdsTheme || 'auto');
|
|
58
|
+
(0, _react.useEffect)(function () {
|
|
59
|
+
updateGlobals({
|
|
60
|
+
adsTheme: adsTheme
|
|
61
|
+
});
|
|
62
|
+
}, [adsTheme, updateGlobals]);
|
|
58
63
|
var setTheme = (0, _react.useCallback)(function (theme) {
|
|
59
64
|
return updateGlobals({
|
|
60
65
|
adsTheme: theme
|
package/dist/es2019/tool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
|
|
3
3
|
import { BottomBarIcon, CircleHollowIcon, CircleIcon, CrossIcon, MirrorIcon, SidebarIcon } from '@storybook/icons';
|
|
4
|
-
import { useGlobals } from '@storybook/manager-api';
|
|
4
|
+
import { useGlobals, useParameter } from '@storybook/manager-api';
|
|
5
5
|
import { TOOL_ID } from './constants';
|
|
6
6
|
const themeOptions = [{
|
|
7
7
|
id: 'auto',
|
|
@@ -38,8 +38,14 @@ const Tool = () => {
|
|
|
38
38
|
var _themeOptions$find;
|
|
39
39
|
const [isVisible, setIsVisible] = useState(false);
|
|
40
40
|
const [{
|
|
41
|
-
adsTheme
|
|
41
|
+
adsTheme: originalAdsTheme
|
|
42
42
|
}, updateGlobals] = useGlobals();
|
|
43
|
+
const adsTheme = useParameter('adsTheme', originalAdsTheme || 'auto');
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
updateGlobals({
|
|
46
|
+
adsTheme
|
|
47
|
+
});
|
|
48
|
+
}, [adsTheme, updateGlobals]);
|
|
43
49
|
const setTheme = useCallback(theme => updateGlobals({
|
|
44
50
|
adsTheme: theme
|
|
45
51
|
}), [updateGlobals]);
|
package/dist/esm/tool.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
|
|
4
4
|
import { BottomBarIcon, CircleHollowIcon, CircleIcon, CrossIcon, MirrorIcon, SidebarIcon } from '@storybook/icons';
|
|
5
|
-
import { useGlobals } from '@storybook/manager-api';
|
|
5
|
+
import { useGlobals, useParameter } from '@storybook/manager-api';
|
|
6
6
|
import { TOOL_ID } from './constants';
|
|
7
7
|
var themeOptions = [{
|
|
8
8
|
id: 'auto',
|
|
@@ -43,8 +43,14 @@ var Tool = function Tool() {
|
|
|
43
43
|
setIsVisible = _useState2[1];
|
|
44
44
|
var _useGlobals = useGlobals(),
|
|
45
45
|
_useGlobals2 = _slicedToArray(_useGlobals, 2),
|
|
46
|
-
|
|
46
|
+
originalAdsTheme = _useGlobals2[0].adsTheme,
|
|
47
47
|
updateGlobals = _useGlobals2[1];
|
|
48
|
+
var adsTheme = useParameter('adsTheme', originalAdsTheme || 'auto');
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
updateGlobals({
|
|
51
|
+
adsTheme: adsTheme
|
|
52
|
+
});
|
|
53
|
+
}, [adsTheme, updateGlobals]);
|
|
48
54
|
var setTheme = useCallback(function (theme) {
|
|
49
55
|
return updateGlobals({
|
|
50
56
|
adsTheme: theme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/storybook-addon-design-system",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Design token storybook addon",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.tsx"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/tokens": "^
|
|
36
|
+
"@atlaskit/tokens": "^5.0.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"@storybook/components": "^8.4.7",
|
|
39
39
|
"@storybook/icons": "^1.2.9",
|
package/src/tool.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { type ReactElement, useCallback, useState } from 'react';
|
|
1
|
+
import React, { type ReactElement, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
|
|
4
4
|
import {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
MirrorIcon,
|
|
10
10
|
SidebarIcon,
|
|
11
11
|
} from '@storybook/icons';
|
|
12
|
-
import { useGlobals } from '@storybook/manager-api';
|
|
12
|
+
import { useGlobals, useParameter } from '@storybook/manager-api';
|
|
13
13
|
|
|
14
14
|
import { TOOL_ID } from './constants';
|
|
15
15
|
import { type Themes } from './types';
|
|
@@ -36,7 +36,12 @@ const themeOptions: ThemeOption[] = [
|
|
|
36
36
|
*/
|
|
37
37
|
const Tool = () => {
|
|
38
38
|
const [isVisible, setIsVisible] = useState(false);
|
|
39
|
-
const [{ adsTheme }, updateGlobals] = useGlobals();
|
|
39
|
+
const [{ adsTheme: originalAdsTheme }, updateGlobals] = useGlobals();
|
|
40
|
+
const adsTheme = useParameter('adsTheme', originalAdsTheme || 'auto');
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
updateGlobals({ adsTheme });
|
|
44
|
+
}, [adsTheme, updateGlobals]);
|
|
40
45
|
|
|
41
46
|
const setTheme = useCallback(
|
|
42
47
|
(theme: Themes) => updateGlobals({ adsTheme: theme }),
|