@carbon/storybook-addon-theme 1.0.0 → 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 +65 -70
- package/{react.js → constants.js} +2 -2
- package/dist/Panel.js +24 -0
- package/dist/Panel.js.map +1 -0
- package/dist/components/PanelContent.js +34 -0
- package/dist/components/PanelContent.js.map +1 -0
- package/dist/constants.js +17 -0
- package/dist/constants.js.map +1 -0
- package/dist/decorators/withCarbonTheme.js +27 -0
- package/dist/decorators/withCarbonTheme.js.map +1 -0
- package/dist/manager.js +18 -0
- package/dist/manager.js.map +1 -0
- package/dist/preset.js +14 -0
- package/dist/preset.js.map +1 -0
- package/package.json +10 -10
- package/{register.js → preset.js} +2 -2
- package/{vue.js → withCarbonTheme.js} +2 -2
- package/dist/components/Panel.js +0 -73
- package/dist/components/Panel.js.map +0 -1
- package/dist/react.js +0 -31
- package/dist/react.js.map +0 -1
- package/dist/register.js +0 -28
- package/dist/register.js.map +0 -1
- package/dist/shared.js +0 -44
- package/dist/shared.js.map +0 -1
- package/dist/vue.js +0 -31
- package/dist/vue.js.map +0 -1
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
|
41
|
+
// other addons...
|
42
|
+
addons: ['@carbon/storybook-addon-theme/preset.js'],
|
39
43
|
};
|
40
44
|
```
|
41
45
|
|
42
|
-
|
46
|
+
### Global Decorator
|
47
|
+
|
48
|
+
`.storybook/preview.js`:
|
43
49
|
|
44
50
|
```js
|
45
|
-
|
46
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
54
|
+
const decorators = [
|
55
|
+
/// other decorators...
|
56
|
+
withCarbonTheme
|
57
|
+
];
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
68
|
+
## SCSS
|
60
69
|
|
61
|
-
`.storybook/
|
70
|
+
`.storybook/index.scss`
|
62
71
|
|
63
|
-
|
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
|
-
```
|
76
|
-
|
77
|
-
|
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
|
-
|
87
|
-
|
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
|
-
|
81
|
+
/* make sure background and color are set if theme in use */
|
82
|
+
background-color: $background;
|
83
|
+
color: $text-primary;
|
84
|
+
}
|
98
85
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
102
|
+
### Carbon 10
|
118
103
|
|
119
|
-
|
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
|
-
|
122
|
-
@import
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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"}
|
package/dist/manager.js
ADDED
@@ -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": "
|
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": "
|
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": "
|
46
|
-
"@storybook/api": "
|
47
|
-
"@storybook/client-api": "
|
48
|
-
"@storybook/client-logger": "
|
49
|
-
"@storybook/components": "
|
50
|
-
"@storybook/core-events": "
|
51
|
-
"@storybook/theming": "
|
52
|
-
"core-js": "^3.
|
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": {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp.
|
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
|
-
|
7
|
+
module.exports = require('./dist/preset.js');
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp.
|
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
|
-
|
7
|
+
module.exports = require('./dist/decorators/withCarbonTheme');
|
package/dist/components/Panel.js
DELETED
@@ -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
|
package/dist/register.js.map
DELETED
@@ -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
|
package/dist/shared.js.map
DELETED
@@ -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"}
|