-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Storybook: Addon to wrap stories in max-width div #45134
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +134 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
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'll let @mirka give final approval , since she's been putting together most Storybook utils/addons !
storybook/decorators/with-wrapper.js
Outdated
|
||
const Wrapper = styled.div` | ||
max-width: 248px; | ||
padding: 16px; |
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.
Should we also show an outline
? It would help to read the padding better
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 did ponder adding a border myself but erred towards minimising changes from how the current component stories looked. I'll add one tomorrow 👍
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.
For sure there are pros and cons — I though an outline / border could help also with the look of the sidebar?
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.
A couple small things:
- I believe the correct metrics are 280-(16*2) = 248px? (248px is the internal content width, after padding)
- I'm hoping we can keep this add-on to have a singular purpose for now — so, just max-width and nothing else. (No padding, no borders, etc). Would that be ok?
- One of the reasons for point 2 ☝️ is that almost every Storybook decorator we have is a "wrapper". So it would be good to be clear about what each wrapper is for. Could we change all the naming to be more specific, like
WithMaxWidthWrapper
,context.globals.maxWidthWrapper
, etc?
We could also consider injecting an indicator div (like the margin checker) so nobody gets confused whether or not a max-width is being applied. No strong opinion on this at the moment though. We could add something later if we do find it confusing.
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, all good suggestions.
- Padding has been removed
- Max width has been corrected
- No border added
- Add-on has been renamed to indicate a singular purpose
- Indicator has also been added
- Styles copied from the margin checker
- I think it's good to make it easy to know what max-width is being applied
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.
Yay, thanks! I think the icon is good 👍
storybook/decorators/with-wrapper.js
Outdated
|
||
const Wrapper = styled.div` | ||
max-width: 248px; | ||
padding: 16px; |
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.
A couple small things:
- I believe the correct metrics are 280-(16*2) = 248px? (248px is the internal content width, after padding)
- I'm hoping we can keep this add-on to have a singular purpose for now — so, just max-width and nothing else. (No padding, no borders, etc). Would that be ok?
- One of the reasons for point 2 ☝️ is that almost every Storybook decorator we have is a "wrapper". So it would be good to be clear about what each wrapper is for. Could we change all the naming to be more specific, like
WithMaxWidthWrapper
,context.globals.maxWidthWrapper
, etc?
We could also consider injecting an indicator div (like the margin checker) so nobody gets confused whether or not a max-width is being applied. No strong opinion on this at the moment though. We could add something later if we do find it confusing.
Thanks for the reviews! I think everything has been cleaned up now if you'd like to give it another once-over 🙂 |
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.
Awesome! 🚢
I think I'll be using this a lot too, especially for screenshots!
Related:
What?
Adds a quick means to wrap a story in a div reflecting the max-width and padding constraints of the WordPress sidebar.
Why?
This addon will allow us to remove the ad hoc wrappers on some components, e.g.
BorderBoxControl
, that set amax-width
matching the WordPress editor sidebars. This way, the component can stretch the full width of the viewport by default illustrating how the component adapts to fill space.When developing components, this addon will make it quick and easy to constrain components to a real-world scenario, such as the width of our editor sidebars.
How?
Testing Instructions
UnitControl
story and confirm the control stretches the full width of your canvasWP Sidebar
option for the new "Wrapper" addon.Screenshots or screencast
Screen.Recording.2022-10-20.at.10.38.13.am.mp4