-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(#1216): storybook config #2310
Conversation
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. |
Thank you so much for looking into this! I've never been able to get Storybook to work so I'm uncertain of what it looked like before. It does seem from you screenshots that the components which use |
stories: ['../client/**/*.stories.(jsx|mdx)'], | ||
addons: [ | ||
'@storybook/addon-actions', | ||
'@storybook/addon-docs', | ||
'@storybook/addon-knobs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that you removed some packages from the addons
array here but kept them in the package.json
. Do they need to be kept as dependencies or should they be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should be removed now. They've been deprecated https://www.npmjs.com/package/@storybook/addon-knobs
Actions are built in by default. And knobs have been replaced with args
and argTypes
where you can configure controls to play with. I've updated Buttons and Icons stories to use these rather than the knobs that were there.
.storybook/preview.js
Outdated
})); | ||
export const decorators = [ | ||
(Story) => ( | ||
<Provider store={store}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are connecting to Redux here then maybe we want a way to modify the initial state on a per-story basis? Just a thought. That's something for a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what Redux is used for but all components with stories needed it. It could be good to try and remove it as a dependancy from Storybook/Design System components 🤷🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I actually agree. I think of Storybook as being for pure UI components which are not connected to Redux. But the current FileNode
and the SocialAuthButton
components are connected and they have stories so that's why we need it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! We do need to fix the eslint setup before merging.
@lindapaiste It looks like the css is already built so it was just a matter of including the css file 🎉
These screen shots look better |
@lindapaiste so it looks like including the storybook eslint rules in
As a test commenting out the icon stories and looking at the warnings we can see
And if you fix that you get another error about having at least one story. |
Right now my only concern is the changes in unrelated files due to Prettier. Ideally we want it to pass the linting checks without changing anything. I noticed in your Can you try the following steps?
I definitely want to get this merged in ASAP so that we can keep building on it. Now that you've got the basics of Storybook working I'm seeing problems and areas for improvement in the stories and in the components themselves. I've been reading some docs to figure out how to make the most out of Storybook and I've figured out theme switching, selecting icons from a dropdown on the |
label={text('label', 'submit')} | ||
> | ||
{text('children', 'this is the button')} | ||
export const AllFeatures = (args) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controls on this story don't seem to do anything because we aren't passing down all of the args
. Looks like we can write the story as an object with the new "Component Story Format 3". Very cool.
export default {
title: 'Common/Button',
component: Button
}
export const AllFeatures = {
args: {
children: 'this is the button'
}
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating linting... I mistakenly thought these were linting issues on the main branch. I wasn't giving them much thought. I'll try your suggestion later today and see if I can revert them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah with stories you can set some defaults for all stories. Customise default args per story. Or present them with fixed values too if you like.
Previously this AllFeatures
story had dynamic args as knobs and all the reset were fixed.
This is a button story from a personal project where args were overridden.
const Template: Story<ButtonProps> = (args) => <Button {...args} />;
export const FullWidth = Template.bind({});
FullWidth.args = {
primary: true,
children: 'Button',
fullWidth: true
};
This reverts commit 1c3748d.
One other addition. I ran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Thank you for all of your work on this!
I'm going to go ahead and merge this. Feel free to keep adding other improvements in additional PRs.
Ah 💩, one last thing. Can you please commit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Related to #1216
It looks like Storybook has been set up previously but is currently in a broken state.
I was attempting to explore the project via Storybook and notice the commands weren't working.
The changes in
package.json
were due to running this commandnpx storybook@latest init
which took me through an install wizard. These are the packages Storybook recommends.addDecorator
,addParameters
andwithKnobs
are no longer supported. Controls are created for you through prop introspection with the ability to override withargTypes
.I'm not familiar with the work prior to these changes so I can't offer garuntee that thats how these stories behaved prior to this upgrade.
But I can confirm all stories are now rendering.
I notice one of the initial motivations were "help reduce bugs and make contributing easier" which I absolutely agree with. It makes debugging hard to reach aspect a breeze. It also helps seperate concerns between stylistic/ux concerns and business logic.
Changes:
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123