Skip to content

Commit

Permalink
feat: implement for TextLink component
Browse files Browse the repository at this point in the history
  • Loading branch information
kumanoayumi committed Oct 18, 2024
1 parent 529927f commit 34f1a1b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.link {
color: var(--primary-color);

&:hover {
background-image: linear-gradient(
var(--primary-color),
var(--primary-color)
);
background-size: 100% 1px;
background-position: 0 100%;
background-repeat: no-repeat;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Meta, StoryObj } from '@storybook/react'

import { LinkText } from '.'

const StoryComponent = () => {
return <LinkText href="https://www.google.com">dummy</LinkText>
}

const meta = {
component: StoryComponent,
} satisfies Meta<typeof StoryComponent>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { PropsWithChildren } from 'react'
import styles from './LinkText.module.css'

type Props = PropsWithChildren & {
href: string
}

export const LinkText = ({ children, ...props }: Props) => {
return (
<a {...props} className={styles.link} href={props.href}>
{children}
</a>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LinkText'
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from './PostCategories'
export * from './PostTags'
export * from './PostWriter'
export * from './OrderList'
export * from './LinkText'

export * from './PostDetailPage'
export * from './PostListPage'
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Code,
Heading,
LinkCard,
LinkText,
OrderList,
} from '@/features/posts'
import type { MDXComponents } from 'mdx/types'
Expand Down Expand Up @@ -52,6 +53,13 @@ const mdxComponents: MDXComponents = {
ol: ({ children, ...props }) => {
return <OrderList {...props}>{children}</OrderList>
},
a: ({ children, href = '#', ...props }) => {
return (
<LinkText href={href} {...props}>
{children}
</LinkText>
)
},
}

type Props = {
Expand Down

0 comments on commit 34f1a1b

Please sign in to comment.