-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Storybook for component development #1244
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
Conversation
I guess this also kicks off the process of migrating to Styled Components—exciting! |
@catarak, I've commented about organising stories. I think the next steps are to implement that and properly extract the Button as a reusable component. I'll continue in this PR? |
sounds good!! i'm really excited to get this going ✨ |
@catarak Ok, so this introduces a shared To avoid this becoming a long-running branch that diverges from master, I think we should aim to get this merged in first. Then I'll do small PRs that tackle different sections of the app. |
Unfortunately a lot of the changes I've been working on for web accessibility are causing these merge conflicts.... i'm gonna try to fix them! |
I've been working on the branch feature/storybook-cat! I made some pretty significant changes (that I'm not 100% sure of), so I figured I'd separate it in case you think another direction is better. Basically, I decided to separate out the Icons from the Button component, because depending on how the icon is being used, you want it to have different accessibility attributes, that are separate from the function of the button. Sometimes the icon is purely decorative, and should be hidden from screen readers, and sometimes it should have a label. With my latest commit f359dce, the Icon component is not totally finished, and maybe it doesn't even need to be to merge this in. It would be rad to by default make all of the components web accessibility friendly, which is what I tried to do with the |
I like this approach, it looks like it works well! I left a comment about naming the inputs and outputs of the HoC.
What's left to do here? If it's enhancements—rather than fixing anything that's broken—then maybe open a PR from your branch to merge onto mine? We can continue to enhance as we expand the components. I'm a big fan of trying to get small improvements regularly merged into the main project.
Totally agree. Ideally, all the components will guide contributors (and us) to best practices by composing together in an accessible way and by having prop-types that require aria-labels etc. |
@catarak I thought about the approach in your latest commit some more and changed my mind... The purpose of having
How about we use For example, this would become: <Button
iconAfter={<Icons.DropdownArrow />}
onClick={() => setShowURL(!showURL)}
>
Share
</Button> |
I agree with your reasons here! We also get Icons as their own component, and support control over different needs for web accessibility. I'll update the branch 😸 |
I just merged my branch with this one and made your suggested changes. Would you mind taking a look again? I couldn't decide whether to make |
Ok @catarak , this is looking good. Thanks for merging those changes! Can you just check commit 161ac5b please? I've removed some aria-labels that duplicate button content. Or are misleading. I think that's ok? On I'm happy with either though. |
Thanks for catching those! You are right that they are unnecessary.
I hear you! I want to go with what's clearest. I think I'm gonna change it. |
Integrates Storybook, one of the options discussed in #1216.
This will allow components to be developed in isolation for reuse across the Editor app.
I've also included styled-components as there needs to be some way to bundle the component styling with the component.
This should be reviewed against PR #1294.
Usage
npm install
npm run storybook
Add-ons
Example "Button" component
This PR includes a new
Button
component with associated "stories" - the name Storybook gives each example instance of the component with a set of props.There are two ways of writing stories, and I've included an example of both for us to choose between.
A. Component Story Format (CSF)
File: client/components/Button/Button.stories.jsx
B. MDX Format
Intro page: client/index.stories.mdx
File: client/components/Button/Button.stories.mdx
Proposal
I'd actually propose that most of our stories should be in CSF format. If we need the extra flexibility of MDX then it's easy to swap to that.