-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
refactor: connect ShadCN Link
to ShadCN ButtonLink
#13560
Changes from all commits
417c803
5a2c361
ec47b90
4eb2b41
18fe6a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from "@storybook/react/*" | ||
|
||
import { ButtonLink as ButtonLinkComponent } from "../buttons/Button" | ||
|
||
const meta = { | ||
title: "Atoms / Form / ShadCn Buttons", | ||
component: ButtonLinkComponent, | ||
} satisfies Meta<typeof ButtonLinkComponent> | ||
|
||
export default meta | ||
|
||
export const ButtonLink: StoryObj<typeof meta> = { | ||
args: { | ||
href: "#", | ||
children: "What is Ethereum?", | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,9 +63,20 @@ const ButtonTwoLines = ({ | |
) | ||
|
||
if (props.componentType === "link") { | ||
const { buttonProps, ...rest } = props | ||
return ( | ||
<ButtonLink className={commonClassStyles} size={size} {...props}> | ||
<ChildContent {...props} size={size} isIconLeft={isIconLeft} /> | ||
<ButtonLink | ||
className={commonClassStyles} | ||
// size={size} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did comment this out to skip a type error that was breaking the build. I see this as a minor issue for now since this component is not currently used. We can tackle the issue in a separate PR. I also think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With With if (props.componentType === "link") {
const { buttonProps, ...rest } = props
const mergedButtonProps = merge(buttonProps, { size })
return (
<ButtonLink
className={commonClassStyles}
buttonProps={mergedButtonProps}
{...rest}
>
<ChildContent
{...rest}
size={size}
isSecondary={buttonProps?.isSecondary}
isIconLeft={isIconLeft}
/>
</ButtonLink>
)
} What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should follow the same approach we took with the original ButtonLink. In this case, I think we should return just a button to simplify everything. Then, in case you need a buttonlink, the user/dev could do the same we are doing with the buttonlink. // always a button
<ButtonTwoLines size=".." variant="..." />
// in case you want a buttonlink => compose them with asChild (same as with ButtonLink)
<ButtonTwoLines asChild>
<BaseLink> ...
</Button> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pettinarip Good with me! Getting too DRY here, and it's showing its cracks |
||
buttonProps={buttonProps} | ||
{...rest} | ||
> | ||
<ChildContent | ||
{...rest} | ||
size={size} | ||
isSecondary={buttonProps?.isSecondary} | ||
isIconLeft={isIconLeft} | ||
/> | ||
</ButtonLink> | ||
) | ||
} | ||
|
@@ -79,7 +90,10 @@ const ButtonTwoLines = ({ | |
export default ButtonTwoLines | ||
|
||
const ChildContent = ( | ||
props: Omit<ButtonTwoLinesProps, "iconAlignment"> & { isIconLeft: boolean } | ||
props: Omit<ButtonTwoLinesProps, "iconAlignment" | "buttonProps"> & { | ||
isIconLeft: boolean | ||
isSecondary?: boolean | ||
} | ||
) => { | ||
const { | ||
reverseTextOrder = false, | ||
|
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.
👍🏼