-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️(frontend) simplify button primitive
In object-oriented terms, the previous implementation violated the Liskov Substitution Principle. Props between these two components (Button and Link) were not substitutable. This led to TypeScript errors and increased overall complexity without significant DX gains. To address this, the LinkButton has been extracted into a dedicated component.
- Loading branch information
1 parent
211ba33
commit 1875a39
Showing
4 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Link, LinkProps } from 'react-aria-components' | ||
import { type RecipeVariantProps } from '@/styled-system/css' | ||
import { buttonRecipe, type ButtonRecipe } from './buttonRecipe' | ||
import { TooltipWrapper, type TooltipWrapperProps } from './TooltipWrapper' | ||
|
||
type LinkButtonProps = RecipeVariantProps<ButtonRecipe> & | ||
LinkProps & | ||
TooltipWrapperProps | ||
|
||
export const LinkButton = ({ | ||
tooltip, | ||
tooltipType = 'instant', | ||
...props | ||
}: LinkButtonProps) => { | ||
const [variantProps, componentProps] = buttonRecipe.splitVariantProps(props) | ||
|
||
return ( | ||
<TooltipWrapper tooltip={tooltip} tooltipType={tooltipType}> | ||
<Link className={buttonRecipe(variantProps)} {...componentProps} /> | ||
</TooltipWrapper> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters