From 7290087680fadf04d0515e45f68b2bbe3516ad34 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Mon, 2 Sep 2019 15:20:36 +0200 Subject: [PATCH] Add dynamic stories --- babel.config.js | 3 ++- package-lock.json | 50 +++++++++++++++++------------------------ package.json | 1 + src/storybook/config.js | 8 ++++++- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/babel.config.js b/babel.config.js index 723c15517..0db43fbd4 100644 --- a/babel.config.js +++ b/babel.config.js @@ -37,7 +37,8 @@ module.exports = api => { extractFromFormatMessageCall: true, messagesDir: "build/locale/" } - ] + ], + "macros" ]; return { diff --git a/package-lock.json b/package-lock.json index cdfa829e5..eedf6a666 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9409,8 +9409,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -9428,13 +9427,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -9447,18 +9444,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -9561,8 +9555,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -9572,7 +9565,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -9585,20 +9577,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9615,7 +9604,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -9688,8 +9676,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -9699,7 +9686,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -9775,8 +9761,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -9806,7 +9791,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9824,7 +9808,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9863,13 +9846,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -16962,6 +16943,15 @@ "tough-cookie": "^2.3.3" } }, + "require-context.macro": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/require-context.macro/-/require-context.macro-1.1.1.tgz", + "integrity": "sha512-l1XH5HruDyG+Iwo5pz39EGbOFVtoYQt8cl7mJ6KJFWzARNJnpb+XUui+jBQUGlJ8SJOdx+QDh784e8b42PxLXA==", + "dev": true, + "requires": { + "@types/webpack-env": "^1.14.0" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", diff --git a/package.json b/package.json index 6c8830060..d18a61efb 100644 --- a/package.json +++ b/package.json @@ -120,6 +120,7 @@ "react-intl-po": "^2.2.2", "react-test-renderer": "^16.8.6", "regenerator-runtime": "^0.11.1", + "require-context.macro": "^1.1.1", "rimraf": "^2.7.0", "testcafe": "^1.3.3", "ts-jest": "^23.10.5", diff --git a/src/storybook/config.js b/src/storybook/config.js index 78aff494a..89b3a57cf 100644 --- a/src/storybook/config.js +++ b/src/storybook/config.js @@ -1,7 +1,13 @@ /* eslint-disable */ -const { configure } = require("@storybook/react"); +import requireContext from "require-context.macro"; +import { configure } from "@storybook/react"; + +const req = requireContext("../", true, /.stories.tsx$/); function loadStories() { + // Story autodiscovery + req.keys().forEach(filename => req(filename)); + // Components require("./stories/components/ActionDialog"); require("./stories/components/AddressEdit");