-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui/react): Text 기능을 상속하는 Link로 개편 (#283)
* refactor(ui/react): Text 기능을 상속하는 Link로 개편 * refactor(ui/react): Toast에 Link 변경사항 반영 * refactor(ui/react): components의 index.ts에 link 제거
- Loading branch information
Showing
9 changed files
with
73 additions
and
76 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* eslint-disable @stylistic/padding-line-between-statements, react-refresh/only-export-components */ | ||
export { Heading, type HeadingProps } from './heading'; | ||
|
||
export { Link, type LinkProps } from './link'; | ||
export { Text, type TextProps } from './text'; |
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,34 @@ | ||
import { createVar, style } from '@vanilla-extract/css'; | ||
import { type RecipeVariants, recipe } from '@vanilla-extract/recipes'; | ||
|
||
const textDecorationLine = createVar(); | ||
|
||
const base = style({ | ||
textDecorationColor: 'currentcolor', | ||
textDecorationLine: 'none', | ||
textDecorationStyle: 'solid', | ||
vars: { | ||
[textDecorationLine]: 'underline', | ||
}, | ||
}); | ||
|
||
export const linkVariants = recipe({ | ||
base, | ||
|
||
variants: { | ||
underline: { | ||
always: { textDecorationLine }, | ||
hover: { ':hover': { textDecorationLine } }, | ||
none: {}, | ||
}, | ||
}, | ||
|
||
defaultVariants: { | ||
underline: 'hover', | ||
}, | ||
}); | ||
|
||
export type LinkVariants = Exclude< | ||
RecipeVariants<typeof linkVariants>, | ||
undefined | ||
>; |
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,35 @@ | ||
import { | ||
type HTMLFavolinkProps, | ||
type RightJoinProps, | ||
forwardRef, | ||
} from '@favolink-ui/system'; | ||
import { cx } from '@favolink-ui/utils'; | ||
import * as styles from './link.css'; | ||
import { Text, type TextProps } from './text'; | ||
|
||
export type LinkProps = RightJoinProps< | ||
Omit<TextProps, 'as'>, | ||
Omit<HTMLFavolinkProps<'a'>, 'color'> | ||
> & | ||
styles.LinkVariants; | ||
|
||
export const Link = forwardRef<LinkProps, 'a'>( | ||
function Link(props, forwardedRef) { | ||
const { children, className, asChild, underline, ...restProps } = props; | ||
|
||
return ( | ||
<Text | ||
{...restProps} | ||
ref={forwardedRef} | ||
asChild | ||
className={cx( | ||
'favolink-link', | ||
styles.linkVariants({ underline }), | ||
className, | ||
)} | ||
> | ||
{asChild ? children : <a>{children}</a>} | ||
</Text> | ||
); | ||
}, | ||
); |