import type { ReactNode } from "react";
import { cn } from "cn";

type SectionProps = {
  /** Anchor id (for in-page navigation). */
  id?: string;
  /** id of the heading that names this section. */
  labelledBy?: string;
  /** Classes for the <section> (spacing, background). Default: py-20. */
  className?: string;
  /** Classes for the inner container. Pass `false` to render children full-width. */
  containerClassName?: string | false;
  children: ReactNode;
};

/** Page section wrapper: owns vertical spacing, anchor offset and the 1280px container. */
export function Section({ id, labelledBy, className, containerClassName, children }: SectionProps) {
  return (
    <section id={id} aria-labelledby={labelledBy} className={cn("scroll-mt-24 py-20", className)}>
      {containerClassName === false ? children : <div className={cn("container-site", containerClassName)}>{children}</div>}
    </section>
  );
}
