summary refs log tree commit diff
path: root/components/InfoBar
diff options
context:
space:
mode:
Diffstat (limited to 'components/InfoBar')
-rw-r--r--components/InfoBar/InfoBar.module.css34
-rw-r--r--components/InfoBar/index.tsx66
2 files changed, 100 insertions, 0 deletions
diff --git a/components/InfoBar/InfoBar.module.css b/components/InfoBar/InfoBar.module.css
new file mode 100644
index 0000000..7786bd1
--- /dev/null
+++ b/components/InfoBar/InfoBar.module.css
@@ -0,0 +1,34 @@
+.infobar {
+  margin: calc(-1 * var(--text-padding));
+  margin-bottom: var(--text-padding);
+  padding: var(--text-padding);
+  background: var(--main-background);
+  height: var(--header-bar-height);
+  width: var(--main-width);
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  border-bottom: solid 1px var(--text-dimmed);
+}
+
+.infobar.sideNote {
+  color: var(--text-dimmed);
+  font-style: italic;
+}
+
+.infobar.postMeta {
+  color: var(--text-dimmed);
+}
+
+.infobar.postMeta .author {
+  color: var(--text-medium);
+}
+
+.infobar.postMeta .date {
+  font-style: italic;
+}
+
+.infobar + p {
+  margin-top: 0;
+}
diff --git a/components/InfoBar/index.tsx b/components/InfoBar/index.tsx
new file mode 100644
index 0000000..cb5ac9a
--- /dev/null
+++ b/components/InfoBar/index.tsx
@@ -0,0 +1,66 @@
+import { ReactNode } from 'react'
+import styles from './InfoBar.module.css'
+
+interface ArbitraryChildrenProps {
+  children: ReactNode
+}
+
+interface SideNoteProps {
+  text: string
+}
+
+interface PostInfoPros {
+  publishedDate: Date,
+  authorName: string
+}
+
+interface SystemMemberInfoProps {
+  memberName: string,
+  memberAvatar: string
+}
+
+type InfobarProps = (
+  ArbitraryChildrenProps
+  | SideNoteProps
+  | PostInfoPros
+  | SystemMemberInfoProps
+)
+
+export default function InfoBar(props: InfobarProps) {
+  if ('text' in props) {
+    return (
+      <aside className={`${styles.infobar} ${styles.sideNote}`}>
+        {props.text}
+      </aside>
+    )
+  }
+
+  if ('authorName' in props) {
+    return (
+      <aside className={`${styles.infobar} ${styles.postMeta}`}>
+        <span>
+          by <span className={styles.author}>{props.authorName}</span>;{' '}
+          <span className={styles.date}>published {props.publishedDate.toLocaleDateString()}</span>
+        </span>
+      </aside>
+    )
+  }
+
+  if ('memberName' in props) {
+    return (
+      <aside className={`${styles.infobar} ${styles.sideNote}`}>
+        {props.memberName}
+      </aside>
+    )
+  }
+
+  if ('children' in props) {
+    return (
+      <aside className={styles.infobar}>
+        {props.children}
+      </aside>
+    )
+  }
+
+  throw new Error('Unknown infobar type')
+}