Skip to content

Commit

Permalink
fix: add title property to Link and LinkButton Components. for WCAG (#97
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Jeongyong-park authored Dec 28, 2024
1 parent 79fffe1 commit f413992
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/lib/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type LinkProps<E extends React.ElementType> = {
color?: Color;
children: React.ReactNode;
className?: string;
title?: string;
} & React.ComponentPropsWithoutRef<E>;

export const Link = <E extends React.ElementType = 'a'>({
Expand All @@ -14,6 +15,7 @@ export const Link = <E extends React.ElementType = 'a'>({
color = 'gray-90',
children,
className = '',
title,
...props
}: LinkProps<E>) => {
const sizeClass = {
Expand All @@ -31,6 +33,8 @@ export const Link = <E extends React.ElementType = 'a'>({
return (
<a
className={`${sizeClass} ${weightClass} ${textColorClass} ${className}`}
title={title}
aria-label={title}
{...props}
>
{children}
Expand Down
3 changes: 3 additions & 0 deletions packages/core/lib/components/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type LinkButtonProps<E extends React.ElementType> = {
children: React.ReactNode;
className?: string;
link: string;
title?: string;
} & React.ComponentPropsWithoutRef<E>;

export const LinkButton = <E extends React.ElementType = 'a'>({
Expand All @@ -16,6 +17,7 @@ export const LinkButton = <E extends React.ElementType = 'a'>({
children,
className = '',
link,
title,
...props
}: LinkButtonProps<E>) => {
const baseStyles =
Expand Down Expand Up @@ -52,6 +54,7 @@ export const LinkButton = <E extends React.ElementType = 'a'>({
href={link}
role="link"
weight={variantStyles.weight}
title={title}
{...props}
>
{children}
Expand Down
6 changes: 6 additions & 0 deletions stories/core/LinkButton.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ export const Accent: Story = {
variant: 'accent',
children: '링크 버튼: Accent',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
},
};

export const Default: Story = {
args: {
children: '링크 버튼: Default',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
},
};

export const Small: Story = {
args: {
children: '링크 버튼: Default',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
size: 'small',
},
};
Expand All @@ -55,6 +58,7 @@ export const Medium: Story = {
args: {
children: '링크 버튼: Default',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
size: 'medium',
},
};
Expand All @@ -63,6 +67,7 @@ export const Large: Story = {
args: {
children: '링크 버튼: Default',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
size: 'large',
},
};
Expand All @@ -71,6 +76,7 @@ export const popupLink: Story = {
args: {
children: '팝업 링크 버튼',
link: 'https://uiux.egovframe.go.kr/guide/index.html',
title: 'uiux.egovframe.go.kr 이동',
target: '_blank',
rel: 'noopener noreferrer',
},
Expand Down

0 comments on commit f413992

Please sign in to comment.