import React from "react"; import { useCallback, useState } from "react"; import { StoryDescription } from "vibe-storybook-components"; import { Meta, StoryObj } from "@storybook/react"; import { createStoryMetaSettingsDecorator } from "../../../storybook"; import { person1, person2, person3, person4 } from "./assets"; import AvatarGroup from "../AvatarGroup"; import { AvatarGroupProps } from "../AvatarGroup"; import Avatar from "../../Avatar/Avatar"; import Counter from "../../Counter/Counter"; import Flex from "../../Flex/Flex"; import Slider from "../../Slider/Slider"; import Tooltip from "../../Tooltip/Tooltip"; import Table from "../../Table/Table/Table"; import TableHeader from "../../Table/TableHeader/TableHeader"; import TableHeaderCell from "../../Table/TableHeaderCell/TableHeaderCell"; import TableBody from "../../Table/TableBody/TableBody"; import TableRow from "../../Table/TableRow/TableRow"; import TableCell from "../../Table/TableCell/TableCell"; import styles from "./AvatarGroup.stories.module.scss"; const metaSettings = createStoryMetaSettingsDecorator({ component: AvatarGroup, enumPropNamesArray: ["type", "size"] // List enum props here }); export default { title: "Media/Avatar/AvatarGroup", component: AvatarGroup, argTypes: metaSettings.argTypes, decorators: metaSettings.decorators, parameters: { docs: { liveEdit: { scope: { styles, StoryDescription, person1, person2, person3 } } } } } satisfies Meta; type Story = StoryObj; interface AvatarGroupTemplateProps extends AvatarGroupProps { persons: Record<`person${1 | 2 | 3 | 4}`, string>; } const avatarGroupTemplate = ({ persons, ...args }: AvatarGroupTemplateProps) => { return ( ); }; export const Overview: StoryObj = { render: avatarGroupTemplate.bind({}), args: { persons: { person1: window.location.origin + "/" + person1, person2: window.location.origin + "/" + person2, person3: window.location.origin + "/" + person3, person4: window.location.origin + "/" + person4 } }, parameters: { docs: { liveEdit: { isEnabled: false } } } }; export const Size: Story = { render: () => ( ) }; export const ColorVariants: Story = { render: () => ( ) }; export const MaxAvatarsToDisplay: Story = { render: () => { const [max, setMax] = useState(4); return ( setMax(value)} valueText={`${max}`} /> ); } }; export const HoverVsClickable: Story = { render: () => { const getDummyAvatarsProps = useCallback((numItems: number) => { const avatarsProps = [ { type: Avatar.types.IMG, src: person1, ariaLabel: "Julia Martinez" }, { type: Avatar.types.IMG, src: person2, ariaLabel: "Sophia Johnson" }, { type: Avatar.types.IMG, src: person3, ariaLabel: "Marco DiAngelo" }, { type: Avatar.types.IMG, src: person4, ariaLabel: "Liam Caldwell" } ]; const result = []; for (let i = 0; i < numItems; i++) { result.push(avatarsProps[i % avatarsProps.length]); } return result; }, []); return ( {getDummyAvatarsProps(14).map(avatarProps => ( ))} {getDummyAvatarsProps(14).map((avatarProps, index) => ( {}} id={String(index)} /> ))} ); } }; export const Disabled = () => ( ); export const LastSeenUsers: Story = { render: () => (
Last seen
) }; export const CustomCounter: Story = { render: () => ( ) }; export const GridTooltip: Story = { render: () => ( ) }; export const CounterCustomTooltipContent: Story = { render: () => ( ) }; export const VirtualizedList: Story = { render: () => { const avatars = [ , , , ]; const getDummyAvatars = (multiplier: number) => { let result: typeof avatars = []; for (let i = 0; i < multiplier; ++i) { result = result.concat(avatars); } return result; }; return ( {getDummyAvatars(334)} ); } }; export const DisplayingTeams: Story = { render: () => ( } emptyState={
} > Julia Martinez julia@martinez.com Developer
) };