-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-bar): Add configuration option for maximum visible buttons (
#2156) Fixes: #2155 This allows for more flexible designs using the action bar. The maximum number of visible buttons is now configurable allowing anywhere from 1 -> items.length to be show if there is space. I didn't see any tests for action bar so I added some visual testing rows. Let me know if you want anything else. [category:Components] Co-authored-by: @RayRedGoose <48605821+RayRedGoose@users.noreply.github.com>
- Loading branch information
1 parent
4e8110a
commit e30a281
Showing
6 changed files
with
139 additions
and
24 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 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
40 changes: 40 additions & 0 deletions
40
modules/react/action-bar/stories/examples/OverflowActionBarCustomButtonCount.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,40 @@ | ||
import React from 'react'; | ||
import {ActionBar} from '@workday/canvas-kit-react/action-bar'; | ||
|
||
type MyActionItem = { | ||
id: string; | ||
text: React.ReactNode; | ||
}; | ||
|
||
export const OverflowActionBarCustomButtonCount = () => { | ||
const [items] = React.useState<MyActionItem[]>([ | ||
{id: 'view', text: 'View'}, | ||
{id: 'edit', text: 'Edit'}, | ||
{id: 'delete', text: 'Delete'}, | ||
]); | ||
|
||
return ( | ||
<ActionBar items={items} maximumVisible={2}> | ||
<ActionBar.List | ||
aria-label="actions" | ||
position="relative" | ||
overflowButton={<ActionBar.OverflowButton aria-label="More actions" />} | ||
> | ||
{(item: MyActionItem) => ( | ||
<ActionBar.Item onClick={() => console.log(item.id)}>{item.text}</ActionBar.Item> | ||
)} | ||
</ActionBar.List> | ||
<ActionBar.Menu.Popper> | ||
<ActionBar.Menu.Card> | ||
<ActionBar.Menu.List> | ||
{(item: MyActionItem) => ( | ||
<ActionBar.Menu.Item onClick={() => console.log(item.id)}> | ||
{item.text} | ||
</ActionBar.Menu.Item> | ||
)} | ||
</ActionBar.Menu.List> | ||
</ActionBar.Menu.Card> | ||
</ActionBar.Menu.Popper> | ||
</ActionBar> | ||
); | ||
}; |
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