@carbon/storybook-addon-theme 0.22.41 → 2.0.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -8,10 +8,13 @@ Components!
8
8
  - React
9
9
  - Vue
10
10
 
11
+ No reason to suspect others are not supported, but have not been tested. If you use with another framework then please post an update to the README.md.
12
+
11
13
  ## Install
12
14
 
13
15
  ```sh
14
- npm install @carbon/storybook-addon-theme
16
+ npm install --save-dev @carbon/storybook-addon-theme
17
+ yarn instsall --dev @carbon/storybook-addon-theme
15
18
  ```
16
19
 
17
20
  ## Requirements
@@ -35,114 +38,106 @@ and
35
38
 
36
39
  ```js
37
40
  module.exports = {
38
- addons: ['@carbon/storybook-addon-theme/register'],
41
+ // other addons...
42
+ addons: ['@carbon/storybook-addon-theme/preset.js'],
39
43
  };
40
44
  ```
41
45
 
42
- Use with a feature flag switch is possible if you construct the addons array.
46
+ ### Global Decorator
47
+
48
+ `.storybook/preview.js`:
43
49
 
44
50
  ```js
45
- const addons = [
46
- /* other addons */
47
- ];
51
+ import { withCarbonTheme } from '@carbon/storybook-addon-theme/withCarbonTheme';
52
+ import { PARAM_KEY as CARBON_THEME_PARAM_KEY, CARBON_THEMES } from '@carbon/storybook-addon-theme/constants';
48
53
 
49
- if (process.env.CARBON_REACT_STORYBOOK_USE_CUSTOM_PROPERTIES === 'true') {
50
- addons.push('@carbon/storybook-addon-theme/register');
51
- }
54
+ const decorators = [
55
+ /// other decorators...
56
+ withCarbonTheme
57
+ ];
52
58
 
53
- module.exports = {
54
- addons,
55
- stories: ['../src/**/*-story.js', '../src/**/*.stories.mdx'],
59
+ const globals = {
60
+ // other globals...
61
+ // default value of the theme selector
62
+ [CARBON_THEME_PARAM_KEY]: CARBON_THEMES.g10,
56
63
  };
64
+
65
+ export { decorators, globals }
57
66
  ```
58
67
 
59
- ### Global Decorator
68
+ ## SCSS
60
69
 
61
- `.storybook/preview.js`:
70
+ `.storybook/index.scss`
62
71
 
63
- ```js
64
- import { withCarbonTheme } from '@carbon/storybook-addon-theme'; // for React
65
- // import { withCarbonTheme } from '@carbon/storybook-addon-theme/vue'; // for Vue
66
- // for Angular (not yet supported)
67
- // .
68
- // for all (including story decorators)
69
- import index from './index.scss';
70
- // .
71
- addDecorator(withCarbonTheme);
72
- // .
73
- ```
72
+ ### Carbon 11
74
73
 
75
- ```js
76
- // Adding the decorator
77
- const decorators = [withCarbonTheme];
78
- const parameters = {
79
- carbonTheme: {
80
- theme: 'g10',
81
- },
82
- };
83
- export { decorators, parameters };
84
- ```
74
+ ```scss
75
+ @use '@carbon/styles' as styles;
76
+ @use '@carbon/styles/scss/theme' as *;
85
77
 
86
- ```js
87
- // Older storybook versions
88
- addParameters({
89
- // optional
90
- carbonTheme: {
91
- theme: 'g10', // optional default carbon theme
92
- themes: ['g10', 'g90'], // optional carbonTheme filter
93
- },
94
- });
95
- ```
78
+ [storybook-carbon-theme] {
79
+ @include styles.theme(styles.$white);
96
80
 
97
- ### Story decorator
81
+ /* make sure background and color are set if theme in use */
82
+ background-color: $background;
83
+ color: $text-primary;
84
+ }
98
85
 
99
- ```js
100
- import { withCarbonTheme } from '@carbon/storybook-addon-theme'; // for React
101
- // import { withCarbonTheme } from '@carbon/storybook-addon-theme/vue'; // for Vue
102
- // for Angular
103
- // .
104
- // .
105
- // .
106
- storiesOf('Component', module)
107
- .addDecorator(withCarbonTheme)
108
- .add(() => story, {
109
- carbonTheme: {
110
- // optional
111
- theme: 'g10', // optional default carbon theme
112
- themes: ['g10', 'g90'], // optional carbonTheme filter (additive to global)
113
- },
114
- });
86
+ [storybook-carbon-theme='g10'],
87
+ .sb--use-carbon-theme-g10 {
88
+ @include styles.theme(styles.$g10);
89
+ }
90
+
91
+ [storybook-carbon-theme='g90'],
92
+ .sb--use-carbon-theme-g90 {
93
+ @include styles.theme(styles.$g90);
94
+ }
95
+
96
+ [storybook-carbon-theme='g100'],
97
+ .sb--use-carbon-theme-g100 {
98
+ @include styles.theme(styles.$g100);
99
+ }
115
100
  ```
116
101
 
117
- ## SCSS
102
+ ### Carbon 10
118
103
 
119
- `.storybook/index.scss`
104
+ ```SCSS
105
+ // Must happen before styles are loaded
106
+ $feature-flags: (
107
+ ui-shell: true,
108
+ grid-columns-16: true,
109
+ enable-css-custom-properties: true
110
+ );
120
111
 
