UNPKG

1.71 kBJavaScriptView Raw
1"use strict";
2
3require("core-js/modules/es.object.assign");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports["default"] = void 0;
9
10var _addons = require("@storybook/addons");
11
12var _Centered = _interopRequireDefault(require("./components/Centered.svelte"));
13
14var _styles = _interopRequireDefault(require("./styles"));
15
16var _json2CSS = _interopRequireDefault(require("./helpers/json2CSS"));
17
18var _parameters = _interopRequireDefault(require("./parameters"));
19
20function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
22var centeredStyles = {
23 /** @type {string} */
24 style: (0, _json2CSS["default"])(_styles["default"].style),
25
26 /** @type {string} */
27 innerStyle: (0, _json2CSS["default"])(_styles["default"].innerStyle)
28};
29/**
30 * This functionality works by passing the svelte story component into another
31 * svelte component that has the single purpose of centering the story component
32 * using a wrapper and container.
33 *
34 * We use the special element <svelte:component /> to achieve this.
35 *
36 * @see https://svelte.technology/guide#svelte-component
37 */
38
39function centered(storyFn) {
40 var _storyFn = storyFn(),
41 OriginalComponent = _storyFn.Component,
42 props = _storyFn.props,
43 on = _storyFn.on;
44
45 return {
46 Component: OriginalComponent,
47 props: props,
48 on: on,
49 Wrapper: _Centered["default"],
50 WrapperData: centeredStyles
51 };
52}
53
54var _default = (0, _addons.makeDecorator)(Object.assign({}, _parameters["default"], {
55 wrapper: function wrapper(getStory) {
56 return centered(getStory);
57 }
58}));
59
60exports["default"] = _default;
61
62if (module && module.hot && module.hot.decline) {
63 module.hot.decline();
64}
\No newline at end of file