From 7e3dc4ace4c6b21bc68264dc76c8c442aec8031a Mon Sep 17 00:00:00 2001
From: Ashelyn Rose <git@tempest.dev>
Date: Mon, 8 May 2023 14:45:55 -0600
Subject: standardize component structure more

---
 components/InfoBar/index.tsx | 66 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 components/InfoBar/index.tsx

(limited to 'components/InfoBar/index.tsx')

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')
+}
-- 
cgit 1.4.1

