diff --git a/web/modals/threads/members/member.react.js b/web/modals/threads/members/member.react.js new file mode 100644 --- /dev/null +++ b/web/modals/threads/members/member.react.js @@ -0,0 +1,73 @@ +// @flow + +import classNames from 'classnames'; +import * as React from 'react'; +import { useState } from 'react'; + +import { memberIsAdmin, memberHasAdminPowers } from 'lib/shared/thread-utils'; +import { stringForUser } from 'lib/shared/user-utils'; +import { + type RelativeMemberInfo, + type ThreadInfo, +} from 'lib/types/thread-types'; + +import Label from '../../../components/label.react'; +import Menu from '../../../components/menu.react'; +import SWMansionIcon from '../../../SWMansionIcon.react'; +import css from './members-modal.css'; +type Props = { + +memberInfo: RelativeMemberInfo, + +threadInfo: ThreadInfo, + +onMenuChange: boolean => void, +}; + +function ThreadMember(props: Props): React.Node { + const { memberInfo, threadInfo, onMenuChange } = props; + const userName = stringForUser(memberInfo); + const [isMenuOpen, setIsMenuOpen] = useState(false); + + React.useEffect(() => { + onMenuChange(isMenuOpen); + }, [isMenuOpen, onMenuChange]); + + const menuItems = []; + + const userSettingsIcon = React.useMemo( + () => , + [], + ); + + const label = React.useMemo(() => { + if (memberIsAdmin(memberInfo, threadInfo)) { + return ; + } else if (memberHasAdminPowers(memberInfo)) { + return ; + } + return null; + }, [memberInfo, threadInfo]); + + const memberContainerClasses = classNames(css.memberContainer, { + [css.memberContainerWithMenuOpen]: isMenuOpen, + }); + + return ( +
+
+ {userName} {label} +
+
+ + {menuItems} + +
+
+ ); +} + +export default ThreadMember; diff --git a/web/modals/threads/members/members-modal.css b/web/modals/threads/members/members-modal.css new file mode 100644 --- /dev/null +++ b/web/modals/threads/members/members-modal.css @@ -0,0 +1,25 @@ +div.memberContainer { + display: flex; + flex-direction: row; + justify-content: space-between; + padding: 8px 16px; +} + +div.memberContainer:hover { + color: var(--members-modal-member-text-hover); +} + +div.memberContainerWithMenuOpen { + color: var(--members-modal-member-text-hover); +} + +div.memberInfo { + font-size: var(--l-font-18); + display: flex; + align-items: center; + gap: 10px; +} + +div.memberAction { + position: relative; +}