Skip to content

Commit 9e4a8c9

Browse files
authored
Merge pull request #13707 from ethereum/button-props
refactor: accept size and variant as direct props
2 parents a8ecc60 + 7fc7bd0 commit 9e4a8c9

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/components/ui/buttons/Button.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,37 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
108108
)
109109
Button.displayName = "Button"
110110

111-
type ButtonLinkProps = Omit<LinkProps, "onClick"> & {
112-
buttonProps?: ButtonProps
113-
customEventOptions?: MatomoEventOptions
114-
}
111+
type ButtonLinkProps = Omit<LinkProps, "onClick"> &
112+
Pick<ButtonProps, "size" | "variant" | "isSecondary"> & {
113+
buttonProps?: Omit<ButtonProps, "size" | "variant">
114+
customEventOptions?: MatomoEventOptions
115+
}
115116

116117
const ButtonLink = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
117118
(
118-
{ buttonProps, customEventOptions, children, className, ...linkProps },
119+
{
120+
size,
121+
variant,
122+
isSecondary,
123+
buttonProps,
124+
customEventOptions,
125+
children,
126+
className,
127+
...linkProps
128+
},
119129
ref
120130
) => {
121-
const { size, variant } = buttonProps || {}
122131
const handleClick = () => {
123132
customEventOptions && trackCustomEvent(customEventOptions)
124133
}
125134
return (
126-
<Button asChild size={size} variant={variant} {...buttonProps}>
135+
<Button
136+
asChild
137+
size={size}
138+
variant={variant}
139+
isSecondary={isSecondary}
140+
{...buttonProps}
141+
>
127142
<BaseLink
128143
ref={ref}
129144
className={cn("no-underline hover:no-underline", className)}

src/pages/what-is-ethereum.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,7 @@ const WhatIsEthereumPage = ({
650650
<ButtonLink href="/smart-contracts/">
651651
{t("page-what-is-ethereum-more-on-smart-contracts")}
652652
</ButtonLink>
653-
<ButtonLink
654-
href="/dapps/"
655-
buttonProps={{
656-
variant: "outline",
657-
isSecondary: true,
658-
}}
659-
>
653+
<ButtonLink href="/dapps/" variant="outline" isSecondary>
660654
{t("page-what-is-ethereum-explore-dapps")}
661655
</ButtonLink>
662656
</ButtonRow>
@@ -679,13 +673,7 @@ const WhatIsEthereumPage = ({
679673
<ButtonLink href="/eth/">
680674
{t("page-what-is-ethereum-what-is-ether")}
681675
</ButtonLink>
682-
<ButtonLink
683-
href="/get-eth/"
684-
buttonProps={{
685-
variant: "outline",
686-
isSecondary: true,
687-
}}
688-
>
676+
<ButtonLink href="/get-eth/" variant="outline" isSecondary>
689677
{t("page-what-is-ethereum-get-eth")}
690678
</ButtonLink>
691679
</ButtonRow>
@@ -714,10 +702,8 @@ const WhatIsEthereumPage = ({
714702
</ButtonLink>
715703
<ButtonLink
716704
href="/roadmap/merge/"
717-
buttonProps={{
718-
variant: "outline",
719-
isSecondary: true,
720-
}}
705+
variant="outline"
706+
isSecondary
721707
>
722708
{t("page-what-is-ethereum-the-merge-update")}
723709
</ButtonLink>

0 commit comments

Comments
 (0)