@atlaskit/storybook-addon-design-system 3.0.0 → 3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/storybook-addon-design-system
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#154276](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154276)
8
+ [`917104b6edd11`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/917104b6edd11) -
9
+ Introduced `adsTheme` parameter for customizing the theme in preview.js that allows overriding the
10
+ theme with custom values 'light' or 'dark'.
11
+
3
12
  ## 3.0.0
4
13
 
5
14
  ### 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/tool.js CHANGED
@@ -53,8 +53,14 @@ var Tool = function Tool() {
53
53
  setIsVisible = _useState2[1];
54
54
  var _useGlobals = (0, _managerApi.useGlobals)(),
55
55
  _useGlobals2 = (0, _slicedToArray2.default)(_useGlobals, 2),
56
- adsTheme = _useGlobals2[0].adsTheme,
56
+ originalAdsTheme = _useGlobals2[0].adsTheme,
57
57
  updateGlobals = _useGlobals2[1];
58
+ var adsTheme = (0, _managerApi.useParameter)('adsTheme', originalAdsTheme || 'auto');
59
+ (0, _react.useEffect)(function () {
60
+ updateGlobals({
61
+ adsTheme: adsTheme
62
+ });
63
+ }, [adsTheme, updateGlobals]);
58
64
  var setTheme = (0, _react.useCallback)(function (theme) {
59
65
  return updateGlobals({
60
66
  adsTheme: theme
@@ -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
- adsTheme = _useGlobals2[0].adsTheme,
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.0.0",
3
+ "version": "3.1.0",
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": "^4.5.0",
36
+ "@atlaskit/tokens": "^4.8.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 }),