@storybook/angular 7.4.0-alpha.0 → 7.4.0-alpha.2
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/package.json +18 -17
- package/src/server/angular-cli-webpack.d.ts +0 -7
- package/src/server/angular-cli-webpack.js +0 -127
- package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -54
- package/src/typings.d.ts +0 -21
- package/template/components/button.component.ts +0 -54
- package/template/components/button.css +0 -30
- package/template/components/form.component.ts +0 -37
- package/template/components/html.component.ts +0 -22
- package/template/components/pre.component.ts +0 -29
- package/template/stories/angular-mdx.stories.mdx +0 -25
- package/template/stories/argTypes/doc-button/doc-button.component.html +0 -7
- package/template/stories/argTypes/doc-button/doc-button.component.scss +0 -3
- package/template/stories/argTypes/doc-button/doc-button.component.ts +0 -232
- package/template/stories/argTypes/doc-button/doc-button.stories.ts +0 -24
- package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +0 -24
- package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +0 -14
- package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +0 -27
- package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +0 -14
- package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +0 -18
- package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +0 -14
- package/template/stories/basics/README.stories.mdx +0 -7
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +0 -27
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +0 -57
- package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +0 -19
- package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +0 -19
- package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +0 -37
- package/template/stories/basics/component-with-enums/enums.component.html +0 -8
- package/template/stories/basics/component-with-enums/enums.component.stories.ts +0 -24
- package/template/stories/basics/component-with-enums/enums.component.ts +0 -53
- package/template/stories/basics/component-with-inheritance/base-button.component.ts +0 -10
- package/template/stories/basics/component-with-inheritance/base-button.stories.ts +0 -12
- package/template/stories/basics/component-with-inheritance/icon-button.component.ts +0 -11
- package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +0 -13
- package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +0 -58
- package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +0 -29
- package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +0 -40
- package/template/stories/basics/component-with-on-push/on-push-box.component.ts +0 -21
- package/template/stories/basics/component-with-on-push/on-push.stories.ts +0 -21
- package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +0 -31
- package/template/stories/basics/component-with-pipe/custom.pipe.ts +0 -10
- package/template/stories/basics/component-with-pipe/with-pipe.component.ts +0 -10
- package/template/stories/basics/component-with-provider/di.component.html +0 -7
- package/template/stories/basics/component-with-provider/di.component.stories.ts +0 -26
- package/template/stories/basics/component-with-provider/di.component.ts +0 -28
- package/template/stories/basics/component-with-style/styled.component.css +0 -3
- package/template/stories/basics/component-with-style/styled.component.html +0 -5
- package/template/stories/basics/component-with-style/styled.component.scss +0 -5
- package/template/stories/basics/component-with-style/styled.component.stories.ts +0 -10
- package/template/stories/basics/component-with-style/styled.component.ts +0 -8
- package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +0 -73
- package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +0 -71
- package/template/stories/basics/component-without-selector/without-selector.component.ts +0 -30
- package/template/stories/basics/component-without-selector/without-selector.stories.ts +0 -30
- package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +0 -3
- package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +0 -29
- package/template/stories/basics/ng-module/angular-src/chip.component.ts +0 -60
- package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +0 -49
- package/template/stories/basics/ng-module/angular-src/chips.module.ts +0 -31
- package/template/stories/basics/ng-module/import-module-chip.stories.ts +0 -23
- package/template/stories/basics/ng-module/import-module-for-root.stories.ts +0 -50
- package/template/stories/basics/ng-module/import-module.stories.ts +0 -35
- package/template/stories/button.component.ts +0 -26
- package/template/stories/core/README.stories.mdx +0 -7
- package/template/stories/core/applicationConfig/with-browser-animations.stories.ts +0 -40
- package/template/stories/core/applicationConfig/with-noop-browser-animations.stories.ts +0 -35
- package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +0 -20
- package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +0 -99
- package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +0 -18
- package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +0 -20
- package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +0 -10
- package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +0 -14
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +0 -13
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +0 -7
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +0 -39
- package/template/stories/core/moduleMetadata/angular-src/service.component.ts +0 -24
- package/template/stories/core/moduleMetadata/angular-src/token.component.ts +0 -31
- package/template/stories/core/moduleMetadata/in-export-default.stories.ts +0 -38
- package/template/stories/core/moduleMetadata/in-stories.stories.ts +0 -46
- package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +0 -35
- package/template/stories/core/parameters/bootstrap-options.stories.ts +0 -18
- package/template/stories/core/styles/story-styles.stories.ts +0 -50
- package/template/stories/others/app-initializer-use-factory/app-initializer-use-factory.stories.ts +0 -34
- package/template/stories/others/issues/12009-unknown-component.stories.ts +0 -14
- package/template/stories/others/ngx-translate/README.stories.mdx +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "7.4.0-alpha.
|
|
3
|
+
"version": "7.4.0-alpha.2",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -25,31 +25,32 @@
|
|
|
25
25
|
"types": "dist/index.d.ts",
|
|
26
26
|
"files": [
|
|
27
27
|
"dist/**/*",
|
|
28
|
-
"template/**/*",
|
|
28
|
+
"template/cli/**/*",
|
|
29
29
|
"README.md",
|
|
30
30
|
"*.js",
|
|
31
31
|
"*.mjs",
|
|
32
|
-
"*.d.ts"
|
|
32
|
+
"*.d.ts",
|
|
33
|
+
"!src/**/*"
|
|
33
34
|
],
|
|
34
35
|
"scripts": {
|
|
35
36
|
"check": "../../../scripts/node_modules/.bin/tsc",
|
|
36
37
|
"prep": "../../../scripts/prepare/tsc.ts"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@storybook/builder-webpack5": "7.4.0-alpha.
|
|
40
|
-
"@storybook/cli": "7.4.0-alpha.
|
|
41
|
-
"@storybook/client-logger": "7.4.0-alpha.
|
|
42
|
-
"@storybook/core-common": "7.4.0-alpha.
|
|
43
|
-
"@storybook/core-events": "7.4.0-alpha.
|
|
44
|
-
"@storybook/core-server": "7.4.0-alpha.
|
|
45
|
-
"@storybook/core-webpack": "7.4.0-alpha.
|
|
46
|
-
"@storybook/docs-tools": "7.4.0-alpha.
|
|
40
|
+
"@storybook/builder-webpack5": "7.4.0-alpha.2",
|
|
41
|
+
"@storybook/cli": "7.4.0-alpha.2",
|
|
42
|
+
"@storybook/client-logger": "7.4.0-alpha.2",
|
|
43
|
+
"@storybook/core-common": "7.4.0-alpha.2",
|
|
44
|
+
"@storybook/core-events": "7.4.0-alpha.2",
|
|
45
|
+
"@storybook/core-server": "7.4.0-alpha.2",
|
|
46
|
+
"@storybook/core-webpack": "7.4.0-alpha.2",
|
|
47
|
+
"@storybook/docs-tools": "7.4.0-alpha.2",
|
|
47
48
|
"@storybook/global": "^5.0.0",
|
|
48
|
-
"@storybook/manager-api": "7.4.0-alpha.
|
|
49
|
-
"@storybook/node-logger": "7.4.0-alpha.
|
|
50
|
-
"@storybook/preview-api": "7.4.0-alpha.
|
|
51
|
-
"@storybook/telemetry": "7.4.0-alpha.
|
|
52
|
-
"@storybook/types": "7.4.0-alpha.
|
|
49
|
+
"@storybook/manager-api": "7.4.0-alpha.2",
|
|
50
|
+
"@storybook/node-logger": "7.4.0-alpha.2",
|
|
51
|
+
"@storybook/preview-api": "7.4.0-alpha.2",
|
|
52
|
+
"@storybook/telemetry": "7.4.0-alpha.2",
|
|
53
|
+
"@storybook/types": "7.4.0-alpha.2",
|
|
53
54
|
"@types/node": "^16.0.0",
|
|
54
55
|
"@types/react": "^16.14.34",
|
|
55
56
|
"@types/react-dom": "^16.9.14",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"find-up": "^5.0.0",
|
|
59
60
|
"read-pkg-up": "^7.0.1",
|
|
60
61
|
"semver": "^7.3.7",
|
|
61
|
-
"telejson": "^7.0
|
|
62
|
+
"telejson": "^7.2.0",
|
|
62
63
|
"ts-dedent": "^2.0.0",
|
|
63
64
|
"tsconfig-paths-webpack-plugin": "^4.0.1",
|
|
64
65
|
"util-deprecate": "^1.0.2",
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/* eslint-disable global-require */
|
|
2
|
-
// Private angular devkit stuff
|
|
3
|
-
const {
|
|
4
|
-
generateI18nBrowserWebpackConfigFromContext,
|
|
5
|
-
} = require('@angular-devkit/build-angular/src/utils/webpack-browser-config');
|
|
6
|
-
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
7
|
-
const { filterOutStylingRules } = require('./utils/filter-out-styling-rules');
|
|
8
|
-
const {
|
|
9
|
-
default: StorybookNormalizeAngularEntryPlugin,
|
|
10
|
-
} = require('./plugins/storybook-normalize-angular-entry-plugin');
|
|
11
|
-
|
|
12
|
-
const getAngularWebpackUtils = () => {
|
|
13
|
-
try {
|
|
14
|
-
// Angular < 16.1.0
|
|
15
|
-
const {
|
|
16
|
-
getCommonConfig,
|
|
17
|
-
getStylesConfig,
|
|
18
|
-
getDevServerConfig,
|
|
19
|
-
getTypeScriptConfig,
|
|
20
|
-
} = require('@angular-devkit/build-angular/src/webpack/configs');
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
getCommonConfig,
|
|
24
|
-
getStylesConfig,
|
|
25
|
-
getDevServerConfig,
|
|
26
|
-
getTypeScriptConfig,
|
|
27
|
-
};
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// Angular > 16.1.0
|
|
30
|
-
const {
|
|
31
|
-
getCommonConfig,
|
|
32
|
-
getStylesConfig,
|
|
33
|
-
getDevServerConfig,
|
|
34
|
-
getTypeScriptConfig,
|
|
35
|
-
} = require('@angular-devkit/build-angular/src/tools/webpack/configs');
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
getCommonConfig,
|
|
39
|
-
getStylesConfig,
|
|
40
|
-
getDevServerConfig,
|
|
41
|
-
getTypeScriptConfig,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Extract webpack config from angular-cli 13.x.x
|
|
48
|
-
* ⚠️ This file is in JavaScript to not use TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
|
|
49
|
-
* FIXME: Try another way with TypeScript on future storybook version (7 maybe 🤞)
|
|
50
|
-
*
|
|
51
|
-
* @param {*} baseConfig Previous webpack config from storybook
|
|
52
|
-
* @param {*} options { builderOptions, builderContext }
|
|
53
|
-
*/
|
|
54
|
-
exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }) => {
|
|
55
|
-
/**
|
|
56
|
-
* Get angular-cli Webpack config
|
|
57
|
-
*/
|
|
58
|
-
const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig } =
|
|
59
|
-
getAngularWebpackUtils();
|
|
60
|
-
const { config: cliConfig } = await generateI18nBrowserWebpackConfigFromContext(
|
|
61
|
-
{
|
|
62
|
-
// Default options
|
|
63
|
-
index: 'noop-index',
|
|
64
|
-
main: 'noop-main',
|
|
65
|
-
outputPath: 'noop-out',
|
|
66
|
-
|
|
67
|
-
// Options provided by user
|
|
68
|
-
...builderOptions,
|
|
69
|
-
|
|
70
|
-
// Fixed options
|
|
71
|
-
optimization: false,
|
|
72
|
-
namedChunks: false,
|
|
73
|
-
progress: false,
|
|
74
|
-
buildOptimizer: false,
|
|
75
|
-
aot: false,
|
|
76
|
-
},
|
|
77
|
-
builderContext,
|
|
78
|
-
(wco) => [
|
|
79
|
-
getCommonConfig(wco),
|
|
80
|
-
getStylesConfig(wco),
|
|
81
|
-
getTypeScriptConfig ? getTypeScriptConfig(wco) : getDevServerConfig(wco),
|
|
82
|
-
]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Merge baseConfig Webpack with angular-cli Webpack
|
|
87
|
-
*/
|
|
88
|
-
const entry = [
|
|
89
|
-
...baseConfig.entry,
|
|
90
|
-
...(cliConfig.entry.styles ?? []),
|
|
91
|
-
...(cliConfig.entry.polyfills ?? []),
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
// Don't use storybooks styling rules because we have to use rules created by @angular-devkit/build-angular
|
|
95
|
-
// because @angular-devkit/build-angular created rules have include/exclude for global style files.
|
|
96
|
-
const rulesExcludingStyles = filterOutStylingRules(baseConfig);
|
|
97
|
-
const module = {
|
|
98
|
-
...baseConfig.module,
|
|
99
|
-
rules: [...cliConfig.module.rules, ...rulesExcludingStyles],
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const plugins = [
|
|
103
|
-
...(cliConfig.plugins ?? []),
|
|
104
|
-
...baseConfig.plugins,
|
|
105
|
-
new StorybookNormalizeAngularEntryPlugin(),
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
const resolve = {
|
|
109
|
-
...baseConfig.resolve,
|
|
110
|
-
modules: Array.from(new Set([...baseConfig.resolve.modules, ...cliConfig.resolve.modules])),
|
|
111
|
-
plugins: [
|
|
112
|
-
new TsconfigPathsPlugin({
|
|
113
|
-
configFile: builderOptions.tsConfig,
|
|
114
|
-
mainFields: ['browser', 'module', 'main'],
|
|
115
|
-
}),
|
|
116
|
-
],
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
...baseConfig,
|
|
121
|
-
entry,
|
|
122
|
-
module,
|
|
123
|
-
plugins,
|
|
124
|
-
resolve,
|
|
125
|
-
resolveLoader: cliConfig.resolveLoader,
|
|
126
|
-
};
|
|
127
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const PLUGIN_NAME = 'storybook-normalize-angular-entry-plugin';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Angular's webpack plugin @angular-devkit/build-angular/src/webpack/plugins/styles-webpack-plugin.js
|
|
5
|
-
* transforms the original webpackOptions.entry point array into a structure like this:
|
|
6
|
-
*
|
|
7
|
-
* ```js
|
|
8
|
-
* {
|
|
9
|
-
* main: {
|
|
10
|
-
* import: [...]
|
|
11
|
-
* },
|
|
12
|
-
*
|
|
13
|
-
* styles: {
|
|
14
|
-
* import: [...]
|
|
15
|
-
* },
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Storybook throws an __webpack_require__.nmd is not a function error, when another runtime bundle (styles~runtime.iframe.bundle.js) is loaded.
|
|
20
|
-
* To prevent this error, we have to normalize the entry point to only generate one runtime bundle (main~runtime.iframe.bundle.js).
|
|
21
|
-
*/
|
|
22
|
-
export default class StorybookNormalizeAngularEntryPlugin {
|
|
23
|
-
constructor(options) {
|
|
24
|
-
this.options = options;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
apply(compiler) {
|
|
28
|
-
compiler.hooks.environment.tap(PLUGIN_NAME, () => {
|
|
29
|
-
const webpackOptions = compiler.options;
|
|
30
|
-
const entry =
|
|
31
|
-
typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
|
|
32
|
-
|
|
33
|
-
webpackOptions.entry = async () => {
|
|
34
|
-
const entryResult = await entry;
|
|
35
|
-
|
|
36
|
-
if (entryResult.main && entryResult.styles) {
|
|
37
|
-
return {
|
|
38
|
-
main: {
|
|
39
|
-
import: Array.from(
|
|
40
|
-
new Set([...entryResult.main.import, ...entryResult.styles.import])
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return entry;
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
51
|
-
this.compilation = compilation;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/typings.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
|
|
2
|
-
|
|
3
|
-
// will be provided by the webpack define plugin
|
|
4
|
-
declare var NODE_ENV: string | undefined;
|
|
5
|
-
|
|
6
|
-
declare var __STORYBOOK_ADDONS_CHANNEL__: any;
|
|
7
|
-
declare var __STORYBOOK_ADDONS_PREVIEW: any;
|
|
8
|
-
declare var __STORYBOOK_COMPODOC_JSON__: any;
|
|
9
|
-
declare var __STORYBOOK_CLIENT_API__: any;
|
|
10
|
-
declare var __STORYBOOK_PREVIEW__: any;
|
|
11
|
-
declare var __STORYBOOK_STORY_STORE__: any;
|
|
12
|
-
declare var CHANNEL_OPTIONS: any;
|
|
13
|
-
declare var DOCS_OPTIONS: any;
|
|
14
|
-
|
|
15
|
-
declare var FEATURES: import('@storybook/types').StorybookConfig['features'];
|
|
16
|
-
|
|
17
|
-
declare var IS_STORYBOOK: any;
|
|
18
|
-
declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined;
|
|
19
|
-
declare var STORIES: any;
|
|
20
|
-
declare var STORYBOOK_ENV: 'angular';
|
|
21
|
-
declare var STORYBOOK_HOOKS_CONTEXT: any;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
// Needs to be a different name to the CLI template button
|
|
5
|
-
selector: 'storybook-framework-button',
|
|
6
|
-
template: ` <button
|
|
7
|
-
type="button"
|
|
8
|
-
(click)="onClick.emit($event)"
|
|
9
|
-
[ngClass]="classes"
|
|
10
|
-
[ngStyle]="{ 'background-color': backgroundColor }"
|
|
11
|
-
>
|
|
12
|
-
{{ label }}
|
|
13
|
-
</button>`,
|
|
14
|
-
styleUrls: ['./button.css'],
|
|
15
|
-
})
|
|
16
|
-
export default class FrameworkButtonComponent {
|
|
17
|
-
/**
|
|
18
|
-
* Is this the principal call to action on the page?
|
|
19
|
-
*/
|
|
20
|
-
@Input()
|
|
21
|
-
primary = false;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* What background color to use
|
|
25
|
-
*/
|
|
26
|
-
@Input()
|
|
27
|
-
backgroundColor?: string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* How large should the button be?
|
|
31
|
-
*/
|
|
32
|
-
@Input()
|
|
33
|
-
size: 'small' | 'medium' | 'large' = 'medium';
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Button contents
|
|
37
|
-
*
|
|
38
|
-
* @required
|
|
39
|
-
*/
|
|
40
|
-
@Input()
|
|
41
|
-
label = 'Button';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Optional click handler
|
|
45
|
-
*/
|
|
46
|
-
@Output()
|
|
47
|
-
onClick = new EventEmitter<Event>();
|
|
48
|
-
|
|
49
|
-
public get classes(): string[] {
|
|
50
|
-
const mode = this.primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
51
|
-
|
|
52
|
-
return ['storybook-button', `storybook-button--${this.size}`, mode];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.storybook-button {
|
|
2
|
-
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
3
|
-
font-weight: 700;
|
|
4
|
-
border: 0;
|
|
5
|
-
border-radius: 3em;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
display: inline-block;
|
|
8
|
-
line-height: 1;
|
|
9
|
-
}
|
|
10
|
-
.storybook-button--primary {
|
|
11
|
-
color: white;
|
|
12
|
-
background-color: #1ea7fd;
|
|
13
|
-
}
|
|
14
|
-
.storybook-button--secondary {
|
|
15
|
-
color: #333;
|
|
16
|
-
background-color: transparent;
|
|
17
|
-
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
|
|
18
|
-
}
|
|
19
|
-
.storybook-button--small {
|
|
20
|
-
font-size: 12px;
|
|
21
|
-
padding: 10px 16px;
|
|
22
|
-
}
|
|
23
|
-
.storybook-button--medium {
|
|
24
|
-
font-size: 14px;
|
|
25
|
-
padding: 11px 20px;
|
|
26
|
-
}
|
|
27
|
-
.storybook-button--large {
|
|
28
|
-
font-size: 16px;
|
|
29
|
-
padding: 12px 24px;
|
|
30
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Component, Output, EventEmitter } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'storybook-form',
|
|
5
|
-
template: `
|
|
6
|
-
<form id="interaction-test-form" (submit)="handleSubmit($event)">
|
|
7
|
-
<label>
|
|
8
|
-
Enter Value
|
|
9
|
-
<input type="text" data-testid="value" [(ngModel)]="value" required />
|
|
10
|
-
</label>
|
|
11
|
-
<button type="submit">Submit</button>
|
|
12
|
-
<p *ngIf="complete">Completed!!</p>
|
|
13
|
-
</form>
|
|
14
|
-
`,
|
|
15
|
-
})
|
|
16
|
-
export default class FormComponent {
|
|
17
|
-
/**
|
|
18
|
-
* Optional success handler
|
|
19
|
-
*/
|
|
20
|
-
@Output()
|
|
21
|
-
onSuccess = new EventEmitter<string>();
|
|
22
|
-
|
|
23
|
-
value = '';
|
|
24
|
-
|
|
25
|
-
complete = false;
|
|
26
|
-
|
|
27
|
-
handleSubmit(event: SubmitEvent) {
|
|
28
|
-
event.preventDefault();
|
|
29
|
-
this.onSuccess.emit(this.value);
|
|
30
|
-
setTimeout(() => {
|
|
31
|
-
this.complete = true;
|
|
32
|
-
}, 500);
|
|
33
|
-
setTimeout(() => {
|
|
34
|
-
this.complete = false;
|
|
35
|
-
}, 1500);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
import { DomSanitizer } from '@angular/platform-browser';
|
|
3
|
-
|
|
4
|
-
@Component({
|
|
5
|
-
selector: 'storybook-html',
|
|
6
|
-
template: `<div [innerHTML]="safeContent"></div>`,
|
|
7
|
-
})
|
|
8
|
-
export default class HtmlComponent {
|
|
9
|
-
/**
|
|
10
|
-
* The HTML to render
|
|
11
|
-
*
|
|
12
|
-
* @required
|
|
13
|
-
*/
|
|
14
|
-
@Input()
|
|
15
|
-
content = '';
|
|
16
|
-
|
|
17
|
-
constructor(private sanitizer: DomSanitizer) {}
|
|
18
|
-
|
|
19
|
-
get safeContent() {
|
|
20
|
-
return this.sanitizer.bypassSecurityTrustHtml(this.content);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'storybook-pre',
|
|
5
|
-
template: `<pre data-testid="pre" [ngStyle]="style">{{ finalText }}</pre>`,
|
|
6
|
-
})
|
|
7
|
-
export default class PreComponent {
|
|
8
|
-
/**
|
|
9
|
-
* Styles to apply to the component
|
|
10
|
-
*/
|
|
11
|
-
@Input()
|
|
12
|
-
style?: Object;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An object to render
|
|
16
|
-
*/
|
|
17
|
-
@Input()
|
|
18
|
-
object?: Object;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The code to render
|
|
22
|
-
*/
|
|
23
|
-
@Input()
|
|
24
|
-
text?: string;
|
|
25
|
-
|
|
26
|
-
get finalText() {
|
|
27
|
-
return this.object ? JSON.stringify(this.object, null, 2) : this.text;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { global as globalThis } from '@storybook/global';
|
|
2
|
-
import { moduleMetadata } from '@storybook/angular';
|
|
3
|
-
import { Meta, Story, Canvas } from '@storybook/addon-docs';
|
|
4
|
-
|
|
5
|
-
export const Button = globalThis.Components.Button;
|
|
6
|
-
|
|
7
|
-
<Meta
|
|
8
|
-
title="angular/angular-mdx"
|
|
9
|
-
component={Button}
|
|
10
|
-
decorators={[moduleMetadata({ declarations: [Button] })]}
|
|
11
|
-
/>
|
|
12
|
-
|
|
13
|
-
# Angular-specific MDX Stories
|
|
14
|
-
|
|
15
|
-
<Canvas>
|
|
16
|
-
<Story name="Angular Story">
|
|
17
|
-
{{
|
|
18
|
-
template: `<storybook-framework-button [label]="text" (onClick)="onClick($event)"></storybook-framework-button>`,
|
|
19
|
-
props: {
|
|
20
|
-
text: 'hello button',
|
|
21
|
-
onClick: () => {},
|
|
22
|
-
},
|
|
23
|
-
}}
|
|
24
|
-
</Story>
|
|
25
|
-
</Canvas>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<button [disabled]="isDisabled" [ngClass]="classes" #buttonRef>
|
|
2
|
-
<img
|
|
3
|
-
width="100"
|
|
4
|
-
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCAyNTAgMjUwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNTAgMjUwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDojREQwMDMxO30NCgkuc3Qxe2ZpbGw6I0MzMDAyRjt9DQoJLnN0MntmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxnPg0KCTxwb2x5Z29uIGNsYXNzPSJzdDAiIHBvaW50cz0iMTI1LDMwIDEyNSwzMCAxMjUsMzAgMzEuOSw2My4yIDQ2LjEsMTg2LjMgMTI1LDIzMCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAJIi8+DQoJPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSIxMjUsMzAgMTI1LDUyLjIgMTI1LDUyLjEgMTI1LDE1My40IDEyNSwxNTMuNCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAxMjUsMzAgCSIvPg0KCTxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik0xMjUsNTIuMUw2Ni44LDE4Mi42aDBoMjEuN2gwbDExLjctMjkuMmg0OS40bDExLjcsMjkuMmgwaDIxLjdoMEwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMQ0KCQlMMTI1LDUyLjF6IE0xNDIsMTM1LjRIMTA4bDE3LTQwLjlMMTQyLDEzNS40eiIvPg0KPC9nPg0KPC9zdmc+DQo="
|
|
5
|
-
/>
|
|
6
|
-
{{ label }}
|
|
7
|
-
</button>
|