-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Showing
2 changed files
with
74 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Meta, StoryFn, StoryObj } from '@storybook/react' | ||
import { range } from 'lib/utils' | ||
|
||
import { Playlist, PlaylistProps } from './Playlist' | ||
|
||
type Story = StoryObj<typeof Playlist> | ||
const meta: Meta<typeof Playlist> = { | ||
title: 'Components/Playlist', | ||
component: Playlist, | ||
} | ||
export default meta | ||
|
||
const ListItem = ({ item }): JSX.Element => <div className="p-1">Object {item.id}</div> | ||
|
||
const Template: StoryFn<typeof Playlist> = (props: Partial<PlaylistProps>) => { | ||
const mainContent = ({ activeItem }): JSX.Element => ( | ||
<div className="flex items-center justify-center h-full"> | ||
{activeItem ? `Object ${activeItem.id} selected` : 'Select an item from the list'} | ||
</div> | ||
) | ||
|
||
return ( | ||
<div className="h-96"> | ||
<Playlist | ||
title="Title" | ||
sections={[]} | ||
listEmptyState={<div>No items</div>} | ||
content={mainContent} | ||
{...props} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export const Default: Story = Template.bind({}) | ||
Default.args = { | ||
sections: [ | ||
{ | ||
key: 'default', | ||
title: `Default section`, | ||
items: range(0, 100).map((idx) => ({ id: idx })), | ||
render: ListItem, | ||
}, | ||
], | ||
} | ||
|
||
export const MultipleSections: Story = Template.bind({}) | ||
MultipleSections.args = { | ||
sections: [ | ||
{ | ||
key: 'one', | ||
title: 'First section', | ||
items: range(0, 5).map((idx) => ({ id: idx })), | ||
render: ListItem, | ||
}, | ||
{ | ||
key: 'two', | ||
title: 'Second section', | ||
items: range(0, 5).map((idx) => ({ id: idx })), | ||
render: ListItem, | ||
}, | ||
], | ||
} |
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