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(Buttons): refactor code and fix spacing bug in loading buttonLink #1212

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

marcoskolodny
Copy link
Collaborator

@marcoskolodny marcoskolodny commented Aug 23, 2024

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

⚠️ Remark

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.

Copy link

github-actions bot commented Aug 23, 2024

Size stats

master this branch diff
Total JS 12.1 MB 12.1 MB -1.5 kB
JS without icons 2.04 MB 2.03 MB -1.5 kB
Lib overhead 68.1 kB 68.2 kB +38 B
Lib overhead (gzip) 16.5 kB 16.5 kB +25 B

Copy link

github-actions bot commented Aug 23, 2024

Accessibility report
βœ”οΈ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

Copy link

github-actions bot commented Aug 23, 2024

Deploy preview for mistica-web ready!

βœ… Preview
https://mistica-7gaudk7gz-flows-projects-65bb050e.vercel.app

Built with commit 71e4799.
This pull request is being automatically deployed with vercel-action

Copy link
Collaborator Author

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

src/button.tsx Outdated Show resolved Hide resolved
@marcoskolodny marcoskolodny removed the request for review from yceballost August 26, 2024 17:35
@marcoskolodny marcoskolodny added this pull request to the merge queue Aug 26, 2024
Merged via the queue into master with commit 640e429 Aug 26, 2024
11 checks passed
@marcoskolodny marcoskolodny deleted the WEB-1999-refactor-buttons-code branch August 26, 2024 18:04
tuentisre pushed a commit that referenced this pull request Sep 3, 2024
# [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))
@tuentisre
Copy link
Collaborator

πŸŽ‰ This PR is included in version 15.19.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants