import type { PageSection } from '../../../lib/page-editor-service.js'
import { str } from './parts.js'

/** A highlighted pull quote with optional attribution. */
export function PullQuoteSection({ section }: { section: PageSection }) {
  const c = section.content
  const quote = str(c, 'quote')
  const attribution = str(c, 'attribution')
  const role = str(c, 'role')

  if (!quote) return null

  return (
    <figure className="mx-auto max-w-3xl px-6">
      <blockquote className="border-brand border-l-4 pl-6">
        <p className="text-foreground text-xl leading-relaxed font-medium sm:text-2xl">“{quote}”</p>
      </blockquote>
      {(attribution || role) && (
        <figcaption className="text-muted-foreground mt-3 pl-6 text-sm">
          {attribution && <span className="text-foreground font-medium">{attribution}</span>}
          {attribution && role && <span aria-hidden> · </span>}
          {role}
        </figcaption>
      )}
    </figure>
  )
}
