Skip to content

Commit

Permalink
Add another example
Browse files Browse the repository at this point in the history
  • Loading branch information
maximedegreve committed Dec 1, 2023
1 parent 294cd04 commit b0ecc7f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/ActionList/ActionList.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export const SingleSelect = () => {
)
}

export const MultiSelect = () => {
export const MenuMultiSelect = () => {
const [selectedIndices, setSelectedIndices] = React.useState<number[]>([0])
const handleSelect = (index: number) => {
if (selectedIndices.includes(index)) {
Expand Down Expand Up @@ -300,6 +300,37 @@ export const MultiSelect = () => {
)
}

export const ListBoxMultiSelect = () => {
const [selectedIndices, setSelectedIndices] = React.useState<number[]>([0])
const handleSelect = (index: number) => {
if (selectedIndices.includes(index)) {
setSelectedIndices(selectedIndices.filter(i => i !== index))
} else {
setSelectedIndices([...selectedIndices, index])
}
}
return (
<ActionList selectionVariant="multiple" aria-label="Project">
{projects.map((project, index) => (
<ActionList.Item
key={index}
role="menuitemcheckbox"
selected={selectedIndices.includes(index)}
aria-checked={selectedIndices.includes(index)}
onSelect={() => handleSelect(index)}
disabled={index === 3 ? true : undefined}
>
<ActionList.LeadingVisual>
<TableIcon />
</ActionList.LeadingVisual>
{project.name}
<ActionList.Description variant="block">{project.scope}</ActionList.Description>
</ActionList.Item>
))}
</ActionList>
)
}

export const DisabledSelectedMultiselect = () => (
<ActionList selectionVariant="multiple" role="menu" aria-label="Project">
<ActionList.Item role="menuitemcheckbox" selected aria-checked disabled>
Expand Down

0 comments on commit b0ecc7f

Please sign in to comment.