element-call/src/room/OverflowMenu.jsx

78 lines
2.3 KiB
React
Raw Normal View History

2021-12-04 00:42:29 +00:00
import React, { useCallback } from "react";
2022-01-06 00:55:41 +00:00
import { Button } from "../button";
import { Menu } from "../Menu";
import { PopoverMenuTrigger } from "../PopoverMenu";
2021-12-07 01:34:10 +00:00
import { Item } from "@react-stately/collections";
2022-01-06 00:55:41 +00:00
import { ReactComponent as SettingsIcon } from "../icons/Settings.svg";
import { ReactComponent as AddUserIcon } from "../icons/AddUser.svg";
import { ReactComponent as OverflowIcon } from "../icons/Overflow.svg";
import { useModalTriggerState } from "../Modal";
import { SettingsModal } from "../settings/SettingsModal";
2022-01-06 00:58:55 +00:00
import { InviteModal } from "./InviteModal";
2022-01-06 00:55:41 +00:00
import { Tooltip, TooltipTrigger } from "../Tooltip";
2021-12-04 00:42:29 +00:00
2021-12-07 01:34:10 +00:00
export function OverflowMenu({
2021-12-10 21:44:06 +00:00
roomId,
2021-12-07 01:34:10 +00:00
setShowInspector,
showInspector,
client,
}) {
const { modalState: inviteModalState, modalProps: inviteModalProps } =
useModalTriggerState();
const { modalState: settingsModalState, modalProps: settingsModalProps } =
useModalTriggerState();
// TODO: On closing modal, focus should be restored to the trigger button
// https://github.com/adobe/react-spectrum/issues/2444
const onAction = useCallback((key) => {
switch (key) {
case "invite":
inviteModalState.open();
break;
case "settings":
settingsModalState.open();
break;
}
});
2021-12-04 00:42:29 +00:00
return (
2021-12-07 01:34:10 +00:00
<>
2021-12-13 23:36:35 +00:00
<PopoverMenuTrigger disableOnState>
2021-12-15 06:00:00 +00:00
<TooltipTrigger>
<Button variant="toolbar">
<OverflowIcon />
</Button>
{(props) => (
<Tooltip position="top" {...props}>
More
</Tooltip>
)}
</TooltipTrigger>
2021-12-07 01:34:10 +00:00
{(props) => (
<Menu {...props} label="More menu" onAction={onAction}>
<Item key="invite" textValue="Invite people">
<AddUserIcon />
<span>Invite people</span>
</Item>
<Item key="settings" textValue="Settings">
<SettingsIcon />
<span>Settings</span>
</Item>
</Menu>
)}
</PopoverMenuTrigger>
{settingsModalState.isOpen && (
<SettingsModal
{...settingsModalProps}
setShowInspector={setShowInspector}
showInspector={showInspector}
client={client}
/>
)}
{inviteModalState.isOpen && (
2021-12-10 21:44:06 +00:00
<InviteModal roomId={roomId} {...inviteModalProps} />
2021-12-04 00:42:29 +00:00
)}
2021-12-07 01:34:10 +00:00
</>
2021-12-04 00:42:29 +00:00
);
}