-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
UI: Improved Button and IconButton #24266
Conversation
This reverts commit c9a9f06.
Thanks a lot for reviewing this PR @JReinhold. Here's some answers:
This was a conscious decision. From the audit that I made so far I could find a single instance where any of the main button components were use in both internal and external addons. The idea is to make sure that automatically default to our new default design with the closest match.
I'll work on that tomorrow on migration notes. I'm not sure what need to be done regarding runtime depreciation warnings though. Can you tell me more?
This is now fixed. I added more stories to test animations.
Yes you're right. I can work on it tomorrow morning. |
That's fair, we should make sure to mention it in the migration notes.
we should show a warning in the console when we detect that someone is using any of the deprecated props. See how we do it for |
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! I have a few minor comments but I'm sure you'll figure it out. Make sure to review all the UI Tests in Chromatic.
MIGRATION.md
Outdated
@@ -320,6 +321,10 @@ In Storybook 7 it was possible to use `addons.setConfig({...});` to configure St | |||
- `showPanel: boolean` is now split into `bottomPanelHeight: number` and `rightPanelWidth: number`, where the numbers represents the size of the panel in pixels. | |||
- `isFullscreen: boolean` is no longer supported, but can be achieved by setting a combination of the above. | |||
|
|||
#### New UI and props for Button and IconButton components | |||
|
|||
We used to have a lot of different buttons in `@storybook/components` that were not used anywhere. We have removed them and added a new `Button` component that can be used in all places. The `IconButton` component has also been updated to use the new `Button` component. Going forward addon creators and Storybook maintainers should use the new `Button` component. `IconButton` is still available for use, but we might remove it in the future as this is just a wrapper around the `Button` component. `Form.Button` is depreciated and will be removed in the future. |
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 need to:
- be specific about which exact components have been deprecated (currently it just says "a lot of different buttons")
- which exact props have been deprecated
- which new props replace which old props
- give an example of migrating from the old props to the new props
We don't need to specify stuff that we "might remove" in the future, it doesn't help the user and just creates uncertainty.
In reality this is mostly an accessible version of what's written in the source code and the types, but we can't expect users to read those at all. Consider that users will see the warning in the console with a link to this section, they'll need a way forward here to resolve the warning.
Here's a proposal:
The X component from
@storybook/components
have been deprecated.
The following props to theButton
component have been deprecated:
- X use Y instead
- X use Y instead
- ...
(same forIconButton
if it has any deprecations)
Here's an example of migrating from the old props to the new props:// deprecated usage <Button ... /> // new usage <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.
I just pushed an update with some new notes and clear descriptions of what props are deprecated and what is the alternative.
path: { | ||
fill: 'currentColor', | ||
}, | ||
background: `${(() => { |
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.
it's not actually fixed here 😁
verticalAlign: 'top', | ||
whiteSpace: 'nowrap', | ||
userSelect: 'none', | ||
opacity: disabled ? 0.5 : 1, |
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 way of setting something to be disabled is a bit unfortunate. if the button is on top of something that has multiple colors, it will actually be semi-transparent, where I think what we really want is the colors to be slighlty muted?
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 agree with you on this one but I think this is something we might change after the theming v2.0 project. For now there is pretty low risk that the button will be below something else.
What I did
As part of all our efforts to update our core UI components, we are improving both the Button and IconButton as part of this PR. The main concept here is to make it more of an atomic version that can be used anywhere. We worked on creating props that would make it easy to customise and extend the way you want without breaking the design. It also work with the existing icons library as well as our new icon library.
children
prop as it is.asChild
prop to allow for a custom wrapper (for<Link>
or<a />
).IconButton
is now just a wrapper aroundButton
with special props.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
yarn storybook:ui
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>