Skip to content

feat: add dynamic list react component #6043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions packages/react/src/DynamicList/DynamicList.dev.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import {DynamicList} from '../DynamicList'
import classes from './story.module.css'

export default {
title: 'Components/DynamicList/Dev',
component: DynamicList,
}

export const Default = () => {
return (
<DynamicList

Check failure on line 11 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
className={classes.Story}
items={Array.from({length: 20}).map((_, i) => `Item ${i}`)}
renderItem={({item}) => <li className="item">{item}</li>}

Check failure on line 14 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
renderTrigger={({buttonRef}) => (
<button type="button" popovertarget="overflow" ref={buttonRef}>

Check failure on line 16 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

Unknown property 'popovertarget' found

Check failure on line 16 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
...
</button>
)}
renderOverflow={({items}) => (
<ul id="overflow" popover="">

Check failure on line 21 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

Unknown property 'popover' found

Check failure on line 21 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
{items.map(item => {
return <li key={item}>{item}</li>

Check failure on line 23 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
})}
</ul>
)}
/>
)
}

export const WithBetweenPlacement = () => {
return (
<DynamicList

Check failure on line 33 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
className={classes.Story}
items={Array.from({length: 20}).map((_, i) => `Item ${i}`)}
renderItem={({item}) => <li className="item">{item}</li>}

Check failure on line 36 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
renderTrigger={({buttonRef}) => (
<button type="button" popovertarget="overflow" ref={buttonRef}>

Check failure on line 38 in packages/react/src/DynamicList/DynamicList.dev.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'React' must be in scope when using JSX
...
</button>
)}
renderOverflow={({items}) => (
<ul id="overflow" popover="">
{items.map(item => {
return <li key={item}>{item}</li>
})}
</ul>
)}
triggerPlacement="between"
/>
)
}

export const WithLeadingPlacement = () => {
return (
<DynamicList
className={classes.Story}
items={Array.from({length: 20}).map((_, i) => `Item ${i}`)}
renderItem={({item}) => <li className="item">{item}</li>}
renderTrigger={({buttonRef}) => (
<button type="button" popovertarget="overflow" ref={buttonRef}>
...
</button>
)}
renderOverflow={({items}) => (
<ul id="overflow" popover="">
{items.map(item => {
return <li key={item}>{item}</li>
})}
</ul>
)}
triggerPlacement="leading"
/>
)
}

export const WithTrailingPlacement = () => {
return (
<DynamicList
className={classes.Story}
items={Array.from({length: 20}).map((_, i) => `Item ${i}`)}
renderItem={({item}) => <li className="item">{item}</li>}
renderTrigger={({buttonRef}) => (
<button type="button" popovertarget="overflow" ref={buttonRef}>
...
</button>
)}
renderOverflow={({items}) => (
<ul id="overflow" popover="">
{items.map(item => {
return <li key={item}>{item}</li>
})}
</ul>
)}
triggerPlacement="trailing"
/>
)
}

export const WithMaxVisibleItems = () => {
return (
<DynamicList
className={classes.Story}
items={Array.from({length: 20}).map((_, i) => `Item ${i}`)}
maxVisibleItems={5}
renderItem={({item}) => <li className="item">{item}</li>}
renderTrigger={({buttonRef}) => (
<button type="button" popovertarget="overflow" ref={buttonRef}>
...
</button>
)}
renderOverflow={({items}) => (
<ul id="overflow" popover="">
{items.map(item => {
return <li key={item}>{item}</li>
})}
</ul>
)}
triggerPlacement="between"
/>
)
}
11 changes: 11 additions & 0 deletions packages/react/src/DynamicList/DynamicList.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DynamicList {
display: flex;
width: 100%;
max-width: 100%;
flex: 0 1 100%;
white-space: nowrap;
padding: 0;
list-style: none;
overflow: hidden;
margin: 0;
}
Loading
Loading