diff --git a/web/chat/thread-menu.css b/web/chat/thread-menu.css new file mode 100644 --- /dev/null +++ b/web/chat/thread-menu.css @@ -0,0 +1,22 @@ +button.topBarMenuButton { + background-color: transparent; + border: none; + cursor: pointer; + color: var(--thread-top-bar-menu-color); +} + +div.topBarMenuActionList { + position: absolute; + right: 10px; + top: 55px; + z-index: 1; + display: flex; + flex-direction: column; + background-color: var(--thread-menu-bg); + border-radius: 4px; + padding: 5px 0px; +} + +div.disabled { + display: none; +} diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js new file mode 100644 --- /dev/null +++ b/web/chat/thread-menu.react.js @@ -0,0 +1,60 @@ +// @flow + +import classNames from 'classnames'; +import * as React from 'react'; + +import { type ThreadInfo } from 'lib/types/thread-types'; + +import SWMansionIcon from '../SWMansionIcon.react'; +import css from './thread-menu.css'; + +type ThreadMenuProps = { + +threadInfo: ThreadInfo, +}; + +function ThreadMenu(props: ThreadMenuProps): React.Node { + const [isOpen, setIsOpen] = React.useState(false); + + // eslint-disable-next-line no-unused-vars + const { threadInfo } = props; + + const menuItems = []; + + const menuActionListClasses = classNames(css.topBarMenuActionList, { + [css.disabled]: !isOpen, + }); + + const closeMenuCallback = React.useCallback(() => { + document.removeEventListener('click', closeMenuCallback); + if (isOpen) { + setIsOpen(false); + } + }, [isOpen]); + + React.useEffect(() => { + if (!document || !isOpen) { + return undefined; + } + document.addEventListener('click', closeMenuCallback); + return () => document.removeEventListener('click', closeMenuCallback); + }, [closeMenuCallback, isOpen]); + + const switchMenuCallback = React.useCallback(() => { + setIsOpen(!isOpen); + }, [isOpen]); + + if (menuItems.length === 0) { + return null; + } + + return ( +
{threadInfo.uiName}