-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load all messages for explorer assistant response, app conversation d…
…isplay, and transcript export; plus overflow support for assistant canvas (#228)
- Loading branch information
Showing
19 changed files
with
702 additions
and
449 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { | ||
Button, | ||
makeStyles, | ||
Menu, | ||
MenuItem, | ||
MenuList, | ||
MenuPopover, | ||
MenuTrigger, | ||
Slot, | ||
tokens, | ||
useIsOverflowItemVisible, | ||
useOverflowMenu, | ||
} from '@fluentui/react-components'; | ||
import { MoreHorizontalRegular } from '@fluentui/react-icons'; | ||
import React from 'react'; | ||
|
||
const useClasses = makeStyles({ | ||
menu: { | ||
backgroundColor: tokens.colorNeutralBackground1, | ||
}, | ||
menuButton: { | ||
alignSelf: 'center', | ||
}, | ||
}); | ||
|
||
export interface OverflowMenuItemData { | ||
id: string; | ||
icon?: Slot<'span'>; | ||
name?: string; | ||
} | ||
|
||
interface OverflowMenuItemProps { | ||
item: OverflowMenuItemData; | ||
onClick: (event: React.MouseEvent, id: string) => void; | ||
} | ||
|
||
export const OverflowMenuItem: React.FC<OverflowMenuItemProps> = (props) => { | ||
const { item, onClick } = props; | ||
const isVisible = useIsOverflowItemVisible(item.id); | ||
|
||
if (isVisible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<MenuItem key={item.id} icon={item.icon} onClick={(event) => onClick(event, item.id)}> | ||
{item.name} | ||
</MenuItem> | ||
); | ||
}; | ||
|
||
interface OverflowMenuProps { | ||
items: OverflowMenuItemData[]; | ||
onItemSelect: (id: string) => void; | ||
} | ||
|
||
export const OverflowMenu: React.FC<OverflowMenuProps> = (props) => { | ||
const { items, onItemSelect } = props; | ||
const classes = useClasses(); | ||
const { ref, isOverflowing, overflowCount } = useOverflowMenu<HTMLButtonElement>(); | ||
|
||
const handleItemClick = (_event: React.MouseEvent, id: string) => { | ||
onItemSelect(id); | ||
}; | ||
|
||
if (!isOverflowing) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Menu hasIcons={items.find((item) => item.icon !== undefined) !== undefined}> | ||
<MenuTrigger disableButtonEnhancement> | ||
<Button | ||
className={classes.menuButton} | ||
appearance="transparent" | ||
ref={ref} | ||
icon={<MoreHorizontalRegular />} | ||
aria-label={`${overflowCount} more options`} | ||
role="tab" | ||
/> | ||
</MenuTrigger> | ||
<MenuPopover> | ||
<MenuList className={classes.menu}> | ||
{items.map((item) => ( | ||
<OverflowMenuItem key={item.id} item={item} onClick={handleItemClick}></OverflowMenuItem> | ||
))} | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
); | ||
}; |
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.