import { ReactNode } from 'react'
import Image from 'components/Image'
import system from '~/config/system.json'
import styles from './InfoBar.module.css'
interface ArbitraryChildrenProps {
children: ReactNode
}
interface SideNoteProps {
text: string
}
interface PostInfoPros {
publishedDate: Date,
authorName: string
}
interface SystemMemberInfoProps {
memberName: string
}
type InfobarProps = (
ArbitraryChildrenProps
| SideNoteProps
| PostInfoPros
| SystemMemberInfoProps
)
export default function InfoBar(props: InfobarProps) {
if ('text' in props) {
return (
)
}
if ('authorName' in props) {
const author = system.members.find((member) => member.name === props.authorName)
const style = { '--author-color': author?.color } as React.CSSProperties
const picture = author.profileImg
return (
)
}
if ('memberName' in props) {
const memberKey = props.memberName.toLowerCase()
const member = system.members.find((member) => member.name === props.memberName)
const style = { '--member-color': member?.color } as React.CSSProperties
const picture = member.profileImg
return (
)
}
if ('children' in props) {
return (
)
}
throw new Error('Unknown infobar type')
}