-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: web-components stories homogenization
- Loading branch information
Showing
5 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lib/cli/src/generators/WEB-COMPONENTS/template/.storybook/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
stories: ['../stories/**/*.stories.js'], | ||
addons: ['@storybook/addon-actions', '@storybook/addon-links'], | ||
}; |
49 changes: 49 additions & 0 deletions
49
lib/cli/src/generators/WEB-COMPONENTS/template/stories/0-Welcome.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { html } from 'lit-html'; | ||
|
||
export default { | ||
title: 'Welcome', | ||
}; | ||
|
||
export const ToStorybook = () => html`<main> | ||
<h1>Welcome to storybook</h1> | ||
<p>This is a UI component dev environment for your app.</p> | ||
<p> | ||
We've added some basic stories inside the | ||
<span class="inline-code">src/stories</span> directory. <br /> | ||
A story is a single state of one or more UI components. You can have as many stories as you | ||
want. <br /> | ||
(Basically a story is like a visual test case.) | ||
</p> | ||
<p> | ||
See these sample | ||
<a (click)="showApp.emit($event)" role="button" tabindex="0">stories</a> for a component called | ||
<span class="inline-code">Button</span> . | ||
</p> | ||
<p> | ||
Just like that, you can add your own components as stories. <br /> | ||
You can also edit those components and see changes right away. <br /> | ||
(Try editing the <span class="inline-code">Button</span> stories located at | ||
<span class="inline-code">src/stories/index.js</span>.) | ||
</p> | ||
<p> | ||
Usually we create stories with smaller UI components in the app.<br /> | ||
Have a look at the | ||
<a | ||
href="https://storybook.js.org/basics/writing-stories" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Writing Stories | ||
</a> | ||
section in our documentation. | ||
</p> | ||
<p class="note"> | ||
<b>NOTE:</b> <br /> | ||
Have a look at the <span class="inline-code">.storybook/webpack.config.js</span> to add webpack | ||
loaders and plugins you are using in this project. | ||
</p> | ||
</main>`; | ||
|
||
ToStorybook.story = { | ||
name: 'to Storybook', | ||
}; |
42 changes: 42 additions & 0 deletions
42
lib/cli/src/generators/WEB-COMPONENTS/template/stories/1-Button.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { html } from 'lit-html'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { linkTo } from '@storybook/addon-links'; | ||
|
||
export default { | ||
title: 'Button', | ||
}; | ||
|
||
export const Text = () => html` | ||
<button @click=${action('clicked')}> | ||
Hello Button | ||
</button> | ||
`; | ||
|
||
export const Emoji = () => html` | ||
<button @click=${action('clicked')}> | ||
😀 😎 👍 💯 | ||
</button> | ||
`; | ||
|
||
Emoji.story = { | ||
parameters: { notes: 'My notes on a button with emojis' }, | ||
}; | ||
|
||
export const WithSomeEmojiAndAction = () => html` | ||
<button @click=${action('This was clicked')}> | ||
😀 😎 👍 💯 | ||
</button> | ||
`; | ||
|
||
WithSomeEmojiAndAction.story = { | ||
name: 'with some emoji and action', | ||
parameters: { notes: 'My notes on a button with emojis' }, | ||
}; | ||
|
||
export const ButtonWithLinkToAnotherStory = () => html`<button @click=${linkTo('Welcome')}> | ||
Go to Welcome Story | ||
</button>`; | ||
|
||
ButtonWithLinkToAnotherStory.story = { | ||
name: 'button with link to another story', | ||
}; |
24 changes: 0 additions & 24 deletions
24
lib/cli/src/generators/WEB-COMPONENTS/template/stories/index.stories.js
This file was deleted.
Oops, something went wrong.