Skip to content
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

Merged
merged 48 commits into from
Oct 6, 2023
Merged

UI: Improved Button and IconButton #24266

merged 48 commits into from
Oct 6, 2023

Conversation

cdedreuille
Copy link
Contributor

@cdedreuille cdedreuille commented Sep 22, 2023

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.

  • No breaking changes for 8.0.
  • One button to rule them all. We are removing all the need for special button instances.
  • We are keeping the children prop as it is.
  • new asChild prop to allow for a custom wrapper (for <Link> or <a />).
  • IconButton is now just a wrapper around Button with special props.
  • Match design of old props to the closest version we have in the new design.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Open Storybook locally with yarn storybook:ui
  2. Go to the IconButton story to test it out.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/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>

@cdedreuille cdedreuille added maintenance User-facing maintenance tasks ci:normal labels Sep 22, 2023
@cdedreuille cdedreuille self-assigned this Sep 22, 2023
@cdedreuille cdedreuille changed the base branch from next to v8 September 22, 2023 07:48
@cdedreuille cdedreuille changed the base branch from v8 to release-8-0 September 22, 2023 14:27
@cdedreuille
Copy link
Contributor Author

Thanks a lot for reviewing this PR @JReinhold. Here's some answers:

Using the deprecated props will not make the button look at all like it used to. Here are the new deprecated stories, compare them with the current stories for the button and there is a clear visual difference. I'm not sure if we should consider this a breaking change or not. The API is not broken, but how the button looks in the UI has definitely changed.

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.

There are some thing missing here, mainly migration notes and runtime deprecation warnings. do you plan on adding this later, or as part of this PR? what other follow-up work are you planning to do, if any?

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?

I can't get the animations to work in the stories, am I doing something wrong? I'm just opening the base button story and setting the onClickAnimation prop but that doesn't seem to do anything.

This is now fixed. I added more stories to test animations.

I think we should use this opportunity to make the stories here great, with proper descriptions for the components and the props, so the Button/Docs page is something actually useful. setting a trend for our future work on the UI.

Yes you're right. I can work on it tomorrow morning.

@JReinhold
Copy link
Contributor

I'm consistently seeing some weird pixel-rendering issues (in Chromium) around the corners, is it just me, or are we using an unusual combination of shadows/borders that does this?

image

@JReinhold
Copy link
Contributor

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.

That's fair, we should make sure to mention it in the migration notes.

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?

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 Description here: https://github.com/storybookjs/storybook/blob/next/code/ui/blocks/src/blocks/Description.tsx#L143-L157

@cdedreuille cdedreuille requested a review from JReinhold October 4, 2023 10:26
Copy link
Contributor

@JReinhold JReinhold left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to:

  1. be specific about which exact components have been deprecated (currently it just says "a lot of different buttons")
  2. which exact props have been deprecated
  3. which new props replace which old props
  4. 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 the Button component have been deprecated:

  • X use Y instead
  • X use Y instead
  • ...
    (same for IconButton 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 ... />

Copy link
Contributor Author

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: `${(() => {
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@JReinhold JReinhold added the ui label Oct 5, 2023
@valentinpalkovic valentinpalkovic removed their request for review October 5, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal maintenance User-facing maintenance tasks ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants