@toptal/davinci-storybook-addons 1.1.7-alpha-fix-execute-graphql-command-64ee6d5e.26 → 1.1.7

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.
Files changed (3) hide show
  1. package/README.md +17 -0
  2. package/package.json +5 -6
  3. package/src/index.js +26 -20
package/README.md CHANGED
@@ -40,6 +40,23 @@ module.exports = {
40
40
 
41
41
  Valid addon keys can be any value from the `Contents` section
42
42
 
43
+ ### Customizing addons
44
+
45
+ You can provide addon specific options in `.storybook/main.js` as follows:
46
+
47
+ ```js
48
+ module.exports = {
49
+ addons: [{
50
+ name: '@toptal/davinci-storybook-addons',
51
+ options: {
52
+ '@storybook/addon-docs': {
53
+ transcludeMarkdown: true,
54
+ },
55
+ },
56
+ }]
57
+ }
58
+ ```
59
+
43
60
  ## Contents
44
61
 
45
62
  Here's a list of all addons used in `davinci-storybook-addons` package
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-storybook-addons",
3
- "version": "1.1.7-alpha-fix-execute-graphql-command-64ee6d5e.26+64ee6d5e",
3
+ "version": "1.1.7",
4
4
  "description": "Addons for davinci-based storybook for the best developer experience",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -47,14 +47,13 @@
47
47
  "@storybook/core-events": "^6.5.9",
48
48
  "@storybook/react": "^6.5.10",
49
49
  "@storybook/theming": "^6.5.10",
50
- "@toptal/davinci-cli-shared": "1.10.1-alpha-fix-execute-graphql-command-64ee6d5e.19+64ee6d5e",
51
- "@toptal/davinci-storybook-full-text-search-addon": "0.2.5-alpha-fix-execute-graphql-command-64ee6d5e.26+64ee6d5e",
52
- "@toptal/davinci-storybook-live-edit-addon": "0.2.4-alpha-fix-execute-graphql-command-64ee6d5e.28+64ee6d5e"
50
+ "@toptal/davinci-cli-shared": "^1.5.2",
51
+ "@toptal/davinci-storybook-full-text-search-addon": "0.2.4",
52
+ "@toptal/davinci-storybook-live-edit-addon": "0.2.3"
53
53
  },
54
54
  "devDependencies": {
55
55
  "mdast-builder": "^1.1.1",
56
56
  "mdast-util-heading-range": "^2.1.5",
57
57
  "remark": "^13.0.0"
58
- },
59
- "gitHead": "64ee6d5e0f752824e63dc28ea753ec9415b9e483"
58
+ }
60
59
  }
package/src/index.js CHANGED
@@ -1,28 +1,34 @@
1
- const { dirname, join } = require('path')
2
-
3
1
  const { STORYBOOK_ADDONS, CUSTOM_ADDONS } = require('./constants')
4
2
 
5
3
  const addons = options => {
6
- return []
7
- .concat(
8
- CUSTOM_ADDONS.filter(addon => options[addon.name] !== false).map(
9
- ({ path }) => path
10
- )
11
- )
12
- .concat(
13
- STORYBOOK_ADDONS.filter(addon => options[addon] !== false)
14
- .map(addon => `@storybook/addon-${addon}`)
15
- .map(addon => {
16
- // inspired by storybook essentials:
17
- // https://github.com/storybookjs/storybook/blob/next/addons/essentials/src/index.ts#L52-L57
18
- try {
19
- return dirname(require.resolve(join(addon, 'package.json')))
20
- // eslint-disable-next-line no-empty
21
- } catch (ignore) {}
4
+ const addonsArray = []
5
+
6
+ // filter custom addons by options
7
+ for (const addon of CUSTOM_ADDONS) {
8
+ if (options[addon.name] !== false) {
9
+ addonsArray.push(addon.path)
10
+ }
11
+ }
22
12
 
23
- return require.resolve(addon)
13
+ // filter storybook addons by options
14
+ // if options specified, pass it to addon
15
+ for (const addon of STORYBOOK_ADDONS) {
16
+ const addonName = `@storybook/addon-${addon}`
17
+ const addonsOptions = options[addonName]
18
+
19
+ if (addonsOptions !== false) {
20
+ if (addonsOptions && typeof addonsOptions === 'object') {
21
+ addonsArray.push({
22
+ name: addonName,
23
+ options: addonsOptions,
24
24
  })
25
- )
25
+ } else {
26
+ addonsArray.push(addonName)
27
+ }
28
+ }
29
+ }
30
+
31
+ return addonsArray
26
32
  }
27
33
 
28
34
  module.exports = { addons }