import type { Translator } from "@/lib/i18n";

/**
 * Previous / share / next, at the foot of a project or article.
 *
 * The empty spans are load-bearing: the row is a three-column grid, so an
 * absent neighbour still has to occupy its cell or the share button slides out
 * of the centre.
 */
export default function ProjectNav({
  previous,
  next,
  t,
}: {
  previous: any;
  next: any;
  t: Translator;
}) {
  return (
    <nav className="project-post-nav" aria-label={t("ui.next")}>
      <div className="container project-post-nav__inner">
        {previous?.url ? (
          <a rel="prev" href={previous.url}>
            <span>{t("ui.previous_project")}</span>
            <strong>{previous.title}</strong>
          </a>
        ) : (
          <span aria-hidden="true" />
        )}

        <button className="project-share" type="button" data-share-page>
          {t("ui.share")}
        </button>

        {next?.url ? (
          <a rel="next" href={next.url}>
            <span>{t("ui.next_project")}</span>
            <strong>{next.title}</strong>
          </a>
        ) : (
          <span aria-hidden="true" />
        )}
      </div>
    </nav>
  );
}
