// // Copyright 2022 DXOS.org // import { type Meta } from '@storybook/react-vite'; import React, { type PropsWithChildren } from 'react'; import { type ChromaticPalette, type Size } from '@dxos/ui-types'; import { hexToFallback } from '@dxos/util'; import { withTheme } from '../../testing'; import { Avatar, type AvatarAnimation, type AvatarStatus, type AvatarVariant } from './Avatar'; type StoryArgs = PropsWithChildren<{ id?: string; imgSrc?: string; fallbackText?: string; label?: string; description?: string; status?: AvatarStatus; variant?: AvatarVariant; animation?: AvatarAnimation; size?: Size; hue?: ChromaticPalette; }>; const DefaultStory = (props: StoryArgs) => { const { id = '20970b563fc49b5bb194a6ffdff376031a3a11f9481360c071c3fed87874106b', status, size = 12, variant = 'circle', label = 'Alice', description = 'Online', fallbackText = '', animation, imgSrc, } = props; const { emoji, hue } = hexToFallback(id); return (
{label} {description} ({size})
); }; const meta = { title: 'ui/react-ui-core/components/Avatar', component: Avatar.Root, decorators: [withTheme()], } satisfies Meta; export default meta; const sampleImage = 'https://png.pngtree.com/thumb_back/fh260/background/20230614/pngtree-the-photo-of-a-woman-with-red-sunglasses-w-surrounded-by-image_2931163.jpg'; const brokenImage = 'https://png.pngtree.com/potato_squirrel.png'; const row = (size: Size) => ( <> ); export const Default = () => (
{row(28)} {row(20)} {row(16)} {row(12)} {row(10)} {row(8)} {row(6)} {row(5)} {row(4)} {row(3)} {row(2)} {row(1)}
); export const Image = () => (
); export const BrokenImage = () => (
); export const Square = () => (
); export const DefaultEmoji = () => (
); export const SquareEmoji = () => ; export const DefaultText = () => (
); export const Error = () => ; export const Pulse = () => (
);