// // Copyright 2022 DXOS.org // import '@dxos-theme'; import React, { type PropsWithChildren } from 'react'; import { type HuePalette } from '@dxos/react-ui-theme'; import { type Size } from '@dxos/react-ui-types'; import { hexToFallback } from '@dxos/util'; import { Avatar, type AvatarVariant, type AvatarStatus, type AvatarAnimation } from './Avatar'; import { withTheme } from '../../testing'; type StoryProps = { id?: string; imgSrc?: string; fallbackText?: string; label?: string; description?: string; status?: AvatarStatus; variant?: AvatarVariant; animation?: AvatarAnimation; size?: Size; hue?: HuePalette; }; const DefaultStory = (props: PropsWithChildren) => { 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})
); }; export default { title: 'ui/react-ui-core/Avatar', component: Avatar, render: DefaultStory, decorators: [withTheme], parameters: { chromatic: { disableSnapshot: false } }, }; const sampleImage = 'https://png.pngtree.com/thumb_back/fh260/background/20230614/pngtree-the-photo-of-a-woman-with-red-sunglasses-is-surrounded-by-image_2931163.jpg'; 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 Square = () => (
); export const DefaultEmoji = () => (
); export const SquareEmoji = () => ; export const DefaultText = () => (
); export const Error = () => ; export const Pulse = () => (
);