Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: web-components stories homogenization #10703

Merged
merged 3 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/cli/src/generators/WEB-COMPONENTS/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fse from 'fs-extra';
import path from 'path';
import {
getVersion,
getVersionedPackages,
retrievePackageJson,
writePackageJson,
Expand All @@ -18,14 +17,14 @@ export default async (npmOptions, { storyFormat }) => {
'lit-html',
];

if (storyFormat === STORY_FORMAT.MDX) {
// TODO: handle adding of docs mode
}

const versionedPackages = await getVersionedPackages(npmOptions, ...packages);

fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true });

if (storyFormat === STORY_FORMAT.MDX) {
// TODO: handle adding of docs mode
}

const packageJson = await retrievePackageJson();

packageJson.dependencies = packageJson.dependencies || {};
Expand Down
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'],
};
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>
Comment on lines +40 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove that as I'm not sure there will be a .storybook/webpack.config.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the template does not contain such file:
image

However it's nice to tell people that if they add a webpack.config.js file it will be picked up, so maybe just rephrase that? Also, that sentence is in every framework's template, so if we were to make a change, it has to be synced with the others.

@shilman what's your take on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the current recommendation is to override webpackFinal in main.js, so we should probably update all the docs accordingly. webpack.config.js is still supported (for now, not sure how long we plan to keep this? But we should be directing everybody towards the recommendation. @ndelangen please feel free to correct if I got any of this wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current recommendation is to override webpackFinal in main.js

indeed

</main>`;

ToStorybook.story = {
name: 'to Storybook',
};
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' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should get rid of notes for every framework. It's deprecated or was even removed already.
@ndelangen what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @yannbf, notes has been moved to the repo storybookjs/deprecated-addons so no 6.0 version will be released.

Copy link
Member

@shilman shilman May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree we should get rid of notes and pick a better example. Maybe backgrounds and/or docs?

Slight clarification on the deprecation. We won't release a 6.0 version of notes along with the Storybook release. We will release deprecated addons with the community on an independent schedule and will be looking for users of those addons to step up as maintainers if they want to keep them going

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should leave it out for now.

};

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',
};

This file was deleted.