Page MenuHomePhabricator

D10499.id35170.diff
No OneTemporary

D10499.id35170.diff

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 <div className={css.header}>All communites</div>;
+ }
+
+ return (
+ <div className={css.header}>
+ <ThreadAvatar size="S" threadInfo={resolvedSelectedCommunity} />
+ <div>{resolvedSelectedCommunity.uiName}</div>
+ </div>
+ );
+ }, [resolvedSelectedCommunity]);
+
+ const communityButtons = React.useMemo(() => {
+ if (!resolvedSelectedCommunity) {
+ return null;
+ }
+
+ return (
+ <CommunityHeaderActions communityID={resolvedSelectedCommunity.id} />
+ );
+ }, [resolvedSelectedCommunity]);
+
+ const communityHeader = React.useMemo(
+ () => (
+ <div className={css.container}>
+ {header}
+ {communityButtons}
+ </div>
+ ),
+ [communityButtons, header],
+ );
+
+ return communityHeader;
+}
+
+export default CommunityHeader;

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 9:15 AM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611151
Default Alt Text
D10499.id35170.diff (2 KB)

Event Timeline