@atlaskit/storybook-addon-design-system 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @atlaskit/storybook-addon-design-system
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ddbec37a16c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ddbec37a16c) - Initial release of the design system storybook addon package. Intended to be a generic package for all storybook releated DS tooling
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2021-Present Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Design System storybook addons
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "withDesignTokens", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _tokens.withDesignTokens;
10
+ }
11
+ });
12
+
13
+ var _tokens = require("./tokens");
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PANEL_TITLE = exports.PANEL_ID = exports.EVENT_THEME_CHANGED = exports.DECORATOR_PARAM = exports.DECORATOR_ID = exports.ADDON_ID = void 0;
7
+ var ADDON_ID = 'ads-tokens';
8
+ exports.ADDON_ID = ADDON_ID;
9
+ var PANEL_ID = "".concat(ADDON_ID, "/panel");
10
+ exports.PANEL_ID = PANEL_ID;
11
+ var PANEL_TITLE = "Design Tokens";
12
+ exports.PANEL_TITLE = PANEL_TITLE;
13
+ var EVENT_THEME_CHANGED = "".concat(ADDON_ID, "/on-theme-change");
14
+ exports.EVENT_THEME_CHANGED = EVENT_THEME_CHANGED;
15
+ var DECORATOR_ID = 'withDesignTokens';
16
+ exports.DECORATOR_ID = DECORATOR_ID;
17
+ var DECORATOR_PARAM = 'DesignTokens';
18
+ exports.DECORATOR_PARAM = DECORATOR_PARAM;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _addons = require("@storybook/addons");
9
+
10
+ require("../../../node_modules/@atlaskit/tokens/css/atlassian-light.css");
11
+
12
+ require("../../../node_modules/@atlaskit/tokens/css/atlassian-dark.css");
13
+
14
+ var _constants = require("./constants");
15
+
16
+ // eslint-disable-next-line
17
+ // eslint-disable-next-line
18
+ var withDesignTokens = (0, _addons.makeDecorator)({
19
+ name: _constants.DECORATOR_ID,
20
+ parameterName: _constants.DECORATOR_PARAM,
21
+ wrapper: function wrapper(storyFn, context) {
22
+ // eslint-disable-next-line react-hooks/rules-of-hooks
23
+ (0, _addons.useEffect)(function () {
24
+ var setTheme = function setTheme(theme) {
25
+ if (!theme || theme === 'none') {
26
+ delete document.documentElement.dataset.theme;
27
+ return;
28
+ } // HACK: Allows us to disable the light mode style since it uses root:
29
+
30
+
31
+ if (theme === 'light') {
32
+ document.querySelectorAll('style').forEach(function (el) {
33
+ if (el.innerText.includes(':root, html[data-theme="light"]')) {
34
+ el.innerText = el.textContent.replace(':root,', '');
35
+ }
36
+ });
37
+ }
38
+
39
+ document.documentElement.dataset.theme = theme;
40
+ };
41
+
42
+ var channel = _addons.addons.getChannel();
43
+
44
+ channel.on(_constants.EVENT_THEME_CHANGED, setTheme);
45
+ return function () {
46
+ channel.off(_constants.EVENT_THEME_CHANGED, setTheme);
47
+ };
48
+ }, [context.id]);
49
+ return storyFn(context);
50
+ }
51
+ });
52
+ var _default = withDesignTokens;
53
+ exports.default = _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "withDesignTokens", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _decorator.default;
12
+ }
13
+ });
14
+
15
+ var _decorator = _interopRequireDefault(require("./decorator"));
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _addons = require("@storybook/addons");
8
+
9
+ var _components = require("@storybook/components");
10
+
11
+ var _constants = require("./constants");
12
+
13
+ // eslint-disable-next-line import/no-extraneous-dependencies
14
+ // eslint-disable-next-line import/no-extraneous-dependencies
15
+ var TokensPanel = function TokensPanel(_ref) {
16
+ var onThemeChange = _ref.onThemeChange;
17
+ return /*#__PURE__*/_react.default.createElement("div", {
18
+ style: {
19
+ padding: '20px'
20
+ }
21
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "ADS Design Tokens"), /*#__PURE__*/_react.default.createElement("select", {
22
+ name: "theme",
23
+ onChange: function onChange(event) {
24
+ return onThemeChange(event.target.value);
25
+ }
26
+ }, /*#__PURE__*/_react.default.createElement("option", {
27
+ value: "none"
28
+ }, "Disable theme"), /*#__PURE__*/_react.default.createElement("option", {
29
+ value: "light"
30
+ }, "Light theme"), /*#__PURE__*/_react.default.createElement("option", {
31
+ value: "dark"
32
+ }, "Dark theme")));
33
+ };
34
+
35
+ _addons.addons.register(_constants.ADDON_ID, function (api) {
36
+ _addons.addons.add(_constants.PANEL_ID, {
37
+ type: _addons.types.PANEL,
38
+ title: _constants.PANEL_TITLE,
39
+ render: function render(_ref2) {
40
+ var active = _ref2.active,
41
+ key = _ref2.key;
42
+ return /*#__PURE__*/_react.default.createElement(_components.AddonPanel, {
43
+ active: active || false,
44
+ key: key
45
+ }, /*#__PURE__*/_react.default.createElement(TokensPanel, {
46
+ onThemeChange: function onThemeChange(theme) {
47
+ return api.emit(_constants.EVENT_THEME_CHANGED, theme);
48
+ }
49
+ }));
50
+ }
51
+ });
52
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/storybook-addon-design-system",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { withDesignTokens } from './tokens';
@@ -0,0 +1,6 @@
1
+ export const ADDON_ID = 'ads-tokens';
2
+ export const PANEL_ID = `${ADDON_ID}/panel`;
3
+ export const PANEL_TITLE = `Design Tokens`;
4
+ export const EVENT_THEME_CHANGED = `${ADDON_ID}/on-theme-change`;
5
+ export const DECORATOR_ID = 'withDesignTokens';
6
+ export const DECORATOR_PARAM = 'DesignTokens';
@@ -0,0 +1,40 @@
1
+ import { addons, makeDecorator, useEffect } from '@storybook/addons'; // eslint-disable-next-line
2
+
3
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-light.css'; // eslint-disable-next-line
4
+
5
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-dark.css';
6
+ import { DECORATOR_ID, DECORATOR_PARAM, EVENT_THEME_CHANGED } from './constants';
7
+ const withDesignTokens = makeDecorator({
8
+ name: DECORATOR_ID,
9
+ parameterName: DECORATOR_PARAM,
10
+ wrapper: (storyFn, context) => {
11
+ // eslint-disable-next-line react-hooks/rules-of-hooks
12
+ useEffect(() => {
13
+ const setTheme = theme => {
14
+ if (!theme || theme === 'none') {
15
+ delete document.documentElement.dataset.theme;
16
+ return;
17
+ } // HACK: Allows us to disable the light mode style since it uses root:
18
+
19
+
20
+ if (theme === 'light') {
21
+ document.querySelectorAll('style').forEach(el => {
22
+ if (el.innerText.includes(':root, html[data-theme="light"]')) {
23
+ el.innerText = el.textContent.replace(':root,', '');
24
+ }
25
+ });
26
+ }
27
+
28
+ document.documentElement.dataset.theme = theme;
29
+ };
30
+
31
+ const channel = addons.getChannel();
32
+ channel.on(EVENT_THEME_CHANGED, setTheme);
33
+ return () => {
34
+ channel.off(EVENT_THEME_CHANGED, setTheme);
35
+ };
36
+ }, [context.id]);
37
+ return storyFn(context);
38
+ }
39
+ });
40
+ export default withDesignTokens;
@@ -0,0 +1 @@
1
+ export { default as withDesignTokens } from './decorator';
@@ -0,0 +1,39 @@
1
+ import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
2
+
3
+ import { addons, types } from '@storybook/addons'; // eslint-disable-next-line import/no-extraneous-dependencies
4
+
5
+ import { AddonPanel } from '@storybook/components';
6
+ import { ADDON_ID, EVENT_THEME_CHANGED, PANEL_ID, PANEL_TITLE } from './constants';
7
+
8
+ const TokensPanel = ({
9
+ onThemeChange
10
+ }) => /*#__PURE__*/React.createElement("div", {
11
+ style: {
12
+ padding: '20px'
13
+ }
14
+ }, /*#__PURE__*/React.createElement("h1", null, "ADS Design Tokens"), /*#__PURE__*/React.createElement("select", {
15
+ name: "theme",
16
+ onChange: event => onThemeChange(event.target.value)
17
+ }, /*#__PURE__*/React.createElement("option", {
18
+ value: "none"
19
+ }, "Disable theme"), /*#__PURE__*/React.createElement("option", {
20
+ value: "light"
21
+ }, "Light theme"), /*#__PURE__*/React.createElement("option", {
22
+ value: "dark"
23
+ }, "Dark theme")));
24
+
25
+ addons.register(ADDON_ID, api => {
26
+ addons.add(PANEL_ID, {
27
+ type: types.PANEL,
28
+ title: PANEL_TITLE,
29
+ render: ({
30
+ active,
31
+ key
32
+ }) => /*#__PURE__*/React.createElement(AddonPanel, {
33
+ active: active || false,
34
+ key: key
35
+ }, /*#__PURE__*/React.createElement(TokensPanel, {
36
+ onThemeChange: theme => api.emit(EVENT_THEME_CHANGED, theme)
37
+ }))
38
+ });
39
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/storybook-addon-design-system",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { withDesignTokens } from './tokens';
@@ -0,0 +1,6 @@
1
+ export var ADDON_ID = 'ads-tokens';
2
+ export var PANEL_ID = "".concat(ADDON_ID, "/panel");
3
+ export var PANEL_TITLE = "Design Tokens";
4
+ export var EVENT_THEME_CHANGED = "".concat(ADDON_ID, "/on-theme-change");
5
+ export var DECORATOR_ID = 'withDesignTokens';
6
+ export var DECORATOR_PARAM = 'DesignTokens';
@@ -0,0 +1,40 @@
1
+ import { addons, makeDecorator, useEffect } from '@storybook/addons'; // eslint-disable-next-line
2
+
3
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-light.css'; // eslint-disable-next-line
4
+
5
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-dark.css';
6
+ import { DECORATOR_ID, DECORATOR_PARAM, EVENT_THEME_CHANGED } from './constants';
7
+ var withDesignTokens = makeDecorator({
8
+ name: DECORATOR_ID,
9
+ parameterName: DECORATOR_PARAM,
10
+ wrapper: function wrapper(storyFn, context) {
11
+ // eslint-disable-next-line react-hooks/rules-of-hooks
12
+ useEffect(function () {
13
+ var setTheme = function setTheme(theme) {
14
+ if (!theme || theme === 'none') {
15
+ delete document.documentElement.dataset.theme;
16
+ return;
17
+ } // HACK: Allows us to disable the light mode style since it uses root:
18
+
19
+
20
+ if (theme === 'light') {
21
+ document.querySelectorAll('style').forEach(function (el) {
22
+ if (el.innerText.includes(':root, html[data-theme="light"]')) {
23
+ el.innerText = el.textContent.replace(':root,', '');
24
+ }
25
+ });
26
+ }
27
+
28
+ document.documentElement.dataset.theme = theme;
29
+ };
30
+
31
+ var channel = addons.getChannel();
32
+ channel.on(EVENT_THEME_CHANGED, setTheme);
33
+ return function () {
34
+ channel.off(EVENT_THEME_CHANGED, setTheme);
35
+ };
36
+ }, [context.id]);
37
+ return storyFn(context);
38
+ }
39
+ });
40
+ export default withDesignTokens;
@@ -0,0 +1 @@
1
+ export { default as withDesignTokens } from './decorator';
@@ -0,0 +1,45 @@
1
+ import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
2
+
3
+ import { addons, types } from '@storybook/addons'; // eslint-disable-next-line import/no-extraneous-dependencies
4
+
5
+ import { AddonPanel } from '@storybook/components';
6
+ import { ADDON_ID, EVENT_THEME_CHANGED, PANEL_ID, PANEL_TITLE } from './constants';
7
+
8
+ var TokensPanel = function TokensPanel(_ref) {
9
+ var onThemeChange = _ref.onThemeChange;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ style: {
12
+ padding: '20px'
13
+ }
14
+ }, /*#__PURE__*/React.createElement("h1", null, "ADS Design Tokens"), /*#__PURE__*/React.createElement("select", {
15
+ name: "theme",
16
+ onChange: function onChange(event) {
17
+ return onThemeChange(event.target.value);
18
+ }
19
+ }, /*#__PURE__*/React.createElement("option", {
20
+ value: "none"
21
+ }, "Disable theme"), /*#__PURE__*/React.createElement("option", {
22
+ value: "light"
23
+ }, "Light theme"), /*#__PURE__*/React.createElement("option", {
24
+ value: "dark"
25
+ }, "Dark theme")));
26
+ };
27
+
28
+ addons.register(ADDON_ID, function (api) {
29
+ addons.add(PANEL_ID, {
30
+ type: types.PANEL,
31
+ title: PANEL_TITLE,
32
+ render: function render(_ref2) {
33
+ var active = _ref2.active,
34
+ key = _ref2.key;
35
+ return /*#__PURE__*/React.createElement(AddonPanel, {
36
+ active: active || false,
37
+ key: key
38
+ }, /*#__PURE__*/React.createElement(TokensPanel, {
39
+ onThemeChange: function onThemeChange(theme) {
40
+ return api.emit(EVENT_THEME_CHANGED, theme);
41
+ }
42
+ }));
43
+ }
44
+ });
45
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/storybook-addon-design-system",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { withDesignTokens } from './tokens';
@@ -0,0 +1,6 @@
1
+ export declare const ADDON_ID = "ads-tokens";
2
+ export declare const PANEL_ID: string;
3
+ export declare const PANEL_TITLE = "Design Tokens";
4
+ export declare const EVENT_THEME_CHANGED: string;
5
+ export declare const DECORATOR_ID = "withDesignTokens";
6
+ export declare const DECORATOR_PARAM = "DesignTokens";
@@ -0,0 +1,4 @@
1
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-light.css';
2
+ import '../../../node_modules/@atlaskit/tokens/css/atlassian-dark.css';
3
+ declare const withDesignTokens: (...args: any) => any;
4
+ export default withDesignTokens;
@@ -0,0 +1 @@
1
+ export { default as withDesignTokens } from './decorator';
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@atlaskit/storybook-addon-design-system",
3
+ "version": "0.1.0",
4
+ "author": "Atlassian Pty Ltd",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org/"
7
+ },
8
+ "atlassian": {
9
+ "team": "Design System Team",
10
+ "releaseModel": "scheduled"
11
+ },
12
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
13
+ "main": "dist/cjs/index.js",
14
+ "module": "dist/esm/index.js",
15
+ "module:es2019": "dist/es2019/index.js",
16
+ "types": "dist/types/index.d.ts",
17
+ "sideEffects": false,
18
+ "atlaskit:src": "src/index.tsx",
19
+ "af:exports": {
20
+ ".": "./src/index.tsx"
21
+ },
22
+ "dependencies": {
23
+ "@atlaskit/tokens": "^0.4.0",
24
+ "@babel/runtime": "^7.0.0",
25
+ "@storybook/addons": "^6.1.11",
26
+ "@storybook/components": "^6.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^16.8.0"
33
+ },
34
+ "techstack": {
35
+ "@atlassian/frontend": {
36
+ "import-structure": "atlassian-conventions"
37
+ },
38
+ "@repo/internal": {
39
+ "design-system": "v1",
40
+ "deprecation": "no-deprecated-imports",
41
+ "styling": "emotion"
42
+ }
43
+ },
44
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
45
+ }
@@ -0,0 +1,2 @@
1
+ /* eslint-disable */
2
+ require('./dist/cjs/tokens/register');