-
Notifications
You must be signed in to change notification settings - Fork 219
Conversation
0ee1928
to
658127b
Compare
This PR has been rebased (package.json conflicts) |
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.
Great work @haszari ! This was working for me. I've left some feedback inline that can be addressed. Also, I'd like if we could add the same storybook addons as what gutenberg is using. All of them have great utility and it should be trivial to setup in this pull. That way going forward as we build and expand on stories we can utilize these add-ons. Having it configured from the get-go saves having to figure things out later.
@storybook/addon-docs
: allows us to add extra docs for stories to help explain things further if needed.@storybook/addon-knobs
: allows for configuring variations of props fed to components in a story by the user (which can be useful for demonstrating and seeing various behaviour controlled via props).@storybook/addon-storysource
: displays the source of the story in the storybook which I think is super useful for seeing the code used for the story (which is another way for developers to learn how things are implemented).@storybook/addon-viewport
: This allows us to display stories in different sizes and layouts. Super useful for seeing responsive behaviour (does it behave as expected with breakpoints etc).@storybook/addon-a11y
: This adds some accessibility checks to stories. I think this can help us keep on top of any potential accessibility issues in our components.
Along with the potential followups already identified, I also think it'd be neat if (in a followup at some point) we could wire things up so that pulls trigger the creation of an accessible storybook that can be viewed along with the pull. This could potentially help with visual reviews of components as well (Gutenberg is doing something similar). But that's definitely not needed right away.
2a22d84
to
2a577d6
Compare
@nerrad Thanks for the feedback – now ready for a final review. Note regarding addons – these are installed and configured (based on Gutenberg config) now. I've confirmed that they don't break the build and show up in the Storybook UI. I figure we'll need to revisit these in subsequent pulls as we add more stories - I haven't tested and configured all addons. I did some brief testing and some aren't fully working out of the box:
Rather than hold up merging this initial PR on investigating these addons, I suggest we merge and handle as follow up on the first few stories.
|
Looks like I need to rebase again. Keen to merge this ASAP! |
- fixes scss imports breaking storybook build - note scss / styling doesn't work yet + organise our component stories into folder
append our webpack aliases to storybook webpack config
- PriceSlider expects client to handle onChange and pass in new min/max
- icons components are changing in #1644 - we need to refactor/do more work to get ProductPreview working (settings globals)
0d3c01a
to
3574a99
Compare
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 pushed a couple of commits that fixed the inoperative addons. I've added some comments for things that should be addressed. Once that's done, go ahead and merge (so pre-approving).
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
|
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.
This is not needed.
/** | ||
* External dependencies | ||
*/ | ||
import { React, useState } from 'react'; |
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.
React is a default export (so usage is wrong) and is not needed. useState
should be imported from @wordpress/element
.
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; |
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.
No need to import React. To save repeating this everywhere, this comment applies to everywhere. Importing is not needed because the JSX is handled via babel pragma.
Fixes #1601
This PR is an experiment. Goals:
What is Storybook? It's developer tooling to document and develop components in isolation, outside of the context of your app. For us this means we can develop and test things like
PriceSlider
orQuantitySelector
outside of WordPress + Woo (+ Woo Blocks Plugin) environment.Why? Documenting our components allows us as developers to be explicit about the intended use and interface (props) of a component. Designers and product people can easily test and experience components in isolation, so that as a broader product team we can build up a library of consistent components for building new features or iterating on the UI. It also provides a nice way to review our components alongside those from other projects (e.g. Gutenberg, wc-admin).
Check out storybook docs here: https://storybook.js.org
Check out Gutenberg project storybook here: https://wordpress.github.io/gutenberg/
Screenshot
What's working
Button
,ReadMore
andPriceSlider
fromjs/base/components
ErrorPlaceholder
andIcon
s fromjs/components
@wordpress/components
; we may need more base styles / resets to simulate a "typical" theme front end or wp-admin environmentnpm run storybook
to launch storybook server - open browser to http://localhost:6006/npm run build-storybook
to build a static storybook site tostorybook-static
folder (we could publish this somewhere, e.g. GitHub Pages)What's not working
ProductPreview
for an example broken story). I'm thinking we handle this as a follow-up; we can still write useful stories for many components.How to test the changes in this Pull Request:
npm install
(a few new things).npm run storybook
to run storybook dev server.http://localhost:6006
and browse component stories. Stories are alongside each component in astories
folder (similar to Gutenberg project).Changelog