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

fix(ButtonTwoLines): split rendering of button or link #14521

Merged

Conversation

TylerAPfledderer
Copy link
Contributor

Splits ButtonTwoLines component to a dedicated ButtonTwoLines and ButtonLinkTwoLines.

Current Behavior

The current ButtonTwoLines relies on type guarding to check if a button or button link should render and accept the appropriate props.

The unintended side-effect with the current approach is that there is child content with specific props used that should not be sent to the Button/ButtonLink component, adding complexity in addressing unexpected issues.

New Behavior

Split the component into dedicated renders of either the Button or ButtonLink and add a creator function (createSplitProps) to help split the props so that only the needed ones for the child content are sent down, and the rest go to the parent component.

Most props are not explicit and are meant for the parent component only, some are meant for both, so need an intermediary to correctly identify who goes to the child content and not to the parent.

Additional Information

  • Removed the old ButtonTwoLines file.
  • Updated the required href prop for the ButtonLink.
  • Added a ButtonLinkTwoLines story. Although it has the same styling, this will confirm the use of ButtonLink without error or regression.

I will note that this seems like overengineering at the moment, as we currently do not employ the component in prod, and therefore do not even know if a rendering with ButtonLink is necessary. Open to discussion of simplification, reverting to the old approach and modifying that, or something else.

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 81da546
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/67679838a1617a0008cb779c
😎 Deploy Preview https://deploy-preview-14521--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 48 (🔴 down 8 from production)
Accessibility: 92 (no change from production)
Best Practices: 91 (🔴 down 7 from production)
SEO: 99 (🟢 up 1 from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

LGTM @TylerAPfledderer. I'm fine with this refactor, its cleaner and easier to understand than the previous one IMO.

Pick<ButtonProps, "size" | "variant" | "isSecondary"> & {
href: string
Copy link
Member

Choose a reason for hiding this comment

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

just curious, is the intention of this change to make the field required? looks good if so

@pettinarip pettinarip merged commit 4158959 into ethereum:dev Dec 23, 2024
10 checks passed
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.

2 participants