From 7e3dc4ace4c6b21bc68264dc76c8c442aec8031a Mon Sep 17 00:00:00 2001 From: Ashelyn Rose 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 ( + + ) + } + + if ('authorName' in props) { + return ( + + ) + } + + if ('memberName' in props) { + return ( + + ) + } + + if ('children' in props) { + return ( + + ) + } + + throw new Error('Unknown infobar type') +} -- cgit 1.4.1