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

feat(Button): button redesign #1234

Merged
merged 20 commits into from
Sep 4, 2024
Merged

feat(Button): button redesign #1234

merged 20 commits into from
Sep 4, 2024

Conversation

janseke10
Copy link
Contributor

@janseke10 janseke10 commented Aug 12, 2024

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. Use imperative, present tense in your commit description ("change", not "changed" or "changes") without uppercases or period (.) at the end.

BREAKING CHANGE: button props isLink & isInline & isPrimary are removed

  • inline button should be replaced by size="small"
  • isLink should be replaced by variant="ghost"
  • isPrimary should be replaced with variant="filled" (default)

Checklist

  • The implementation has been manually tested and complies with Textkernel browser support guidelines
  • The implementation complies with accessibility standards.
  • The component has a displayName defined.
  • The component comes with a detailed PropTypes (and defaultProps) definition.
  • Component PropTypes are sufficiently described / documented.
  • There is a story in Storybook.

@eszthoff
Copy link
Contributor

Check the docs about breaking change comments, the syntax is important for the library to pick it up. (singular change, I think it should be on one line). Please adjust the description to match, then when squashing the commits, you can just copy paste it.

&:active {
background-color: var(--transparent);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sass Master :) Nice!

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed!!

if (buttonRef && buttonRef.current) {
setButtonWidth(buttonRef.current.offsetWidth);
}
}, [buttonRef]);
Copy link
Contributor

@mukiienko mukiienko Aug 15, 2024

Choose a reason for hiding this comment

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

In this case, we only measure the element's width during the initial phase. If the width or text changes during the button's lifecycle, it could result in an incorrect width. For example, if we switch the language and all the text changes, the button may have the wrong width. Although this might be an edge case, what do you think about measuring the element's width on demand—specifically when the loading state is true? This way, we will always have the correct width for both the button and the loading state:

....
        const buttonRef = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);
        const [buttonWidth, setButtonWidth] = React.useState<number | undefined>();

        if (buttonRef.current && isLoading && !buttonWidth) {
            setButtonWidth(buttonRef.current.offsetWidth);
        }

        if (!isLoading && buttonWidth) {
            setButtonWidth(undefined); // Reset to auto width when not loading
        }

        if (typeof children !== 'number' && !children) {
            return null;
        }
...
style={{ width: buttonWidth ? `${buttonWidth}px` : 'auto' }}
....

Copy link
Contributor

Choose a reason for hiding this comment

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

I still think we don't need React.useLayoutEffect for calculation width.

@mukiienko
Copy link
Contributor

mukiienko commented Aug 15, 2024

Loading state doesn't work for link:
Screenshot 2024-08-15 at 11 29 14

&:active {
background-color: var(--transparent);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

indeed!!

@mukiienko
Copy link
Contributor

Loading state doesn't work for link: Screenshot 2024-08-15 at 11 29 14

Loading state has wrong width:

Screen.Recording.2024-08-20.at.12.18.16.mov

Copy link

vercel bot commented Aug 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oneui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 9:18am

@mukiienko mukiienko merged commit 58698af into master Sep 4, 2024
8 checks passed
@mukiienko mukiienko deleted the ONEUI-437-buttons-redesign branch September 4, 2024 09:21
mukiienko pushed a commit that referenced this pull request Sep 4, 2024
BREAKING CHANGE: button props `isLink` & `isInline` & `isPrimary` are removed

BREAKING CHANGE: button prop `isInline` button should be replaced by `size="small"`

BREAKING CHANGE: button prop `isLink` should be replaced by `variant="ghost"`

BREAKING CHANGE: button prop `isPrimary` should be replaced with `variant="filled"` (default) or removed

BREAKING CHANGE: button prop `size: "normal"` is replaced with `size: "medium"`

---------

Co-authored-by: André Nogueira <[email protected]>
Co-authored-by: Oleksii Mukiienko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants