import type { Meta, StoryObj } from '@storybook/react' import { TextLink, TextLinkArrow } from './TextLink' /** Mock Next.js Link for illustrative purposes */ const NextLink = ({ children, className, ...props }: React.AnchorHTMLAttributes) => ( {children} ) const meta = { title: 'Navigation/TextLink', component: TextLink, argTypes: { href: { description: 'The URL the link points to.', control: 'text', table: { type: { summary: 'string' }, }, }, arrow: { description: 'Adds an arrow icon to the link.', control: { type: 'select' }, options: [undefined, 'left', 'right', 'external'], table: { type: { summary: "'left' | 'right' | 'external'" }, defaultValue: { summary: 'undefined' }, }, }, external: { description: 'When true, adds rel="noopener noreferrer" for security. Use for links to external sites.', control: 'boolean', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, newTab: { description: 'When true, opens the link in a new tab (target="_blank").', control: 'boolean', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, asChild: { description: 'When true, uses Radix Slot to merge props with child element. Mutually exclusive with renderLink.', control: 'boolean', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, children: { description: 'The content of the link.', control: 'text', table: { type: { summary: 'React.ReactNode' }, }, }, }, args: { href: '/example', children: 'Click me', arrow: undefined, external: false, newTab: false, }, } satisfies Meta export default meta type Story = StoryObj export const Default: Story = { render: (_args) => Dashboard, } export const WithArrow: Story = { parameters: { docs: { description: { story: 'Shows the built-in arrow variants for backward navigation, forward navigation, and external destinations.', }, }, }, render: (_args) => (
Left arrow Right arrow External arrow
), } export const ExternalWithArrow: Story = { render: (_args) => ( Chainlink ), } export const WithAsChild: Story = { parameters: { docs: { description: { story: 'Use `asChild` to preserve TextLink styling and arrow behavior while delegating the underlying anchor element to another router link component.', }, }, }, render: (_args) => (
Internal link with Right Arrow
), } export const WithCustomArrowColor: Story = { parameters: { docs: { description: { story: 'Use `TextLinkArrow` when the arrow needs different styling from the surrounding link text.', }, }, }, render: (args) => ( Visit Chainlink ), } export const WithCustomColor: Story = { render: (_args) => ( Visit Chainlink ), args: { href: 'https://chain.link', children: 'Visit Chainlink', external: true, newTab: true, arrow: undefined, }, } export const WithRenderLink: Story = { parameters: { docs: { description: { story: 'Use `renderLink` when a routing library needs to own the rendered anchor element without switching to `asChild` composition.', }, }, }, render: (_args) => ( <>
} > Dashboard with renderLink
} > Dashboard with renderLink
), }