import Avatar from 'components/AuthorAvatar'
import CoverImage from 'components/CoverImage'
import GalleryTitle from 'components/GalleryTitle'
import Date from 'components/PostDate'
import type { Gallery } from 'lib/sanity.queries'

export default function GalleryHeader(
  props: Pick<Gallery, 'title' | 'coverImage' | 'date' | 'author' | 'slug'>
) {
  const { title, coverImage, date, author, slug } = props
  return (
    <>
      <GalleryTitle>{title}</GalleryTitle>
      <div className="hidden md:mb-12 md:block">
        {author && <Avatar name={author.name} picture={author.picture} />}
      </div>
      <div className="mb-8 sm:mx-0 md:mb-16">
        <CoverImage title={title} image={coverImage} priority slug={slug} />
      </div>
      <div className="mx-auto max-w-2xl">
        <div className="mb-6 block md:hidden">
          {author && <Avatar name={author.name} picture={author.picture} />}
        </div>
        <div className="mb-6 text-lg">
          <Date dateString={date} />
        </div>
      </div>
    </>
  )
}
