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 { Button, type ButtonSizes, type ButtonVariants } from '../index'
export default {
title: 'Components/Button',
parameters: {
chromatic: { disable: false },
controls: { disable: true },
},
} satisfies Meta
const variants = ['primary', 'secondary', 'tertiary'] satisfies ButtonVariants[]
const sizes = ['small', 'medium', 'large'] satisfies ButtonSizes[]
const StickerSheetTemplate: StickerSheetStory = {
render: ({ isReversed }) => (
<>
{variants.map((variant) =>
sizes.map((size) => (
} variant={variant} size={size}>
Label
}
iconPosition="end"
variant={variant}
size={size}
>
Label
}
iconPosition="end"
variant={variant}
isPending
pendingLabel="Submitting"
size={size}
>
Label
}
iconPosition="end"
variant={variant}
isPending
pendingLabel="Submitting"
hasHiddenPendingLabel
size={size}
>
Label
}
iconPosition="end"
variant={variant}
size={size}
isDisabled
>
Label
)),
)}
{sizes.map((size) => (
{variants.map((variant) => (
}
hasHiddenLabel
size={size}
variant={variant}
>
Label
}
size={size}
isPending
hasHiddenLabel
pendingLabel="Submitting"
variant={variant}
>
Label
))}
))}
{variants.map((variant) => (
))}
>
),
play: ({ canvasElement }) => {
const canvas = within(canvasElement)
const focusButtons = canvas.getAllByTestId('testid__button-focus')
const hoverButtons = canvas.getAllByTestId('testid__button-hover')
const pressedButton = canvas.getAllByTestId('testid__button-pressed')
focusButtons.forEach((button) => {
button.setAttribute('data-focus-visible', 'true')
})
hoverButtons.forEach((button) => {
button.setAttribute('data-hovered', 'true')
})
pressedButton.forEach((button) => {
button.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 StickerSheetReversed: StickerSheetStory = {
...StickerSheetTemplate,
name: 'Sticker Sheet (Reversed)',
parameters: {
reverseColors: true,
},
args: {
isReversed: true,
},
}