121
- ```scss
122
- @import '@carbon/themes/scss/themes';
112
+ @import "carbon-components/scss/globals/scss/styles";
113
+ @import "@carbon/themes/scss/themes";
114
+
115
+ [storybook-carbon-theme] {
116
+ background: $ui-background;
117
+ color: $ui-01;
123
118
 
124
- :root {
125
119
  @include carbon--theme(
126
120
  $theme: $carbon--theme--white,
127
121
  $emit-custom-properties: true
128
122
  );
129
123
  }
130
124
 
131
- :root[storybook-carbon-theme='g10'] {
125
+ [storybook-carbon-theme="g10"] {
132
126
  @include carbon--theme(
133
127
  $theme: $carbon--theme--g10,
134
128
  $emit-custom-properties: true
135
129
  );
136
130
  }
137
131
 
138
- :root[storybook-carbon-theme='g90'] {
132
+ [storybook-carbon-theme="g90"] {
133
+ z-index: 90;
139
134
  @include carbon--theme(
140
135
  $theme: $carbon--theme--g90,
141
136
  $emit-custom-properties: true
142
137
  );
143
138
  }
144
139
 
145
- :root[storybook-carbon-theme='g100'] {
140
+ [storybook-carbon-theme="g100"] {
146
141
  @include carbon--theme(
147
142
  $theme: $carbon--theme--g100,
148
143
  $emit-custom-properties: true
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2018
2
+ * Copyright IBM Corp. 2023, 2023
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export { withCarbonTheme } from './dist/react';
7
+ module.exports = require('./dist/constants.js');
package/dist/Panel.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { useGlobals } from '@storybook/manager-api';
9
+ import { AddonPanel } from '@storybook/components';
10
+ import { PARAM_KEY } from './constants';
11
+ import { PanelContent } from './components/PanelContent';
12
+ export const Panel = props => {
13
+ const [globals, updateGlobals] = useGlobals();
14
+ const globalCarbonTheme = globals[PARAM_KEY];
15
+ return /*#__PURE__*/React.createElement(AddonPanel, props, /*#__PURE__*/React.createElement(PanelContent, {
16
+ theme: globalCarbonTheme,
17
+ onChange: value => {
18
+ updateGlobals({
19
+ [PARAM_KEY]: value
20
+ });
21
+ }
22
+ }));
23
+ };
24
+ //# sourceMappingURL=Panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Panel.js","names":["React","useGlobals","AddonPanel","PARAM_KEY","PanelContent","Panel","props","globals","updateGlobals","globalCarbonTheme","createElement","theme","onChange","value"],"sources":["../src/Panel.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { useGlobals } from '@storybook/manager-api';\n\nimport { AddonPanel } from '@storybook/components';\nimport { PARAM_KEY } from './constants';\nimport { PanelContent } from './components/PanelContent';\n\nexport const Panel = (props) => {\n const [globals, updateGlobals] = useGlobals();\n const globalCarbonTheme = globals[PARAM_KEY];\n\n return (\n <AddonPanel {...props}>\n <PanelContent\n theme={globalCarbonTheme}\n onChange={(value) => {\n updateGlobals({ [PARAM_KEY]: value });\n }}\n />\n </AddonPanel>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,YAAY,QAAQ,2BAA2B;AAExD,OAAO,MAAMC,KAAK,GAAIC,KAAK,IAAK;EAC9B,MAAM,CAACC,OAAO,EAAEC,aAAa,CAAC,GAAGP,UAAU,CAAC,CAAC;EAC7C,MAAMQ,iBAAiB,GAAGF,OAAO,CAACJ,SAAS,CAAC;EAE5C,oBACEH,KAAA,CAAAU,aAAA,CAACR,UAAU,EAAKI,KAAK,eACnBN,KAAA,CAAAU,aAAA,CAACN,YAAY;IACXO,KAAK,EAAEF,iBAAkB;IACzBG,QAAQ,EAAGC,KAAK,IAAK;MACnBL,aAAa,CAAC;QAAE,CAACL,SAAS,GAAGU;MAAM,CAAC,CAAC;IACvC;EAAE,CACH,CACS,CAAC;AAEjB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { Form } from '@storybook/components';
9
+ import PropTypes from 'prop-types';
10
+ import { CARBON_THEMES } from '../constants';
11
+ export const PanelContent = ({
12
+ theme,
13
+ onChange
14
+ }) => {
15
+ const themes = Object.values(CARBON_THEMES);
16
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Form.Field, {
17
+ label: "Select Carbon theme:"
18
+ }, /*#__PURE__*/React.createElement(Form.Select, {
19
+ name: "carbon-theme",
20
+ value: theme,
21
+ onChange: ev => {
22
+ onChange && onChange(ev.target.value);
23
+ },
24
+ size: "flex"
25
+ }, themes.map(option => /*#__PURE__*/React.createElement("option", {
26
+ key: option,
27
+ value: option
28
+ }, option))))));
29
+ };
30
+ PanelContent.propTypes = {
31
+ onChange: PropTypes.func,
32
+ theme: PropTypes.string
33
+ };
34
+ //# sourceMappingURL=PanelContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelContent.js","names":["React","Form","PropTypes","CARBON_THEMES","PanelContent","theme","onChange","themes","Object","values","createElement","Field","label","Select","name","value","ev","target","size","map","option","key","propTypes","func","string"],"sources":["../../src/components/PanelContent.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { Form } from '@storybook/components';\nimport PropTypes from 'prop-types';\nimport { CARBON_THEMES } from '../constants';\n\nexport const PanelContent = ({ theme, onChange }) => {\n const themes = Object.values(CARBON_THEMES);\n\n return (\n <div>\n <Form>\n <Form.Field label=\"Select Carbon theme:\">\n <Form.Select\n name=\"carbon-theme\"\n value={theme}\n onChange={(ev) => {\n onChange && onChange(ev.target.value);\n }}\n size=\"flex\"\n >\n {themes.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </Form.Select>\n </Form.Field>\n </Form>\n </div>\n );\n};\n\nPanelContent.propTypes = {\n onChange: PropTypes.func,\n theme: PropTypes.string,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,aAAa,QAAQ,cAAc;AAE5C,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAK;EACnD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACN,aAAa,CAAC;EAE3C,oBACEH,KAAA,CAAAU,aAAA,2BACEV,KAAA,CAAAU,aAAA,CAACT,IAAI,qBACHD,KAAA,CAAAU,aAAA,CAACT,IAAI,CAACU,KAAK;IAACC,KAAK,EAAC;EAAsB,gBACtCZ,KAAA,CAAAU,aAAA,CAACT,IAAI,CAACY,MAAM;IACVC,IAAI,EAAC,cAAc;IACnBC,KAAK,EAAEV,KAAM;IACbC,QAAQ,EAAGU,EAAE,IAAK;MAChBV,QAAQ,IAAIA,QAAQ,CAACU,EAAE,CAACC,MAAM,CAACF,KAAK,CAAC;IACvC,CAAE;IACFG,IAAI,EAAC;EAAM,GAEVX,MAAM,CAACY,GAAG,CAAEC,MAAM,iBACjBpB,KAAA,CAAAU,aAAA;IAAQW,GAAG,EAAED,MAAO;IAACL,KAAK,EAAEK;EAAO,GAChCA,MACK,CACT,CACU,CACH,CACR,CACH,CAAC;AAEV,CAAC;AAEDhB,YAAY,CAACkB,SAAS,GAAG;EACvBhB,QAAQ,EAAEJ,SAAS,CAACqB,IAAI;EACxBlB,KAAK,EAAEH,SAAS,CAACsB;AACnB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export const ADDON_ID = '@carbon/theme';
8
+ export const PANEL_ID = `${ADDON_ID}/panel`;
9
+ export const TOOL_ID = `${ADDON_ID}/tool`;
10
+ export const PARAM_KEY = 'carbonTheme';
11
+ export const CARBON_THEMES = {
12
+ white: 'white',
13
+ g10: 'g10',
14
+ g90: 'g90',
15
+ g100: 'g100'
16
+ };
17
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["ADDON_ID","PANEL_ID","TOOL_ID","PARAM_KEY","CARBON_THEMES","white","g10","g90","g100"],"sources":["../src/constants.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nexport const ADDON_ID = '@carbon/theme';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = 'carbonTheme';\nexport const CARBON_THEMES = {\n white: 'white',\n g10: 'g10',\n g90: 'g90',\n g100: 'g100',\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAG,eAAe;AACvC,OAAO,MAAMC,QAAQ,GAAI,GAAED,QAAS,QAAO;AAC3C,OAAO,MAAME,OAAO,GAAI,GAAEF,QAAS,OAAM;AACzC,OAAO,MAAMG,SAAS,GAAG,aAAa;AACtC,OAAO,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAE,OAAO;EACdC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;AACR,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useEffect } from '@storybook/preview-api';
8
+ import { PARAM_KEY } from '../constants';
9
+ export const withCarbonTheme = (StoryFn, context) => {
10
+ const {
11
+ globals,
12
+ parameters
13
+ } = context;
14
+ const globalCarbonTheme = globals[PARAM_KEY];
15
+ const storyCarbonTheme = parameters[PARAM_KEY];
16
+
17
+ // eslint-disable-next-line react-hooks/rules-of-hooks
18
+ useEffect(() => {
19
+ const selector = context.viewMode === 'docs' ? `.sbdocs-preview .docs-story` : '.sb-show-main';
20
+ const rootElements = document.querySelectorAll(selector);
21
+ rootElements.forEach(rootElement => {
22
+ rootElement.setAttribute('storybook-carbon-theme', globalCarbonTheme ?? storyCarbonTheme);
23
+ });
24
+ }, [context.id, context.viewMode, globalCarbonTheme, storyCarbonTheme]);
25
+ return StoryFn();
26
+ };
27
+ //# sourceMappingURL=withCarbonTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCarbonTheme.js","names":["useEffect","PARAM_KEY","withCarbonTheme","StoryFn","context","globals","parameters","globalCarbonTheme","storyCarbonTheme","selector","viewMode","rootElements","document","querySelectorAll","forEach","rootElement","setAttribute","id"],"sources":["../../src/decorators/withCarbonTheme.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { useEffect } from '@storybook/preview-api';\nimport { PARAM_KEY } from '../constants';\n\nexport const withCarbonTheme = (StoryFn, context) => {\n const { globals, parameters } = context;\n\n const globalCarbonTheme = globals[PARAM_KEY];\n const storyCarbonTheme = parameters[PARAM_KEY];\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n const selector =\n context.viewMode === 'docs'\n ? `.sbdocs-preview .docs-story`\n : '.sb-show-main';\n\n const rootElements = document.querySelectorAll(selector);\n rootElements.forEach((rootElement) => {\n rootElement.setAttribute(\n 'storybook-carbon-theme',\n globalCarbonTheme ?? storyCarbonTheme\n );\n });\n }, [context.id, context.viewMode, globalCarbonTheme, storyCarbonTheme]);\n\n return StoryFn();\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,wBAAwB;AAClD,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,MAAMC,eAAe,GAAGA,CAACC,OAAO,EAAEC,OAAO,KAAK;EACnD,MAAM;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGF,OAAO;EAEvC,MAAMG,iBAAiB,GAAGF,OAAO,CAACJ,SAAS,CAAC;EAC5C,MAAMO,gBAAgB,GAAGF,UAAU,CAACL,SAAS,CAAC;;EAE9C;EACAD,SAAS,CAAC,MAAM;IACd,MAAMS,QAAQ,GACZL,OAAO,CAACM,QAAQ,KAAK,MAAM,GACtB,6BAA4B,GAC7B,eAAe;IAErB,MAAMC,YAAY,GAAGC,QAAQ,CAACC,gBAAgB,CAACJ,QAAQ,CAAC;IACxDE,YAAY,CAACG,OAAO,CAAEC,WAAW,IAAK;MACpCA,WAAW,CAACC,YAAY,CACtB,wBAAwB,EACxBT,iBAAiB,IAAIC,gBACvB,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,EAAE,CAACJ,OAAO,CAACa,EAAE,EAAEb,OAAO,CAACM,QAAQ,EAAEH,iBAAiB,EAAEC,gBAAgB,CAAC,CAAC;EAEvE,OAAOL,OAAO,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { addons, types } from '@storybook/manager-api';
8
+ import { Panel } from './Panel';
9
+ const ADDON_ID = 'carbonTheme';
10
+ const PANEL_ID = `${ADDON_ID}/panel`;
11
+ addons.register(ADDON_ID, () => {
12
+ addons.add(PANEL_ID, {
13
+ type: types.PANEL,
14
+ title: 'Carbon Theme',
15
+ render: Panel
16
+ });
17
+ });
18
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","names":["addons","types","Panel","ADDON_ID","PANEL_ID","register","add","type","PANEL","title","render"],"sources":["../src/manager.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { addons, types } from '@storybook/manager-api';\n\nimport { Panel } from './Panel';\n\nconst ADDON_ID = 'carbonTheme';\nconst PANEL_ID = `${ADDON_ID}/panel`;\n\naddons.register(ADDON_ID, () => {\n addons.add(PANEL_ID, {\n type: types.PANEL,\n title: 'Carbon Theme',\n render: Panel,\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,KAAK,QAAQ,wBAAwB;AAEtD,SAASC,KAAK,QAAQ,SAAS;AAE/B,MAAMC,QAAQ,GAAG,aAAa;AAC9B,MAAMC,QAAQ,GAAI,GAAED,QAAS,QAAO;AAEpCH,MAAM,CAACK,QAAQ,CAACF,QAAQ,EAAE,MAAM;EAC9BH,MAAM,CAACM,GAAG,CAACF,QAAQ,EAAE;IACnBG,IAAI,EAAEN,KAAK,CAACO,KAAK;IACjBC,KAAK,EAAE,cAAc;IACrBC,MAAM,EAAER;EACV,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/dist/preset.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ function managerEntries(entry = []) {
8
+ return [...entry, require.resolve('./manager')]; //👈 Addon implementation
9
+ }
10
+
11
+ export default {
12
+ managerEntries
13
+ };
14
+ //# sourceMappingURL=preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","names":["managerEntries","entry","require","resolve"],"sources":["../src/preset.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nfunction managerEntries(entry = []) {\n return [...entry, require.resolve('./manager')]; //👈 Addon implementation\n}\n\nexport default { managerEntries };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAcA,CAACC,KAAK,GAAG,EAAE,EAAE;EAClC,OAAO,CAAC,GAAGA,KAAK,EAAEC,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACnD;;AAEA,eAAe;EAAEH;AAAe,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@carbon/storybook-addon-theme",
3
3
  "description": "Carbon theme switcher for Storybook",
4
- "version": "0.22.41",
4
+ "version": "2.0.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/react.js",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/carbon-design-system/ibm-products.git",
10
- "directory": "packages/storybook-addon-carbon-theme"
10
+ "directory": "config/storybook-addon-carbon-theme"
11
11
  },
12
12
  "bugs": "https://github.com/carbon-design-system/ibm-products/issues",
13
13
  "homepage": "https://github.com/storybookjs/storybook#readme",
@@ -42,14 +42,14 @@
42
42
  "vue": "*"
43
43
  },
44
44
  "dependencies": {
45
- "@storybook/addons": "6.5.16",
46
- "@storybook/api": "6.5.16",
47
- "@storybook/client-api": "6.5.16",
48
- "@storybook/client-logger": "6.5.16",
49
- "@storybook/components": "6.5.16",
50
- "@storybook/core-events": "6.5.16",
51
- "@storybook/theming": "6.5.16",
52
- "core-js": "^3.30.2",
45
+ "@storybook/addons": "^7.0.18",
46
+ "@storybook/api": "^7.0.18",
47
+ "@storybook/client-api": "^7.0.18",
48
+ "@storybook/client-logger": "^7.0.18",
49
+ "@storybook/components": "^7.0.18",
50
+ "@storybook/core-events": "^7.0.18",
51
+ "@storybook/theming": "^7.0.18",
52
+ "core-js": "^3.28.0",
53
53
  "global": "^4.4.0"
54
54
  },
55
55
  "devDependencies": {
@@ -59,6 +59,5 @@
59
59
  "npm-check-updates": "^16.10.12",
60
60
  "npm-run-all": "^4.1.5",
61
61
  "rimraf": "^5.0.1"
62
- },
63
- "gitHead": "30b5fa97e450c8587e04b5e2e1be98c9a7379d45"
62
+ }
64
63
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2018
2
+ * Copyright IBM Corp. 2023, 2023
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import './dist/register';
7
+ module.exports = require('./dist/preset.js');
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2018
2
+ * Copyright IBM Corp. 2023, 2023
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export { withCarbonTheme } from './dist/vue';
7
+ module.exports = require('./dist/decorators/withCarbonTheme');
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2020 IBM Corp.
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -1,73 +0,0 @@
1
- /* eslint-disable react/prop-types */
2
- /**
3
- * Copyright IBM Corp. 2016, 2018
4
- *
5
- * This source code is licensed under the Apache-2.0 license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import React, { useEffect, useState } from 'react';
10
- import PropTypes from 'prop-types';
11
- import { Form } from '@storybook/components';
12
- import { SET_STORIES, STORY_CHANGED } from '@storybook/core-events';
13
- import { CARBON_CURRENT_THEME, CARBON_THEMES, CARBON_THEME_DEFAULT, CARBON_THEME_PARAM, mergeParams } from '../shared';
14
-
15
- /**
16
- * Storybook add-on panel for Carbon theme switcher.
17
- */
18
- export const CarbonThemesPanel = ({
19
- api,
20
- active,
21
- channel
22
- }) => {
23
- const [theme, setTheme] = useState(CARBON_THEME_DEFAULT);
24
- const [themes, setThemes] = useState(CARBON_THEMES);
25
- useEffect(() => {
26
- // on mount sort out initial state
27
- const handleStoryChange = () => {
28
- const storyData = api.getCurrentStoryData();
29
- let params = storyData ? storyData.parameters ? storyData.parameters[CARBON_THEME_PARAM] : {} : {};
30
- params = mergeParams(params);
31
- setTheme(params.theme);
32
- setThemes(params.themes);
33
- };
34
- api.on(SET_STORIES, handleStoryChange);
35
- api.on(STORY_CHANGED, handleStoryChange);
36
- return () => {
37
- api.off(SET_STORIES, handleStoryChange);
38
- api.off(STORY_CHANGED, handleStoryChange);
39
- };
40
- }, [api]);
41
- useEffect(() => {
42
- channel.emit(CARBON_CURRENT_THEME, theme);
43
- }, [theme, channel]);
44
- if (!active) {
45
- return null;
46
- }
47
- return /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Form.Field, {
48
- label: "Select Carbon theme:"
49
- }, /*#__PURE__*/React.createElement(Form.Select, {
50
- name: "carbon-theme",
51
- value: theme,
52
- onChange: ev => setTheme(ev.target.value),
53
- size: "flex"
54
- }, themes.map(option => /*#__PURE__*/React.createElement("option", {
55
- key: option,
56
- value: option
57
- }, option)))));
58
- };
59
- CarbonThemesPanel.propTypes = {
60
- /**
61
- * `true` if this Storybook add-on panel is active.
62
- */
63
- active: PropTypes.bool.isRequired,
64
- /**
65
- * The Storybook API object.
66
- */
67
- api: PropTypes.any,
68
- /**
69
- * channel
70
- */
71
- channel: PropTypes.object
72
- };
73
- //# sourceMappingURL=Panel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Panel.js","names":["React","useEffect","useState","PropTypes","Form","SET_STORIES","STORY_CHANGED","CARBON_CURRENT_THEME","CARBON_THEMES","CARBON_THEME_DEFAULT","CARBON_THEME_PARAM","mergeParams","CarbonThemesPanel","api","active","channel","theme","setTheme","themes","setThemes","handleStoryChange","storyData","getCurrentStoryData","params","parameters","on","off","emit","createElement","Field","label","Select","name","value","onChange","ev","target","size","map","option","key","propTypes","bool","isRequired","any","object"],"sources":["../../src/components/Panel.js"],"sourcesContent":["/* eslint-disable react/prop-types */\n/**\n * Copyright IBM Corp. 2016, 2018\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { Form } from '@storybook/components';\nimport { SET_STORIES, STORY_CHANGED } from '@storybook/core-events';\n\nimport {\n CARBON_CURRENT_THEME,\n CARBON_THEMES,\n CARBON_THEME_DEFAULT,\n CARBON_THEME_PARAM,\n mergeParams,\n} from '../shared';\n\n/**\n * Storybook add-on panel for Carbon theme switcher.\n */\nexport const CarbonThemesPanel = ({ api, active, channel }) => {\n const [theme, setTheme] = useState(CARBON_THEME_DEFAULT);\n const [themes, setThemes] = useState(CARBON_THEMES);\n\n useEffect(() => {\n // on mount sort out initial state\n const handleStoryChange = () => {\n const storyData = api.getCurrentStoryData();\n\n let params = storyData\n ? storyData.parameters\n ? storyData.parameters[CARBON_THEME_PARAM]\n : {}\n : {};\n\n params = mergeParams(params);\n\n setTheme(params.theme);\n setThemes(params.themes);\n };\n\n api.on(SET_STORIES, handleStoryChange);\n api.on(STORY_CHANGED, handleStoryChange);\n\n return () => {\n api.off(SET_STORIES, handleStoryChange);\n api.off(STORY_CHANGED, handleStoryChange);\n };\n }, [api]);\n\n useEffect(() => {\n channel.emit(CARBON_CURRENT_THEME, theme);\n }, [theme, channel]);\n\n if (!active) {\n return null;\n }\n\n return (\n <Form>\n <Form.Field label=\"Select Carbon theme:\">\n <Form.Select\n name=\"carbon-theme\"\n value={theme}\n onChange={(ev) => setTheme(ev.target.value)}\n size=\"flex\"\n >\n {themes.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </Form.Select>\n </Form.Field>\n </Form>\n );\n};\n\nCarbonThemesPanel.propTypes = {\n /**\n * `true` if this Storybook add-on panel is active.\n */\n active: PropTypes.bool.isRequired,\n /**\n * The Storybook API object.\n */\n api: PropTypes.any,\n /**\n * channel\n */\n channel: PropTypes.object,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,WAAW,EAAEC,aAAa,QAAQ,wBAAwB;AAEnE,SACEC,oBAAoB,EACpBC,aAAa,EACbC,oBAAoB,EACpBC,kBAAkB,EAClBC,WAAW,QACN,WAAW;;AAElB;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,GAAG;EAAEC,MAAM;EAAEC;AAAQ,CAAC,KAAK;EAC7D,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGf,QAAQ,CAACO,oBAAoB,CAAC;EACxD,MAAM,CAACS,MAAM,EAAEC,SAAS,CAAC,GAAGjB,QAAQ,CAACM,aAAa,CAAC;EAEnDP,SAAS,CAAC,MAAM;IACd;IACA,MAAMmB,iBAAiB,GAAGA,CAAA,KAAM;MAC9B,MAAMC,SAAS,GAAGR,GAAG,CAACS,mBAAmB,CAAC,CAAC;MAE3C,IAAIC,MAAM,GAAGF,SAAS,GAClBA,SAAS,CAACG,UAAU,GAClBH,SAAS,CAACG,UAAU,CAACd,kBAAkB,CAAC,GACxC,CAAC,CAAC,GACJ,CAAC,CAAC;MAENa,MAAM,GAAGZ,WAAW,CAACY,MAAM,CAAC;MAE5BN,QAAQ,CAACM,MAAM,CAACP,KAAK,CAAC;MACtBG,SAAS,CAACI,MAAM,CAACL,MAAM,CAAC;IAC1B,CAAC;IAEDL,GAAG,CAACY,EAAE,CAACpB,WAAW,EAAEe,iBAAiB,CAAC;IACtCP,GAAG,CAACY,EAAE,CAACnB,aAAa,EAAEc,iBAAiB,CAAC;IAExC,OAAO,MAAM;MACXP,GAAG,CAACa,GAAG,CAACrB,WAAW,EAAEe,iBAAiB,CAAC;MACvCP,GAAG,CAACa,GAAG,CAACpB,aAAa,EAAEc,iBAAiB,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAACP,GAAG,CAAC,CAAC;EAETZ,SAAS,CAAC,MAAM;IACdc,OAAO,CAACY,IAAI,CAACpB,oBAAoB,EAAES,KAAK,CAAC;EAC3C,CAAC,EAAE,CAACA,KAAK,EAAED,OAAO,CAAC,CAAC;EAEpB,IAAI,CAACD,MAAM,EAAE;IACX,OAAO,IAAI;EACb;EAEA,oBACEd,KAAA,CAAA4B,aAAA,CAACxB,IAAI,qBACHJ,KAAA,CAAA4B,aAAA,CAACxB,IAAI,CAACyB,KAAK;IAACC,KAAK,EAAC;EAAsB,gBACtC9B,KAAA,CAAA4B,aAAA,CAACxB,IAAI,CAAC2B,MAAM;IACVC,IAAI,EAAC,cAAc;IACnBC,KAAK,EAAEjB,KAAM;IACbkB,QAAQ,EAAGC,EAAE,IAAKlB,QAAQ,CAACkB,EAAE,CAACC,MAAM,CAACH,KAAK,CAAE;IAC5CI,IAAI,EAAC;EAAM,GAEVnB,MAAM,CAACoB,GAAG,CAAEC,MAAM,iBACjBvC,KAAA,CAAA4B,aAAA;IAAQY,GAAG,EAAED,MAAO;IAACN,KAAK,EAAEM;EAAO,GAChCA,MACK,CACT,CACU,CACH,CACR,CAAC;AAEX,CAAC;AAED3B,iBAAiB,CAAC6B,SAAS,GAAG;EAC5B;AACF;AACA;EACE3B,MAAM,EAAEX,SAAS,CAACuC,IAAI,CAACC,UAAU;EACjC;AACF;AACA;EACE9B,GAAG,EAAEV,SAAS,CAACyC,GAAG;EAClB;AACF;AACA;EACE7B,OAAO,EAAEZ,SAAS,CAAC0C;AACrB,CAAC"}
package/dist/react.js DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 2018
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import { useEffect, useState } from 'react';
8
- import addons, { makeDecorator } from '@storybook/addons';
9
- import { CARBON_CURRENT_THEME, CARBON_THEME_PARAM, WITH_CARBON_THEME } from './shared';
10
- const Wrapper = (getStory, context, parameters) => {
11
- const channel = addons.getChannel();
12
- const [carbonTheme, setCarbonTheme] = useState(undefined);
13
- const handleCarbonCurrentTheme = theme => {
14
- document.documentElement.setAttribute('storybook-carbon-theme', theme);
15
- setCarbonTheme(theme);
16
- };
17
- useEffect(() => {
18
- channel.on(CARBON_CURRENT_THEME, handleCarbonCurrentTheme);
19
- setCarbonTheme(carbonTheme || parameters.value);
20
- return () => {
21
- channel.removeListener(CARBON_CURRENT_THEME, handleCarbonCurrentTheme);
22
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
23
- }, []);
24
- return getStory(context);
25
- };
26
- export const withCarbonTheme = makeDecorator({
27
- name: WITH_CARBON_THEME,
28
- parameterName: CARBON_THEME_PARAM,
29
- wrapper: Wrapper
30
- });
31
- //# sourceMappingURL=react.js.map
package/dist/react.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","names":["useEffect","useState","addons","makeDecorator","CARBON_CURRENT_THEME","CARBON_THEME_PARAM","WITH_CARBON_THEME","Wrapper","getStory","context","parameters","channel","getChannel","carbonTheme","setCarbonTheme","undefined","handleCarbonCurrentTheme","theme","document","documentElement","setAttribute","on","value","removeListener","withCarbonTheme","name","parameterName","wrapper"],"sources":["../src/react.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2016, 2018\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { useEffect, useState } from 'react';\nimport addons, { makeDecorator } from '@storybook/addons';\nimport {\n CARBON_CURRENT_THEME,\n CARBON_THEME_PARAM,\n WITH_CARBON_THEME,\n} from './shared';\n\nconst Wrapper = (getStory, context, parameters) => {\n const channel = addons.getChannel();\n const [carbonTheme, setCarbonTheme] = useState(undefined);\n\n const handleCarbonCurrentTheme = (theme) => {\n document.documentElement.setAttribute('storybook-carbon-theme', theme);\n setCarbonTheme(theme);\n };\n\n useEffect(() => {\n channel.on(CARBON_CURRENT_THEME, handleCarbonCurrentTheme);\n setCarbonTheme(carbonTheme || parameters.value);\n\n return () => {\n channel.removeListener(CARBON_CURRENT_THEME, handleCarbonCurrentTheme);\n }; // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return getStory(context);\n};\n\nexport const withCarbonTheme = makeDecorator({\n name: WITH_CARBON_THEME,\n parameterName: CARBON_THEME_PARAM,\n wrapper: Wrapper,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,MAAM,IAAIC,aAAa,QAAQ,mBAAmB;AACzD,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,iBAAiB,QACZ,UAAU;AAEjB,MAAMC,OAAO,GAAGA,CAACC,QAAQ,EAAEC,OAAO,EAAEC,UAAU,KAAK;EACjD,MAAMC,OAAO,GAAGT,MAAM,CAACU,UAAU,CAAC,CAAC;EACnC,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGb,QAAQ,CAACc,SAAS,CAAC;EAEzD,MAAMC,wBAAwB,GAAIC,KAAK,IAAK;IAC1CC,QAAQ,CAACC,eAAe,CAACC,YAAY,CAAC,wBAAwB,EAAEH,KAAK,CAAC;IACtEH,cAAc,CAACG,KAAK,CAAC;EACvB,CAAC;EAEDjB,SAAS,CAAC,MAAM;IACdW,OAAO,CAACU,EAAE,CAACjB,oBAAoB,EAAEY,wBAAwB,CAAC;IAC1DF,cAAc,CAACD,WAAW,IAAIH,UAAU,CAACY,KAAK,CAAC;IAE/C,OAAO,MAAM;MACXX,OAAO,CAACY,cAAc,CAACnB,oBAAoB,EAAEY,wBAAwB,CAAC;IACxE,CAAC,CAAC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOR,QAAQ,CAACC,OAAO,CAAC;AAC1B,CAAC;AAED,OAAO,MAAMe,eAAe,GAAGrB,aAAa,CAAC;EAC3CsB,IAAI,EAAEnB,iBAAiB;EACvBoB,aAAa,EAAErB,kBAAkB;EACjCsB,OAAO,EAAEpB;AACX,CAAC,CAAC"}
package/dist/register.js DELETED
@@ -1,28 +0,0 @@
1
- /* eslint-disable react/prop-types */
2
- /**
3
- * Copyright IBM Corp. 2016, 2018
4
- *
5
- * This source code is licensed under the Apache-2.0 license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import React from 'react';
10
- import { addons } from '@storybook/addons';
11
- import { CarbonThemesPanel /*, CarbonTypePanel */ } from './components/Panel';
12
- import { CARBON_THEMES_ADDON_ID, CARBON_THEME_PANEL_ID } from './shared';
13
- addons.register(CARBON_THEMES_ADDON_ID, api => {
14
- const channel = addons.getChannel();
15
- addons.addPanel(CARBON_THEME_PANEL_ID, {
16
- title: 'Carbon theme',
17
- render: ({
18
- active,
19
- key
20
- }) => /*#__PURE__*/React.createElement(CarbonThemesPanel, {
21
- api,
22
- active,
23
- key,
24
- channel
25
- })
26
- });
27
- });
28
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.js","names":["React","addons","CarbonThemesPanel","CARBON_THEMES_ADDON_ID","CARBON_THEME_PANEL_ID","register","api","channel","getChannel","addPanel","title","render","active","key","createElement"],"sources":["../src/register.js"],"sourcesContent":["/* eslint-disable react/prop-types */\n/**\n * Copyright IBM Corp. 2016, 2018\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport React from 'react';\nimport { addons } from '@storybook/addons';\nimport { CarbonThemesPanel /*, CarbonTypePanel */ } from './components/Panel';\nimport { CARBON_THEMES_ADDON_ID, CARBON_THEME_PANEL_ID } from './shared';\n\naddons.register(CARBON_THEMES_ADDON_ID, (api) => {\n const channel = addons.getChannel();\n addons.addPanel(CARBON_THEME_PANEL_ID, {\n title: 'Carbon theme',\n render: ({ active, key }) => (\n <CarbonThemesPanel {...{ api, active, key, channel }} />\n ),\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,iBAAiB,CAAC,8BAA8B,oBAAoB;AAC7E,SAASC,sBAAsB,EAAEC,qBAAqB,QAAQ,UAAU;AAExEH,MAAM,CAACI,QAAQ,CAACF,sBAAsB,EAAGG,GAAG,IAAK;EAC/C,MAAMC,OAAO,GAAGN,MAAM,CAACO,UAAU,CAAC,CAAC;EACnCP,MAAM,CAACQ,QAAQ,CAACL,qBAAqB,EAAE;IACrCM,KAAK,EAAE,cAAc;IACrBC,MAAM,EAAEA,CAAC;MAAEC,MAAM;MAAEC;IAAI,CAAC,kBACtBb,KAAA,CAAAc,aAAA,CAACZ,iBAAiB;MAAOI,GAAG;MAAEM,MAAM;MAAEC,GAAG;MAAEN;IAAO,CAAK;EAE3D,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/dist/shared.js DELETED
@@ -1,44 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 2021
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- export const CARBON_THEMES = ['white', 'g10', 'g90', 'g100', 'debug'];
9
- export const WITH_CARBON_THEME = 'withCarbonTheme';
10
- export const CARBON_THEME_PARAM = 'carbonTheme';
11
- export const CARBON_THEME_DEFAULT = 'white';
12
- export const CARBON_THEMES_ADDON_ID = 'carbon-theme';
13
- export const CARBON_THEME = `£{CARBON_THEME_PANEL_ID}/carbonTheme`;
14
- export const CARBON_CURRENT_THEME = `${CARBON_THEMES_ADDON_ID}/current`;
15
- export const CARBON_THEME_PANEL_ID = `${CARBON_THEMES_ADDON_ID}/panel`;
16
- const defaultOptions = {
17
- theme: CARBON_THEMES[0],
18
- themes: CARBON_THEMES
19
- };
20
- export const mergeParams = params => {
21
- const options = {
22
- themes: [],
23
- ...params
24
- };
25
- if (options.themes.length) {
26
- // filter to params.themes
27
- options.themes = defaultOptions.themes.filter(option => options.themes.indexOf(option) > -1);
28
- }
29
-
30
- // check not empty
31
- if (options.themes.length === 0) {
32
- options.themes = defaultOptions.themes.slice(0);
33
- }
34
- if (!options.theme) {
35
- options.theme = defaultOptions.theme;
36
- }
37
- if (options.themes.indexOf(options.theme) < 0) {
38
- // default theme to one that exists
39
- const defaultThemeIndex = options.themes.indexOf(defaultOptions.theme);
40
- options.theme = defaultThemeIndex > 0 ? options.themes[defaultThemeIndex] : options.themes[0];
41
- }
42
- return options;
43
- };
44
- //# sourceMappingURL=shared.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.js","names":["CARBON_THEMES","WITH_CARBON_THEME","CARBON_THEME_PARAM","CARBON_THEME_DEFAULT","CARBON_THEMES_ADDON_ID","CARBON_THEME","CARBON_CURRENT_THEME","CARBON_THEME_PANEL_ID","defaultOptions","theme","themes","mergeParams","params","options","length","filter","option","indexOf","slice","defaultThemeIndex"],"sources":["../src/shared.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2016, 2021\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport const CARBON_THEMES = ['white', 'g10', 'g90', 'g100', 'debug'];\nexport const WITH_CARBON_THEME = 'withCarbonTheme';\nexport const CARBON_THEME_PARAM = 'carbonTheme';\nexport const CARBON_THEME_DEFAULT = 'white';\n\nexport const CARBON_THEMES_ADDON_ID = 'carbon-theme';\nexport const CARBON_THEME = `£{CARBON_THEME_PANEL_ID}/carbonTheme`;\nexport const CARBON_CURRENT_THEME = `${CARBON_THEMES_ADDON_ID}/current`;\nexport const CARBON_THEME_PANEL_ID = `${CARBON_THEMES_ADDON_ID}/panel`;\n\nconst defaultOptions = {\n theme: CARBON_THEMES[0],\n themes: CARBON_THEMES,\n};\n\nexport const mergeParams = (params) => {\n const options = { themes: [], ...params };\n\n if (options.themes.length) {\n // filter to params.themes\n options.themes = defaultOptions.themes.filter(\n (option) => options.themes.indexOf(option) > -1\n );\n }\n\n // check not empty\n if (options.themes.length === 0) {\n options.themes = defaultOptions.themes.slice(0);\n }\n\n if (!options.theme) {\n options.theme = defaultOptions.theme;\n }\n\n if (options.themes.indexOf(options.theme) < 0) {\n // default theme to one that exists\n const defaultThemeIndex = options.themes.indexOf(defaultOptions.theme);\n options.theme =\n defaultThemeIndex > 0\n ? options.themes[defaultThemeIndex]\n : options.themes[0];\n }\n\n return options;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,aAAa,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AACrE,OAAO,MAAMC,iBAAiB,GAAG,iBAAiB;AAClD,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C,OAAO,MAAMC,oBAAoB,GAAG,OAAO;AAE3C,OAAO,MAAMC,sBAAsB,GAAG,cAAc;AACpD,OAAO,MAAMC,YAAY,GAAI,sCAAqC;AAClE,OAAO,MAAMC,oBAAoB,GAAI,GAAEF,sBAAuB,UAAS;AACvE,OAAO,MAAMG,qBAAqB,GAAI,GAAEH,sBAAuB,QAAO;AAEtE,MAAMI,cAAc,GAAG;EACrBC,KAAK,EAAET,aAAa,CAAC,CAAC,CAAC;EACvBU,MAAM,EAAEV;AACV,CAAC;AAED,OAAO,MAAMW,WAAW,GAAIC,MAAM,IAAK;EACrC,MAAMC,OAAO,GAAG;IAAEH,MAAM,EAAE,EAAE;IAAE,GAAGE;EAAO,CAAC;EAEzC,IAAIC,OAAO,CAACH,MAAM,CAACI,MAAM,EAAE;IACzB;IACAD,OAAO,CAACH,MAAM,GAAGF,cAAc,CAACE,MAAM,CAACK,MAAM,CAC1CC,MAAM,IAAKH,OAAO,CAACH,MAAM,CAACO,OAAO,CAACD,MAAM,CAAC,GAAG,CAAC,CAChD,CAAC;EACH;;EAEA;EACA,IAAIH,OAAO,CAACH,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC/BD,OAAO,CAACH,MAAM,GAAGF,cAAc,CAACE,MAAM,CAACQ,KAAK,CAAC,CAAC,CAAC;EACjD;EAEA,IAAI,CAACL,OAAO,CAACJ,KAAK,EAAE;IAClBI,OAAO,CAACJ,KAAK,GAAGD,cAAc,CAACC,KAAK;EACtC;EAEA,IAAII,OAAO,CAACH,MAAM,CAACO,OAAO,CAACJ,OAAO,CAACJ,KAAK,CAAC,GAAG,CAAC,EAAE;IAC7C;IACA,MAAMU,iBAAiB,GAAGN,OAAO,CAACH,MAAM,CAACO,OAAO,CAACT,cAAc,CAACC,KAAK,CAAC;IACtEI,OAAO,CAACJ,KAAK,GACXU,iBAAiB,GAAG,CAAC,GACjBN,OAAO,CAACH,MAAM,CAACS,iBAAiB,CAAC,GACjCN,OAAO,CAACH,MAAM,CAAC,CAAC,CAAC;EACzB;EAEA,OAAOG,OAAO;AAChB,CAAC"}
package/dist/vue.js DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 2018
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import addons, { makeDecorator } from '@storybook/addons';
8
- import { CARBON_CURRENT_THEME, CARBON_THEME_PARAM, WITH_CARBON_THEME } from './shared';
9
- const Wrapper = (getStory, context, {
10
- parameters
11
- }) => {
12
- const channel = addons.getChannel();
13
- const setCarbonTheme = theme => {
14
- document.documentElement.setAttribute('storybook-carbon-theme', theme);
15
- };
16
- return {
17
- template: `<story/>`,
18
- mounted() {
19
- channel.on(CARBON_CURRENT_THEME, setCarbonTheme);
20
- setCarbonTheme(parameters.value);
21
- }
22
- };
23
- };
24
-
25
- // export decorator
26
- export const withCarbonTheme = makeDecorator({
27
- name: WITH_CARBON_THEME,
28
- parameterName: CARBON_THEME_PARAM,
29
- wrapper: Wrapper
30
- });
31
- //# sourceMappingURL=vue.js.map
package/dist/vue.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue.js","names":["addons","makeDecorator","CARBON_CURRENT_THEME","CARBON_THEME_PARAM","WITH_CARBON_THEME","Wrapper","getStory","context","parameters","channel","getChannel","setCarbonTheme","theme","document","documentElement","setAttribute","template","mounted","on","value","withCarbonTheme","name","parameterName","wrapper"],"sources":["../src/vue.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2016, 2018\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport addons, { makeDecorator } from '@storybook/addons';\nimport {\n CARBON_CURRENT_THEME,\n CARBON_THEME_PARAM,\n WITH_CARBON_THEME,\n} from './shared';\n\nconst Wrapper = (getStory, context, { parameters }) => {\n const channel = addons.getChannel();\n\n const setCarbonTheme = (theme) => {\n document.documentElement.setAttribute('storybook-carbon-theme', theme);\n };\n\n return {\n template: `<story/>`,\n mounted() {\n channel.on(CARBON_CURRENT_THEME, setCarbonTheme);\n setCarbonTheme(parameters.value);\n },\n };\n};\n\n// export decorator\nexport const withCarbonTheme = makeDecorator({\n name: WITH_CARBON_THEME,\n parameterName: CARBON_THEME_PARAM,\n wrapper: Wrapper,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,MAAM,IAAIC,aAAa,QAAQ,mBAAmB;AACzD,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,iBAAiB,QACZ,UAAU;AAEjB,MAAMC,OAAO,GAAGA,CAACC,QAAQ,EAAEC,OAAO,EAAE;EAAEC;AAAW,CAAC,KAAK;EACrD,MAAMC,OAAO,GAAGT,MAAM,CAACU,UAAU,CAAC,CAAC;EAEnC,MAAMC,cAAc,GAAIC,KAAK,IAAK;IAChCC,QAAQ,CAACC,eAAe,CAACC,YAAY,CAAC,wBAAwB,EAAEH,KAAK,CAAC;EACxE,CAAC;EAED,OAAO;IACLI,QAAQ,EAAG,UAAS;IACpBC,OAAOA,CAAA,EAAG;MACRR,OAAO,CAACS,EAAE,CAAChB,oBAAoB,EAAES,cAAc,CAAC;MAChDA,cAAc,CAACH,UAAU,CAACW,KAAK,CAAC;IAClC;EACF,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMC,eAAe,GAAGnB,aAAa,CAAC;EAC3CoB,IAAI,EAAEjB,iBAAiB;EACvBkB,aAAa,EAAEnB,kBAAkB;EACjCoB,OAAO,EAAElB;AACX,CAAC,CAAC"}