Skip to content

Commit ba949e9

Browse files
committed
Install storybook package and make stories.ts file for button and button2
1 parent 4b437f1 commit ba949e9

File tree

9 files changed

+4331
-310
lines changed

9 files changed

+4331
-310
lines changed

.storybook/addons.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';
3+
import '@storybook/addon-notes/register';

.storybook/config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { configure } from '@storybook/angular';
2+
3+
// automatically import all files ending in *.stories.ts
4+
// const req = require.context('../src/stories', true, /.stories.ts$/);
5+
const req = require.context('../src/app/stories', true, /.stories.ts$/);
6+
function loadStories() {
7+
req.keys().forEach(filename => req(filename));
8+
}
9+
10+
configure(loadStories, module);

Note.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ https://stackoverflow.com/questions/46087105/angular-aot-compilation-ng-vs-ngc
55
https://stackoverflow.com/questions/44642696/whats-the-relationship-and-difference-between-ng-build-and-ngc
66
http://www.gistia.com/angular-performance-two-strategies/
77
https://github.com/angular/angular-cli/wiki/stories-css-preprocessors
8+
https://www.learnstorybook.com/
9+
https://github.com/storybooks/storybook/issues/125
10+
https://github.com/storybooks/storybook/issues/4481
11+
D:\Temp\Test\car-show>npx -p @storybook/cli sb init
812

913

1014
How to create a component:

package-lock.json

Lines changed: 4201 additions & 308 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"test": "ng test",
1010
"lint": "ng lint",
1111
"e2e": "ng e2e",
12+
"storybook1": "start-storybook -p 9001 -c .storybook",
13+
"storybook": "start-storybook -p 6006",
14+
"storybook2": "start-storybook -s ./public,./static -p 6006",
15+
"build-storybook": "build-storybook",
1216
"build-components": "ngc -p tsconfig-release.json",
1317
"build-assets": "gulp build-assets",
1418
"build-exports": "gulp build-exports",
@@ -30,9 +34,16 @@
3034
"@angular/platform-browser": "~7.1.0",
3135
"@angular/platform-browser-dynamic": "~7.1.0",
3236
"@angular/router": "~7.1.0",
37+
"@babel/core": "^7.2.0",
38+
"@storybook/addon-actions": "^4.0.12",
39+
"@storybook/addon-links": "^4.0.12",
40+
"@storybook/addon-notes": "^4.0.12",
41+
"@storybook/addons": "^4.0.12",
42+
"@storybook/angular": "^4.0.12",
3343
"@types/jasmine": "~2.8.8",
3444
"@types/jasminewd2": "~2.0.3",
35-
"@types/node": "~8.9.4",
45+
"@types/node": "^8.9.5",
46+
"babel-loader": "^8.0.4",
3647
"chart.js": "2.7.3",
3748
"codelyzer": "~4.5.0",
3849
"core-js": "^2.5.4",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { storiesOf } from '@storybook/angular';
2+
import { withNotes } from '@storybook/addon-notes';
3+
import { action } from '@storybook/addon-actions';
4+
import { linkTo } from '@storybook/addon-links';
5+
6+
import { Welcome, Button } from '@storybook/angular/demo';
7+
8+
storiesOf('Welcome', module).add('to Storybook', () => ({
9+
component: Welcome,
10+
props: {},
11+
}));
12+
13+
// storiesOf('Button', module)
14+
// .add('with text', () => ({
15+
// component: Button,
16+
// props: {
17+
// text: 'Hello Button',
18+
// },
19+
// }))
20+
// .add(
21+
// 'with some emoji',
22+
// withNotes({ text: 'My notes on a button with emojis' })(() => ({
23+
// component: Button,
24+
// props: {
25+
// text: '😀 😎 👍 💯',
26+
// },
27+
// }))
28+
// )
29+
// .add(
30+
// 'with some emoji and action',
31+
// withNotes({ text: 'My notes on a button with emojis' })(() => ({
32+
// component: Button,
33+
// props: {
34+
// text: '😀 😎 👍 💯',
35+
// onClick: action('This was clicked OMG'),
36+
// },
37+
// }))
38+
// );
39+
//
40+
// storiesOf('Another Button', module).add('button with link to another story', () => ({
41+
// component: Button,
42+
// props: {
43+
// text: 'Go to Welcome Story',
44+
// onClick: linkTo('Welcome'),
45+
// },
46+
// }));

src/app/stories/button.stories.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { storiesOf, moduleMetadata } from '@storybook/angular';
2+
import { withNotes } from '@storybook/addon-notes';
3+
import { action } from '@storybook/addon-actions';
4+
import { linkTo } from '@storybook/addon-links';
5+
6+
import {Button} from '../components/button2/button';
7+
8+
storiesOf('Button', module)
9+
.add('Button', () => {
10+
return {
11+
template: `
12+
<button class="ea-button">Annie Test</button>
13+
`,
14+
props: {
15+
// task,
16+
// onPinTask: actions.onPinTask,
17+
// onArchiveTask: actions.onArchiveTask,
18+
},
19+
};
20+
});

src/app/stories/button2.stories.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { storiesOf, moduleMetadata } from '@storybook/angular';
2+
import { withNotes } from '@storybook/addon-notes';
3+
import { action } from '@storybook/addon-actions';
4+
import { linkTo } from '@storybook/addon-links';
5+
6+
import {Button} from '../components/button2/button';
7+
// import '../../assets/components/themes/nova-light/theme.css';
8+
// import '../src/assets/components/themes/nova-light/theme.css';
9+
// import '../src/assets/components/themes/nova-light/fonts/open-sans-v15-latin-regular.woff2';
10+
11+
storiesOf('Button2', module)
12+
.addDecorator(
13+
moduleMetadata({
14+
declarations: [Button],
15+
}),
16+
)
17+
.add('Button2', () => {
18+
return {
19+
template: `
20+
<link id="theme-css" rel="stylesheet" type="text/css" href="assets/components/themes/nova-light/theme.css">
21+
<p-button label="Click"></p-button>
22+
<p-button icon="pi pi-check" label="Click"></p-button>
23+
<p-button icon="pi pi-check" iconPos="right" label="Click"></p-button>
24+
<p-button icon="pi pi-check"></p-button>
25+
<p-button icon="pi pi-check" [disabled]="true" label="Disabled"></p-button>
26+
`,
27+
props: {
28+
// task,
29+
// onPinTask: actions.onPinTask,
30+
// onArchiveTask: actions.onArchiveTask,
31+
},
32+
};
33+
});

src/tsconfig.app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"exclude": [
88
"src/test.ts",
9-
"**/*.spec.ts"
9+
"**/*.spec.ts",
10+
"**/*.stories.ts"
1011
]
1112
}

0 commit comments

Comments
 (0)