diff --git a/web/community-header/community-header.css b/web/community-header/community-header.css new file mode 100644 --- /dev/null +++ b/web/community-header/community-header.css @@ -0,0 +1,22 @@ +.container { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16px; + min-height: 32px; +} + +.header { + display: flex; + column-gap: 8px; + color: var(--text-background-primary-default); + font-size: var(--xl-font-20); + font-weight: var(--semi-bold); +} + +.communityButtonsContainer { + display: flex; + column-gap: 8px; + align-items: center; + justify-content: center; +} diff --git a/web/community-header/community-header.react.js b/web/community-header/community-header.react.js new file mode 100644 --- /dev/null +++ b/web/community-header/community-header.react.js @@ -0,0 +1,62 @@ +// @flow + +import * as React from 'react'; + +import { threadInfoSelector } from 'lib/selectors/thread-selectors.js'; +import { useResolvedOptionalThreadInfo } from 'lib/utils/entity-helpers.js'; + +import CommunityHeaderActions from './community-header-actions.react.js'; +import css from './community-header.css'; +import ThreadAvatar from '../avatars/thread-avatar.react.js'; +import { useSelector } from '../redux/redux-utils.js'; + +type Props = { + +communityID?: string, +}; + +function CommunityHeader(props: Props): React.Node { + const { communityID } = props; + + const threadInfos = useSelector(state => threadInfoSelector(state)); + const selectedCommunity = communityID ? threadInfos[communityID] : null; + + const resolvedSelectedCommunity = + useResolvedOptionalThreadInfo(selectedCommunity); + + const header = React.useMemo(() => { + if (!resolvedSelectedCommunity) { + return
All communites
; + } + + return ( +
+ +
{resolvedSelectedCommunity.uiName}
+
+ ); + }, [resolvedSelectedCommunity]); + + const communityButtons = React.useMemo(() => { + if (!resolvedSelectedCommunity) { + return null; + } + + return ( + + ); + }, [resolvedSelectedCommunity]); + + const communityHeader = React.useMemo( + () => ( +
+ {header} + {communityButtons} +
+ ), + [communityButtons, header], + ); + + return communityHeader; +} + +export default CommunityHeader;