@storybook/ember 0.0.0-pr-23609-sha-f47ef339
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/README.md +53 -0
- package/dist/client/preview/config.d.ts +4 -0
- package/dist/client/preview/config.js +6 -0
- package/dist/client/preview/globals.d.ts +1 -0
- package/dist/client/preview/globals.js +5 -0
- package/dist/client/preview/index.d.ts +7 -0
- package/dist/client/preview/index.js +14 -0
- package/dist/client/preview/render.d.ts +3 -0
- package/dist/client/preview/render.js +70 -0
- package/dist/client/preview/types.d.ts +19 -0
- package/dist/client/preview/types.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -0
- package/dist/index.mjs +5 -0
- package/dist/preset.d.ts +4 -0
- package/dist/preset.js +20 -0
- package/dist/preset.mjs +16 -0
- package/dist/server/framework-preset-babel-ember.d.ts +4 -0
- package/dist/server/framework-preset-babel-ember.js +50 -0
- package/dist/server/framework-preset-ember-docs.d.ts +2 -0
- package/dist/server/framework-preset-ember-docs.js +11 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +2 -0
- package/dist/types.mjs +1 -0
- package/jest.config.js +7 -0
- package/package.json +63 -0
- package/preset.js +1 -0
- package/src/client/docs/config.js +12 -0
- package/src/client/docs/index.js +1 -0
- package/src/client/docs/jsondoc.js +50 -0
- package/src/client/preview/docs/config.js +9 -0
- package/src/client/preview/docs/index.js +1 -0
- package/src/client/preview/docs/jsondoc.js +50 -0
- package/src/typings.d.ts +4 -0
- package/template/cli/Button.stories.js +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Storybook for Ember
|
|
2
|
+
|
|
3
|
+
Storybook for Ember is a UI development environment for your Ember components.
|
|
4
|
+
With it, you can visualize different states of your UI components and develop them interactively.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
Storybook runs outside of your app.
|
|
9
|
+
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
cd my-ember-app
|
|
15
|
+
npx storybook@latest init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For more information visit: [storybook.js.org](https://storybook.js.org)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish.
|
|
23
|
+
You can also build a [static version](https://storybook.js.org/docs/ember/sharing/publish-storybook) of your Storybook and deploy it anywhere you want.
|
|
24
|
+
|
|
25
|
+
## Docs
|
|
26
|
+
|
|
27
|
+
- [Basics](https://storybook.js.org/docs/ember/get-started/introduction)
|
|
28
|
+
- [Configurations](https://storybook.js.org/docs/ember/configure/overview)
|
|
29
|
+
- [Addons](https://storybook.js.org/docs/ember/configure/storybook-addons)
|
|
30
|
+
|
|
31
|
+
## Working with polyfills
|
|
32
|
+
|
|
33
|
+
If you need to use a polyfill that is already in use in our Ember application,
|
|
34
|
+
you will need to add some options to have Storybook working with them.
|
|
35
|
+
|
|
36
|
+
In this example we'll use the [named-block-polyfill](https://github.com/ember-polyfills/ember-named-blocks-polyfill).
|
|
37
|
+
This example also assume that you already have the package in your `package.json`.
|
|
38
|
+
|
|
39
|
+
In your `.storybook/main.js` you can add the following lines:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import namedBlockPolyfill from 'ember-named-blocks-polyfill/lib/named-blocks-polyfill-plugin';
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
framework: {
|
|
46
|
+
name: '@storybook/ember',
|
|
47
|
+
options: {
|
|
48
|
+
polyfills: [namedBlockPolyfill],
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[...]
|
|
52
|
+
};
|
|
53
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parameters = exports.renderToCanvas = void 0;
|
|
4
|
+
var render_1 = require("./render");
|
|
5
|
+
Object.defineProperty(exports, "renderToCanvas", { enumerable: true, get: function () { return render_1.renderToCanvas; } });
|
|
6
|
+
exports.parameters = { renderer: 'ember' };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './globals';
|
|
2
|
+
import type { EmberRenderer } from './types';
|
|
3
|
+
declare const forceReRender: () => void;
|
|
4
|
+
export declare const raw: ((...args: any[]) => never) | (() => import("lib/types/dist").BoundStory<EmberRenderer>[] | undefined);
|
|
5
|
+
export declare const storiesOf: (kind: string, m: any) => import("lib/types/dist").Addon_StoryApi<import("./types").OptionsArgs>;
|
|
6
|
+
export declare const configure: (...args: any[]) => any;
|
|
7
|
+
export { forceReRender };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forceReRender = exports.configure = exports.storiesOf = exports.raw = void 0;
|
|
4
|
+
const preview_api_1 = require("@storybook/preview-api");
|
|
5
|
+
require("./globals");
|
|
6
|
+
const render_1 = require("./render");
|
|
7
|
+
const { configure: coreConfigure, clientApi, forceReRender } = (0, preview_api_1.start)(render_1.renderToCanvas);
|
|
8
|
+
exports.forceReRender = forceReRender;
|
|
9
|
+
exports.raw = clientApi.raw;
|
|
10
|
+
const RENDERER = 'ember';
|
|
11
|
+
const storiesOf = (kind, m) => clientApi.storiesOf(kind, m).addParameters({ renderer: RENDERER });
|
|
12
|
+
exports.storiesOf = storiesOf;
|
|
13
|
+
const configure = (...args) => coreConfigure(RENDERER, ...args);
|
|
14
|
+
exports.configure = configure;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderToCanvas = void 0;
|
|
7
|
+
const global_1 = require("@storybook/global");
|
|
8
|
+
const ts_dedent_1 = require("ts-dedent");
|
|
9
|
+
// @ts-expect-error (Converted from ts-ignore)
|
|
10
|
+
const component_1 = __importDefault(require("@ember/component")); // eslint-disable-line import/no-unresolved
|
|
11
|
+
const { document } = global_1.global;
|
|
12
|
+
const rootEl = document.getElementById('storybook-root');
|
|
13
|
+
const config = global_1.global.require(`${global_1.global.STORYBOOK_NAME}/config/environment`);
|
|
14
|
+
const app = global_1.global.require(`${global_1.global.STORYBOOK_NAME}/app`).default.create({
|
|
15
|
+
autoboot: false,
|
|
16
|
+
rootElement: rootEl,
|
|
17
|
+
...config.APP,
|
|
18
|
+
});
|
|
19
|
+
let lastPromise = app.boot();
|
|
20
|
+
let hasRendered = false;
|
|
21
|
+
let isRendering = false;
|
|
22
|
+
function render(options, el) {
|
|
23
|
+
if (isRendering)
|
|
24
|
+
return;
|
|
25
|
+
isRendering = true;
|
|
26
|
+
const { template, context = {}, element } = options;
|
|
27
|
+
if (hasRendered) {
|
|
28
|
+
lastPromise = lastPromise.then((instance) => instance.destroy());
|
|
29
|
+
}
|
|
30
|
+
lastPromise = lastPromise
|
|
31
|
+
.then(() => {
|
|
32
|
+
const appInstancePrivate = app.buildInstance();
|
|
33
|
+
return appInstancePrivate.boot().then(() => appInstancePrivate);
|
|
34
|
+
})
|
|
35
|
+
.then((instance) => {
|
|
36
|
+
instance.register('component:story-mode', component_1.default.extend({
|
|
37
|
+
layout: template || options,
|
|
38
|
+
...context,
|
|
39
|
+
}));
|
|
40
|
+
const component = instance.lookup('component:story-mode');
|
|
41
|
+
if (element) {
|
|
42
|
+
component.appendTo(element);
|
|
43
|
+
element.appendTo(el);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
component.appendTo(el);
|
|
47
|
+
}
|
|
48
|
+
hasRendered = true;
|
|
49
|
+
isRendering = false;
|
|
50
|
+
return instance;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function renderToCanvas({ storyFn, kind, name, showMain, showError }, canvasElement) {
|
|
54
|
+
const element = storyFn();
|
|
55
|
+
if (!element) {
|
|
56
|
+
showError({
|
|
57
|
+
title: `Expecting a Ember element from the story: "${name}" of "${kind}".`,
|
|
58
|
+
description: (0, ts_dedent_1.dedent) `
|
|
59
|
+
Did you forget to return the Ember element from the story?
|
|
60
|
+
Use "() => hbs('{{component}}')" or "() => { return {
|
|
61
|
+
template: hbs\`{{component}}\`
|
|
62
|
+
} }" when defining the story.
|
|
63
|
+
`,
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
showMain();
|
|
68
|
+
render(element, canvasElement);
|
|
69
|
+
}
|
|
70
|
+
exports.renderToCanvas = renderToCanvas;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WebRenderer } from '@storybook/types';
|
|
2
|
+
export type { RenderContext } from '@storybook/types';
|
|
3
|
+
export interface ShowErrorArgs {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OptionsArgs {
|
|
8
|
+
template: any;
|
|
9
|
+
context: any;
|
|
10
|
+
element: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `EmberRenderer` instead.
|
|
14
|
+
*/
|
|
15
|
+
export type EmberFramework = EmberRenderer;
|
|
16
|
+
export interface EmberRenderer extends WebRenderer {
|
|
17
|
+
component: any;
|
|
18
|
+
storyResult: OptionsArgs;
|
|
19
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { storiesOf, configure, forceReRender, raw } from './client/preview';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="webpack-env" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.raw = exports.forceReRender = exports.configure = exports.storiesOf = void 0;
|
|
5
|
+
var preview_1 = require("./client/preview");
|
|
6
|
+
Object.defineProperty(exports, "storiesOf", { enumerable: true, get: function () { return preview_1.storiesOf; } });
|
|
7
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return preview_1.configure; } });
|
|
8
|
+
Object.defineProperty(exports, "forceReRender", { enumerable: true, get: function () { return preview_1.forceReRender; } });
|
|
9
|
+
Object.defineProperty(exports, "raw", { enumerable: true, get: function () { return preview_1.raw; } });
|
|
10
|
+
// optimization: stop HMR propagation in webpack
|
|
11
|
+
if (typeof module !== 'undefined')
|
|
12
|
+
module?.hot?.decline();
|
package/dist/index.mjs
ADDED
package/dist/preset.d.ts
ADDED
package/dist/preset.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.core = exports.addons = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const getAbsolutePath = (input) => (0, path_1.dirname)(require.resolve((0, path_1.join)(input, 'package.json')));
|
|
6
|
+
exports.addons = [
|
|
7
|
+
require.resolve('./server/framework-preset-babel-ember'),
|
|
8
|
+
require.resolve('./server/framework-preset-ember-docs'),
|
|
9
|
+
];
|
|
10
|
+
const core = async (config, options) => {
|
|
11
|
+
const framework = await options.presets.apply('framework');
|
|
12
|
+
return {
|
|
13
|
+
...config,
|
|
14
|
+
builder: {
|
|
15
|
+
name: getAbsolutePath('@storybook/builder-webpack5'),
|
|
16
|
+
options: typeof framework === 'string' ? {} : framework.options.builder || {},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.core = core;
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { dirname, join } from 'path';
|
|
2
|
+
const getAbsolutePath = (input) => dirname(require.resolve(join(input, 'package.json')));
|
|
3
|
+
export const addons = [
|
|
4
|
+
require.resolve('./server/framework-preset-babel-ember'),
|
|
5
|
+
require.resolve('./server/framework-preset-ember-docs'),
|
|
6
|
+
];
|
|
7
|
+
export const core = async (config, options) => {
|
|
8
|
+
const framework = await options.presets.apply('framework');
|
|
9
|
+
return {
|
|
10
|
+
...config,
|
|
11
|
+
builder: {
|
|
12
|
+
name: getAbsolutePath('@storybook/builder-webpack5'),
|
|
13
|
+
options: typeof framework === 'string' ? {} : framework.options.builder || {},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TransformOptions } from '@babel/core';
|
|
2
|
+
import type { StorybookConfig, Options } from '@storybook/types';
|
|
3
|
+
export declare function babel(config: TransformOptions, options: Options): TransformOptions;
|
|
4
|
+
export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.previewAnnotations = exports.babel = void 0;
|
|
4
|
+
const ember_template_compiler_1 = require("ember-source/dist/ember-template-compiler");
|
|
5
|
+
const core_common_1 = require("@storybook/core-common");
|
|
6
|
+
let emberOptions;
|
|
7
|
+
function precompileWithPlugins(string, options) {
|
|
8
|
+
const precompileOptions = options;
|
|
9
|
+
if (emberOptions && emberOptions.polyfills) {
|
|
10
|
+
precompileOptions.plugins = { ast: emberOptions.polyfills };
|
|
11
|
+
}
|
|
12
|
+
return (0, ember_template_compiler_1.precompile)(string, precompileOptions);
|
|
13
|
+
}
|
|
14
|
+
function babel(config, options) {
|
|
15
|
+
if (options && options.presetsList) {
|
|
16
|
+
options.presetsList.forEach((e, index) => {
|
|
17
|
+
if (e.preset && e.preset.emberOptions) {
|
|
18
|
+
emberOptions = e.preset.emberOptions;
|
|
19
|
+
if (options.presetsList) {
|
|
20
|
+
// eslint-disable-next-line no-param-reassign
|
|
21
|
+
delete options.presetsList[index].preset.emberOptions;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const babelConfigPlugins = config.plugins || [];
|
|
27
|
+
const extraPlugins = [
|
|
28
|
+
[
|
|
29
|
+
require.resolve('babel-plugin-htmlbars-inline-precompile'),
|
|
30
|
+
{
|
|
31
|
+
precompile: precompileWithPlugins,
|
|
32
|
+
modules: {
|
|
33
|
+
'ember-cli-htmlbars': 'hbs',
|
|
34
|
+
'ember-cli-htmlbars-inline-precompile': 'default',
|
|
35
|
+
'htmlbars-inline-precompile': 'default',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
[require.resolve('babel-plugin-ember-modules-api-polyfill')],
|
|
40
|
+
];
|
|
41
|
+
return {
|
|
42
|
+
...config,
|
|
43
|
+
plugins: [...babelConfigPlugins, ...extraPlugins],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.babel = babel;
|
|
47
|
+
const previewAnnotations = (entry = []) => {
|
|
48
|
+
return [...entry, (0, core_common_1.findDistEsm)(__dirname, 'client/preview/config')];
|
|
49
|
+
};
|
|
50
|
+
exports.previewAnnotations = previewAnnotations;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.previewAnnotations = void 0;
|
|
4
|
+
const core_common_1 = require("@storybook/core-common");
|
|
5
|
+
const docs_tools_1 = require("@storybook/docs-tools");
|
|
6
|
+
const previewAnnotations = (entry = [], options) => {
|
|
7
|
+
if (!(0, docs_tools_1.hasDocsOrControls)(options))
|
|
8
|
+
return entry;
|
|
9
|
+
return [...entry, (0, core_common_1.findDistEsm)(__dirname, 'client/docs/config')];
|
|
10
|
+
};
|
|
11
|
+
exports.previewAnnotations = previewAnnotations;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StorybookConfig as StorybookConfigBase, TypescriptOptions as TypescriptOptionsReact } from '@storybook/core-webpack';
|
|
2
|
+
import type { StorybookConfigWebpack, BuilderOptions, TypescriptOptions as TypescriptOptionsBuilder } from '@storybook/builder-webpack5';
|
|
3
|
+
type FrameworkName = '@storybook/ember-webpack5';
|
|
4
|
+
type BuilderName = '@storybook/builder-webpack5';
|
|
5
|
+
export type FrameworkOptions = {
|
|
6
|
+
builder?: BuilderOptions;
|
|
7
|
+
};
|
|
8
|
+
type StorybookConfigFramework = {
|
|
9
|
+
framework: FrameworkName | {
|
|
10
|
+
name: FrameworkName;
|
|
11
|
+
options: FrameworkOptions;
|
|
12
|
+
};
|
|
13
|
+
core?: StorybookConfigBase['core'] & {
|
|
14
|
+
builder?: BuilderName | {
|
|
15
|
+
name: BuilderName;
|
|
16
|
+
options: BuilderOptions;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
typescript?: Partial<TypescriptOptionsBuilder & TypescriptOptionsReact> & StorybookConfigBase['typescript'];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The interface for Storybook configuration in `main.ts` files.
|
|
23
|
+
*/
|
|
24
|
+
export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
|
|
25
|
+
export {};
|
package/dist/types.js
ADDED
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@storybook/ember",
|
|
3
|
+
"version": "0.0.0-pr-23609-sha-f47ef339",
|
|
4
|
+
"description": "Storybook for Ember: Develop Ember Component in isolation with Hot Reloading.",
|
|
5
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/ember",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/storybookjs/storybook/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/storybookjs/storybook.git",
|
|
12
|
+
"directory": "code/frameworks/ember"
|
|
13
|
+
},
|
|
14
|
+
"funding": {
|
|
15
|
+
"type": "opencollective",
|
|
16
|
+
"url": "https://opencollective.com/storybook"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"module": "dist/index.mjs",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*",
|
|
24
|
+
"template/**/*",
|
|
25
|
+
"README.md",
|
|
26
|
+
"*.js",
|
|
27
|
+
"*.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"check": "../../../scripts/prepare/check.ts",
|
|
31
|
+
"prep": "../../../scripts/prepare/tsc.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@storybook/builder-webpack5": "0.0.0-pr-23609-sha-f47ef339",
|
|
35
|
+
"@storybook/core-common": "0.0.0-pr-23609-sha-f47ef339",
|
|
36
|
+
"@storybook/docs-tools": "0.0.0-pr-23609-sha-f47ef339",
|
|
37
|
+
"@storybook/global": "^5.0.0",
|
|
38
|
+
"@storybook/preview-api": "0.0.0-pr-23609-sha-f47ef339",
|
|
39
|
+
"@storybook/types": "0.0.0-pr-23609-sha-f47ef339",
|
|
40
|
+
"ts-dedent": "^2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"ember-source": "~3.28.1",
|
|
44
|
+
"typescript": "~4.9.3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@babel/core": "*",
|
|
48
|
+
"@types/ember__component": "4.0.8",
|
|
49
|
+
"babel-plugin-ember-modules-api-polyfill": "^2.12.0",
|
|
50
|
+
"babel-plugin-htmlbars-inline-precompile": "2 || 3",
|
|
51
|
+
"ember-source": "~3.28.1",
|
|
52
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
53
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=16.0.0"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"bundler": {},
|
|
62
|
+
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
|
|
63
|
+
}
|
package/preset.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/preset');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { enhanceArgTypes } from '@storybook/docs-tools';
|
|
2
|
+
import { extractArgTypes, extractComponentDescription } from './jsondoc';
|
|
3
|
+
|
|
4
|
+
export const parameters = {
|
|
5
|
+
docs: {
|
|
6
|
+
story: { iframeHeight: '80px' },
|
|
7
|
+
extractArgTypes,
|
|
8
|
+
extractComponentDescription,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const argTypesEnhancers = [enhanceArgTypes];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setJSONDoc } from './jsondoc';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
import { global } from '@storybook/global';
|
|
3
|
+
|
|
4
|
+
export const setJSONDoc = (jsondoc) => {
|
|
5
|
+
global.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
|
|
6
|
+
};
|
|
7
|
+
export const getJSONDoc = () => {
|
|
8
|
+
return global.__EMBER_GENERATED_DOC_JSON__;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const extractArgTypes = (componentName) => {
|
|
12
|
+
const json = getJSONDoc();
|
|
13
|
+
if (!(json && json.included)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
|
17
|
+
|
|
18
|
+
if (!componentDoc) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return componentDoc.attributes.arguments.reduce((acc, prop) => {
|
|
22
|
+
acc[prop.name] = {
|
|
23
|
+
name: prop.name,
|
|
24
|
+
defaultValue: prop.defaultValue,
|
|
25
|
+
description: prop.description,
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: { summary: prop.defaultValue },
|
|
28
|
+
type: {
|
|
29
|
+
summary: prop.type,
|
|
30
|
+
required: prop.tags.length ? prop.tags.some((tag) => tag.name === 'required') : false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const extractComponentDescription = (componentName) => {
|
|
39
|
+
const json = getJSONDoc();
|
|
40
|
+
if (!(json && json.included)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
|
44
|
+
|
|
45
|
+
if (!componentDoc) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return componentDoc.attributes.description;
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setJSONDoc } from './jsondoc';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
import { global } from '@storybook/global';
|
|
3
|
+
|
|
4
|
+
export const setJSONDoc = (jsondoc) => {
|
|
5
|
+
global.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
|
|
6
|
+
};
|
|
7
|
+
export const getJSONDoc = () => {
|
|
8
|
+
return global.__EMBER_GENERATED_DOC_JSON__;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const extractArgTypes = (componentName) => {
|
|
12
|
+
const json = getJSONDoc();
|
|
13
|
+
if (!(json && json.included)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
|
17
|
+
|
|
18
|
+
if (!componentDoc) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return componentDoc.attributes.arguments.reduce((acc, prop) => {
|
|
22
|
+
acc[prop.name] = {
|
|
23
|
+
name: prop.name,
|
|
24
|
+
defaultValue: prop.defaultValue,
|
|
25
|
+
description: prop.description,
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: { summary: prop.defaultValue },
|
|
28
|
+
type: {
|
|
29
|
+
summary: prop.type,
|
|
30
|
+
required: prop.tags.length ? prop.tags.some((tag) => tag.name === 'required') : false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const extractComponentDescription = (componentName) => {
|
|
39
|
+
const json = getJSONDoc();
|
|
40
|
+
if (!(json && json.included)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
|
44
|
+
|
|
45
|
+
if (!componentDoc) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return componentDoc.attributes.description;
|
|
50
|
+
};
|
package/src/typings.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { linkTo } from '@storybook/addon-links';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/ember/writing-stories/introduction
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Example/Button',
|
|
8
|
+
render: (args) => ({
|
|
9
|
+
template: hbs`<button {{action onClick}}>{{label}}</button>`,
|
|
10
|
+
context: args,
|
|
11
|
+
}),
|
|
12
|
+
argTypes: {
|
|
13
|
+
label: { control: 'text' },
|
|
14
|
+
},
|
|
15
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// More on writing stories with args: https://storybook.js.org/docs/ember/writing-stories/args
|
|
20
|
+
export const Text = {
|
|
21
|
+
args: {
|
|
22
|
+
label: 'Button',
|
|
23
|
+
onClick: action('onClick'),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Emoji = {
|
|
28
|
+
args: {
|
|
29
|
+
label: '😀 😎 👍 💯',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const TextWithAction = {
|
|
34
|
+
render: () => ({
|
|
35
|
+
template: hbs`
|
|
36
|
+
<button {{action onClick}}>
|
|
37
|
+
Trigger Action
|
|
38
|
+
</button>
|
|
39
|
+
`,
|
|
40
|
+
context: {
|
|
41
|
+
onClick: () => action('This was clicked')(),
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
name: 'With an action',
|
|
45
|
+
parameters: {
|
|
46
|
+
notes: 'My notes on a button with emojis',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const ButtonWithLinkToAnotherStory = {
|
|
51
|
+
render: () => ({
|
|
52
|
+
template: hbs`
|
|
53
|
+
<button {{action onClick}}>
|
|
54
|
+
Go to Welcome Story
|
|
55
|
+
</button>
|
|
56
|
+
`,
|
|
57
|
+
context: {
|
|
58
|
+
onClick: linkTo('example-introduction--page'),
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
name: 'button with link to another story',
|
|
62
|
+
};
|