From f35fa077040608302f2766aa97148f7250188386 Mon Sep 17 00:00:00 2001 From: DenisVorop Date: Fri, 18 Aug 2023 13:05:10 +0300 Subject: [PATCH] chore: add more examples for CollapsableItem story --- src/stories/CollapsableItem.stories.tsx | 80 ++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/src/stories/CollapsableItem.stories.tsx b/src/stories/CollapsableItem.stories.tsx index b31a4339..6ec23448 100644 --- a/src/stories/CollapsableItem.stories.tsx +++ b/src/stories/CollapsableItem.stories.tsx @@ -1,7 +1,19 @@ import React, { ComponentPropsWithoutRef, useState } from 'react'; import { Meta, StoryFn } from '@storybook/react'; -import { CollapsableItem, CollapsableContentItem, Text } from '../components'; +import { + CollapsableItem, + CollapsableContentItem, + Text, + Table, + TableRow, + TableCell, + GoalIcon, + UserPic, + Dot, + Tag, + CircleProgressBar, +} from '../components'; const meta: Meta = { title: 'CollapsableItem', @@ -15,16 +27,46 @@ type ItemProps = Omit, 'onClick const Item = ({ header, ...restProps }: ItemProps) => { const [isOpen, setIsOpen] = useState(false); + + const handleOpen = () => { + setTimeout( + () => { + setIsOpen((prev) => !prev); + }, + Math.random() > 0.5 ? 300 : 0, + ); + }; + return ( {header}} - onClick={restProps.children ? () => setIsOpen((prev) => !prev) : undefined} + onClick={restProps.children ? () => handleOpen() : undefined} {...restProps} /> ); }; +const data = Array.from({ length: 4 }, (_, i) => ({ + title: `Title ${i + 1}`, + projectId: (Math.random() * 10).toString(16).slice(2, 8).padEnd(6, 'AB').toUpperCase(), + tags: Array.from({ length: Math.ceil(Math.random() * 5) }, (_, i) => `Tag ${i + 1}`), + progress: Math.round(Math.random() * 100), + children: Array.from({ length: 3 }, (_, i) => ({ + title: `Title ${i + 1}`, + projectId: (Math.random() * 10).toString(16).slice(2, 8).padEnd(6, 'AB').toUpperCase(), + tags: Array.from({ length: Math.ceil(Math.random() * 5) }, (_, i) => `Tag ${i + 1}`), + progress: Math.round(Math.random() * 100), + children: Array.from({ length: 3 }, (_, i) => ({ + title: `Title ${i + 1}`, + projectId: (Math.random() * 10).toString(16).slice(2, 8).padEnd(6, 'AB').toUpperCase(), + tags: Array.from({ length: Math.ceil(Math.random() * 5) }, (_, i) => `Tag ${i + 1}`), + progress: Math.round(Math.random() * 100), + children: undefined, + })), + })), +})); + export const Default: Story = () => { return ( @@ -44,7 +86,39 @@ export const Default: Story = () => { - + + + {data.map(({ title, projectId, tags, progress }) => ( + + + + + + + + {title} + + + + + + + + {projectId} + + + + {tags.map((t) => ( + + ))} + + + + + + ))} +
+