import React from 'react' import { type Meta } from '@storybook/react' import { within } from '@storybook/test' import { Icon } from '~components/Icon' import { StickerSheet, type StickerSheetStory } from '~storybook/components/StickerSheet' import { Link, type LinkProps } from '../Link' export default { title: 'Components/Link', component: Link, parameters: { chromatic: { disable: false }, controls: { disable: true }, }, } satisfies Meta const variants = ['primary', 'secondary'] satisfies LinkProps['variant'][] const sizes = ['extra-small', 'small', 'body', 'intro-lede'] satisfies LinkProps['size'][] const href = 'https://www.google.com' satisfies LinkProps['href'] const StickerSheetTemplate: StickerSheetStory = { render: ({ isReversed }) => ( <> {variants.map((variant) => sizes.map((size) => ( Link } iconPosition="start" > Link } iconPosition="end" > Link } iconPosition="start" > Link } iconPosition="end" > Link Link )), )} {variants.map((variant) => ( } data-testid="testid__link-hover" > Label } data-testid="testid__link-focus" > Label } data-testid="testid__link-pressed" > Label ))} ), play: ({ canvasElement }) => { const canvas = within(canvasElement) const focusLinks = canvas.getAllByTestId('testid__link-focus') const hoverLinks = canvas.getAllByTestId('testid__link-hover') const pressedLinks = canvas.getAllByTestId('testid__link-pressed') focusLinks.forEach((Link) => { Link.setAttribute('data-focus-visible', 'true') }) hoverLinks.forEach((Link) => { Link.setAttribute('data-hovered', 'true') }) pressedLinks.forEach((Link) => { Link.setAttribute('data-pressed', 'true') }) }, } export const StickerSheetDefault: StickerSheetStory = { ...StickerSheetTemplate, name: 'Sticker Sheet (Default)', } export const StickerSheetRTL: StickerSheetStory = { ...StickerSheetTemplate, name: 'Sticker Sheet (RTL)', parameters: { textDirection: 'rtl', }, } export const StickerSheetWhite: StickerSheetStory = { ...StickerSheetTemplate, name: 'Sticker Sheet (White)', parameters: { reverseColors: true, }, args: { isReversed: true, }, }