-
Notifications
You must be signed in to change notification settings - Fork 10
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(Buttons): refactor code and fix spacing bug in loading buttonLink #1212
Conversation
Size stats
|
Accessibility report βΉοΈ You can run this locally by executing |
Deploy preview for mistica-web ready! β
Preview Built with commit 71e4799. |
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.
expected. The horizontal spacing of a loading ButtonLink was wrong
# [15.19.0](v15.18.0...v15.19.0) (2024-09-03) ### Bug Fixes * **Buttons:** avoid warnings related to change in order of react hooks ([#1229](#1229)) ([2dbc411](2dbc411)) * **i18n): Revert "feat(i18n:** improve texts sizes" because it is breaking ([#1226](#1226)) ([79eb4a4](79eb4a4)) * **Logo:** fix webpackChunkName magic comments ([#1214](#1214)) ([3d1f098](3d1f098)) * **Vivinho char:** vivinho char in headings being read as a separated heading ([#1209](#1209)) ([f0f5fb0](f0f5fb0)) ### Features * **Buttons:** refactor code and fix spacing bug in loading buttonLink ([#1212](#1212)) ([640e429](640e429)) * **i18n:** improve texts sizes ([#1204](#1204)) ([0345e7c](0345e7c)) * **Logo:** Refactor logo to improve bundle size and loading times ([#1210](#1210)) ([15b77cb](15b77cb)) * **NavigationBar, FunnelNavigationBar, MainNavigationBar:** add alternative variant ([#1200](#1200)) ([eef87ec](eef87ec))
π This PR is included in version 15.19.0 π The release is available on: Your semantic-release bot π¦π |
Issue: Link
ποΈ Note
While I was creating the default version of ButtonLink, I noticed that there is a lot of copy-paste in the button components. I've refactored the code to avoid this.
Also, after doing this refactor I saw that some screenshots tests were affected (ButtonLink with loading state). I investigated this, and I realized that my refactor unexpectedly fixed a bug we had in the ButtonLink component. When a Link in loading state is rendered, the horizontal spacing on the left/right of the button was incorrect (22.5px instead of 12px as the specs indicate).
A bit more about the bug: the loading content is positioned absolutely with left/right spacing of 12px, but the code also adds the original padding of the ButtonLink content (12px minus 1.5px of border, so an extra of 10.5 pixels). This adds up to the 22.5px we have today in prod, and this is wrong.
This bug can be reproduced with this snippet
This is NOT a breaking change. I've added the
small
prop for ButtonLink in order to avoid extra logic in the code. For now, the prop can only be set to true (basically, it does nothing). I'm working in another PR where I allow the prop to be false (part of the breaking changes for next major release).I don't see this as an issue, because it's a temporary thing and using the prop doesn't cause any side effect (it changes nothing). Adding this simplifies the code and trivializes the changes required for the major release.
βοΈ About webapp
I've triggered mistica action against this branch in webapp and there are no failing tests or changes anywhere (results), so this refactor looks safe.