-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fae2dc
commit a04fe77
Showing
21 changed files
with
205 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 35 additions & 65 deletions
100
src/components/TreeList/__stories__/TreeList.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,58 @@ | ||
import React from 'react'; | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
|
||
import type {Meta, StoryFn} from '@storybook/react'; | ||
|
||
import {Flex} from '../../layout'; | ||
import {createRandomizedData} from '../../useList/__stories__/utils/makeData'; | ||
import {TreeList} from '../TreeList'; | ||
import type {TreeListProps} from '../types'; | ||
|
||
import {InfinityScrollExample} from './components/InfinityScrollExample'; | ||
import type {InfinityScrollExampleProps} from './components/InfinityScrollExample'; | ||
import {WithDndListExample} from './components/WithDndListExample'; | ||
import type {WithDndListExampleProps} from './components/WithDndListExample'; | ||
import {WithFiltrationAndControlsExample} from './components/WithFiltrationAndControlsExample'; | ||
import type {WithFiltrationAndControlsExampleProps} from './components/WithFiltrationAndControlsExample'; | ||
import {WithGroupSelectionControlledStateAndCustomIconExample} from './components/WithGroupSelectionControlledStateAndCustomIcon'; | ||
import type {WithGroupSelectionControlledStateAndCustomIconExampleProps} from './components/WithGroupSelectionControlledStateAndCustomIcon'; | ||
import {WithItemLinksAndActionsExample} from './components/WithItemLinksAndActionsExample'; | ||
import type {WithItemLinksAndActionsExampleProps} from './components/WithItemLinksAndActionsExample'; | ||
import {DefaultStory} from './stories/DefaultStory'; | ||
import {InfinityScrollStory} from './stories/InfinityScrollStory'; | ||
import {WithDndListStory} from './stories/WithDndListStory'; | ||
import {WithFiltrationAndControlsStory} from './stories/WithFiltrationAndControlsStory'; | ||
import {WithGroupSelectionAndCustomIconStory} from './stories/WithGroupSelectionAndCustomIconStory'; | ||
import {WithItemLinksAndActionsStory} from './stories/WithItemLinksAndActionsStory'; | ||
|
||
export default { | ||
title: 'Unstable/TreeList', | ||
component: TreeList, | ||
} as Meta; | ||
|
||
const DefaultTemplate: StoryFn< | ||
Omit<TreeListProps<{title: string}>, 'value' | 'onUpdate' | 'items' | 'getItemContent'> & { | ||
itemsCount?: number; | ||
} | ||
> = ({itemsCount = 5, ...props}) => { | ||
const items = React.useMemo(() => createRandomizedData({num: itemsCount}), [itemsCount]); | ||
type DefaultStoryObj = StoryObj<typeof DefaultStory>; | ||
|
||
return ( | ||
<Flex width="500"> | ||
<TreeList {...props} items={items} /> | ||
</Flex> | ||
); | ||
}; | ||
export const Default = DefaultTemplate.bind({}); | ||
Default.args = { | ||
size: 'm', | ||
export const Default: DefaultStoryObj = { | ||
render: DefaultStory, | ||
}; | ||
|
||
const WithGroupSelectionControlledStateAndCustomIconTemplate: StoryFn< | ||
WithGroupSelectionControlledStateAndCustomIconExampleProps | ||
> = (props) => { | ||
return <WithGroupSelectionControlledStateAndCustomIconExample {...props} />; | ||
type InfinityScrollStoryObj = StoryObj<typeof InfinityScrollStory>; | ||
|
||
export const InfinityScroll: InfinityScrollStoryObj = { | ||
render: InfinityScrollStory, | ||
}; | ||
|
||
export const WithGroupSelectionControlledStateAndCustomIcon = | ||
WithGroupSelectionControlledStateAndCustomIconTemplate.bind({}); | ||
WithGroupSelectionControlledStateAndCustomIcon.args = {}; | ||
type WithDndListStoryObj = StoryObj<typeof WithDndListStory>; | ||
|
||
const InfinityScrollTemplate: StoryFn<InfinityScrollExampleProps> = (props) => { | ||
return <InfinityScrollExample {...props} />; | ||
export const WithDndList: WithDndListStoryObj = { | ||
parameters: { | ||
// Strict mode ruins sortable list due to this react-beautiful-dnd issue | ||
// https://github.com/atlassian/react-beautiful-dnd/issues/2350 | ||
disableStrictMode: true, | ||
}, | ||
render: WithDndListStory, | ||
}; | ||
export const InfinityScroll = InfinityScrollTemplate.bind({}); | ||
InfinityScroll.args = {}; | ||
|
||
const WithFiltrationAndControlsTemplate: StoryFn<WithFiltrationAndControlsExampleProps> = ( | ||
props, | ||
) => { | ||
return <WithFiltrationAndControlsExample {...props} />; | ||
}; | ||
export const WithFiltrationAndControls = WithFiltrationAndControlsTemplate.bind({}); | ||
WithFiltrationAndControls.args = { | ||
size: 'l', | ||
}; | ||
type WithFiltrationAndControlsStoryObj = StoryObj<typeof WithFiltrationAndControlsStory>; | ||
|
||
const WithItemLinksAndActionsTemplate: StoryFn<WithItemLinksAndActionsExampleProps> = (props) => { | ||
return <WithItemLinksAndActionsExample {...props} />; | ||
export const WithFiltrationAndControls: WithFiltrationAndControlsStoryObj = { | ||
render: WithFiltrationAndControlsStory, | ||
}; | ||
export const WithItemLinksAndActions = WithItemLinksAndActionsTemplate.bind({}); | ||
WithItemLinksAndActions.args = {}; | ||
|
||
const WithDndListTemplate: StoryFn<WithDndListExampleProps> = (props) => { | ||
return <WithDndListExample {...props} />; | ||
}; | ||
export const WithDndList = WithDndListTemplate.bind({}); | ||
type WithGroupSelectionAndCustomIconStoryObj = StoryObj< | ||
typeof WithGroupSelectionAndCustomIconStory | ||
>; | ||
|
||
WithDndList.args = { | ||
size: 'l', | ||
export const WithGroupSelectionAndCustomIcon: WithGroupSelectionAndCustomIconStoryObj = { | ||
render: WithGroupSelectionAndCustomIconStory, | ||
}; | ||
WithDndList.parameters = { | ||
// Strict mode ruins sortable list due to this react-beautiful-dnd issue | ||
// https://github.com/atlassian/react-beautiful-dnd/issues/2350 | ||
disableStrictMode: true, | ||
|
||
type WithItemLinksAndActionsStoryObj = StoryObj<typeof WithItemLinksAndActionsStory>; | ||
|
||
export const WithItemLinksAndActions: WithItemLinksAndActionsStoryObj = { | ||
render: WithItemLinksAndActionsStory, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/components/TreeList/__stories__/stories/DefaultStory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
|
||
import {Flex} from '../../../layout'; | ||
import {createRandomizedData} from '../../../useList/__stories__/utils/makeData'; | ||
import {TreeList} from '../../TreeList'; | ||
import type {TreeListProps} from '../../types'; | ||
|
||
function identity<T>(value: T): T { | ||
return value; | ||
} | ||
|
||
export interface DefaultStoryProps | ||
extends Omit<TreeListProps<{title: string}>, 'items' | 'getItemContent'> { | ||
itemsCount?: number; | ||
} | ||
|
||
export const DefaultStory = ({itemsCount = 5, ...props}: DefaultStoryProps) => { | ||
const items = React.useMemo(() => createRandomizedData({num: itemsCount}), [itemsCount]); | ||
|
||
return ( | ||
<Flex width="500"> | ||
<TreeList {...props} items={items} getItemContent={identity} /> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.