-
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
ProgressBar
: Simplify default width
implementation and make it more easily overridable
#61976
Conversation
6a2626d
to
bd8c12e
Compare
b23ace3
to
7efb431
Compare
7efb431
to
08346ec
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
To be fair, I think an extra prop that toggles a particular style rule on or off is a worse API than just relying on a classname or inline style.
I also read the discussion in #61062 but couldn't find where and why we decided to have an hasUnconstrainedWidth
prop.
I agree with @jasmussen when he said that we should have a default width for consistency.
I also think we should provide a way to override the width
, but maybe a size/width
prop isn't the best idea since it will prevent the ProgressBar
from being fluid and flexible. We do provide consumers the option to add a classname
where they can add max-width: unset;
or whatever works best for them. I don't think we need an extra prop on top of that.
So I think we should rely on the classname
, document how to change the width
better (including with fluid and non-fluid options), and either:
- Keep the default
max-width
for consistency - Remove the
max-width
and rely on the parent width across the editor.
As I agree with @jasmussen that a default width makes sense for consistency reasons, I'd lean on option 1. I know @mirka preferred option 2, but I believe this will add additional costs for maintaining consistency (having to specify max-width
or width
in multiple places) so I'm curious to hear other thoughts on it.
packages/components/CHANGELOG.md
Outdated
@@ -5,6 +5,8 @@ | |||
### Enhancements | |||
|
|||
- Components: Make the `ProgressBar` public ([#61062](https://github.com/WordPress/gutenberg/pull/61062)). | |||
- Components: Improve `ProgressBar` width control ([#61976](https://github.com/WordPress/gutenberg/pull/61976). |
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.
Same as the other PR - this needs to use the existing Enhancements section.
The concern I have with the "just override with classname" approach with things like width, is that it's non-obvious which properties exactly need to be overridden. Is it For me, it's either:
Though I understand that there are no clear winners here. Both have downsides. Also for what it's worth, I just realized that the native |
… default It has a default `max-width` of 160px, but allows consumers to explicitely disable it so that it expands to fit the parent's width by default. Consumers can then optionally set another width the way they see fit via a custom `className`.
…abled by default" This reverts commit 7a00da3.
08346ec
to
66e8223
Compare
ProgressBar
width controlProgressBar
width more easily overridable
ProgressBar
width more easily overridableProgressBar
: Simplify default width
implementation and make it more easily overridable
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 think all our deliberation paid off! We thought through every detail, and I'd say we landed on the best solution 🎉 (Fingers crossed!)
Thank you everyone for the great collaboration.
Flaky tests detected in e75e941. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9277256751
|
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.
Looking good 👍 🚀
@@ -38,6 +36,10 @@ export const Track = styled.div` | |||
// Windows high contrast mode. | |||
outline: 2px solid transparent; | |||
outline-offset: 2px; | |||
|
|||
:where( & ) { | |||
width: 160px; |
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.
Not specific to this PR, but is there any reason we're not using rem
almost everywhere? It is good practice for proper zoom support, which is an important accessibility feature. @WordPress/gutenberg-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.
I've always assumed that this was a "that ship has sailed" situation, since WordPress/Gutenberg is already built entirely on a non-rem basis 😓
WithCustomWidth.args = { | ||
className: 'custom-progress-bar', | ||
}; | ||
WithCustomWidth.decorators = [ |
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.
Another thing that's not specific to this PR, but I wonder why we're still using a legacy CSF version, even for new stuff. Haven't checked our current version, but CSF 3 has been supported for the last couple of versions and it makes Storybook much easier to work with. @WordPress/gutenberg-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.
We probably should! Nobody hadn't really prioritized it enough.
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 good to me! Pending @tyxla's comments, I think this is ready to merge.
e75e941
to
a076910
Compare
Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Thanks for the collab and thorough review folks! ❤️ |
…re easily overridable (WordPress#61976) * Remove "experimental" designation for `ProgressBar` * Add optional width prop to override/set the progress bar track container * Revert "Add optional width prop to override/set the progress bar track container" This reverts commit b1fe7cd. * Keep an unconstrained width by default, while allowing consumers to override it with CSS * Revert "Keep an unconstrained width by default, while allowing consumers to override it with CSS" This reverts commit 64c72e2. * Make the component public * Update consumers to import the public component * Expose docs for the now public ProgressBar component * Update CHANGELOG * Run docs:build after docs/manifest.js change * Remove remaining private usage of ProgressBar * Small formatting fix in the changelog * Add basic docs to the README * Add jsdoc * Formatting fix in README jsx block Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Another formatting fix in README jsx block Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF (yet another formatting fix) in the README jsx Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Improve wording in descripton of the `value` prop in the README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: Missing semicolon in README jsx Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: missing semicolon in jsx block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: missing semicolon in jsx block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: use tab instead of spaces in jsx code block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Move export out of the HOC export section * Fix CHANGELOG: Move entry to the existing enhacements section * Spacing fix Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Sort import alphabetically * Allow `ProgressBar` to have unconstrained width, which is disabled by default It has a default `max-width` of 160px, but allows consumers to explicitely disable it so that it expands to fit the parent's width by default. Consumers can then optionally set another width the way they see fit via a custom `className`. * Revert "Allow `ProgressBar` to have unconstrained width, which is disabled by default" This reverts commit 7a00da3. * Update docs and add story to illustrate a custom width * Update CHANGELOG * Simplify description in the story Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Improve jsdoc in story, do not encourage more customization than needed * Inherit the second story from the main template --------- Co-authored-by: fullofcaffeine <fullofcaffeine@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>
…re easily overridable (WordPress#61976) * Remove "experimental" designation for `ProgressBar` * Add optional width prop to override/set the progress bar track container * Revert "Add optional width prop to override/set the progress bar track container" This reverts commit b1fe7cd. * Keep an unconstrained width by default, while allowing consumers to override it with CSS * Revert "Keep an unconstrained width by default, while allowing consumers to override it with CSS" This reverts commit 64c72e2. * Make the component public * Update consumers to import the public component * Expose docs for the now public ProgressBar component * Update CHANGELOG * Run docs:build after docs/manifest.js change * Remove remaining private usage of ProgressBar * Small formatting fix in the changelog * Add basic docs to the README * Add jsdoc * Formatting fix in README jsx block Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Another formatting fix in README jsx block Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF (yet another formatting fix) in the README jsx Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Improve wording in descripton of the `value` prop in the README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: Missing semicolon in README jsx Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: missing semicolon in jsx block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: missing semicolon in jsx block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * YAFF: use tab instead of spaces in jsx code block in README Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Move export out of the HOC export section * Fix CHANGELOG: Move entry to the existing enhacements section * Spacing fix Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Sort import alphabetically * Allow `ProgressBar` to have unconstrained width, which is disabled by default It has a default `max-width` of 160px, but allows consumers to explicitely disable it so that it expands to fit the parent's width by default. Consumers can then optionally set another width the way they see fit via a custom `className`. * Revert "Allow `ProgressBar` to have unconstrained width, which is disabled by default" This reverts commit 7a00da3. * Update docs and add story to illustrate a custom width * Update CHANGELOG * Simplify description in the story Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com> * Improve jsdoc in story, do not encourage more customization than needed * Inherit the second story from the main template --------- Co-authored-by: fullofcaffeine <fullofcaffeine@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>
Depends on: #61062.
This is a follow-up to #61062. See this comment for more details on how the work has been split: #61062 (comment). You can also read the discussion there to better understand how we arrived at this solution. You can also check the edit history to see the original description for this PR.
What?
Better align the default width behavior with the original component specs and make it easier to override it.
This PR also adds a new story to illustrate a custom width and updates the docs/jsdoc.
Why?
This progress bar was designed to be of a fixed width, so we should keep it. Existing consumers already expect it, too. However, if there are any scenarios where a custom width size/behavior is required, we should provide the means to do so.
How?
160px
for the progress bar. It's meant to have a fixed size, see this comment;max-width
to set it. It's not meant to adapt to the parent size, by default;:where
pseud-element (which has zero specificity) to set a default width. This makes it trivial for consumers to override the width with a custom CSS class, if they wish.Testing Instructions
ProgressBar
.