import type { Meta, StoryObj } from '@storybook/react-vite'; import { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount } from './avatar'; const meta = { title: 'Components/Avatar', component: Avatar, parameters: { layout: 'centered', docs: { description: { component: 'User or entity image with a text fallback. The fallback appears only once the image fails or is still loading, so initials never flash over a photo that loaded fine.', }, }, }, tags: ['autodocs'], argTypes: { size: { control: 'select', options: ['2xs', 'xs', 'sm', 'md', 'lg', 'xl'] }, variant: { control: 'inline-radio', options: ['solid', 'subtle', 'outline'] }, shape: { control: 'inline-radio', options: ['circle', 'square'] }, colorPalette: { control: 'select', options: ['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'], }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { render: (args) => ( JS ), }; export const Sizes: Story = { render: () => (
{(['2xs', 'xs', 'sm', 'md', 'lg', 'xl'] as const).map((size) => ( {size} ))}
), }; /** Three treatments, each available in any palette. */ export const Variants: Story = { render: () => (
{(['solid', 'subtle', 'outline'] as const).map((variant) => (
{(['primary', 'secondary', 'tertiary', 'black', 'red', 'green'] as const).map((palette) => ( {palette.slice(0, 2)} ))}
))}
), }; /** CBAR draws avatars round by default, with a squared-off alternative. */ export const Shapes: Story = { render: () => (
CI SQ
), }; /** A presence dot pinned to the corner. It scales with the avatar size. */ export const WithBadge: Story = { render: () => ( JS ), }; export const Group: Story = { render: () => ( {['AB', 'CD', 'EF'].map((initials) => ( {initials} ))} +7 ), };