The Open Standard for Generative UI
/* Icons come from the ssr entry so this stays a server component; the type
comes from the main entry, which is the only one that exports it. A
type-only import is erased at build, so it pulls in no client code. */
import type { Icon } from "@phosphor-icons/react";
import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react/dist/ssr";
import Image from "next/image";
import type { CSSProperties, ReactNode } from "react";
import { BevelButton } from "../../components/Button/BevelButton";
import { FadedDither } from "../../components/FadedDither/FadedDither";
import { FeatureGridSection, type GridFeatureIcon } from "../FeatureGridSection/FeatureGridSection";
import styles from "./ProductSection.module.css";
/* Rendered widths of the stage artwork, so phones fetch a phone-sized file
rather than the 2x desktop one. The wide shot shows from 768px up, capped at
--home-container-max; the compact one fills the band minus its gutters. */
const STAGE_WIDE_SIZES = "(max-width: 1023px) calc(100vw - 80px), 1200px";
const STAGE_COMPACT_SIZES = "calc(100vw - 40px)";
export type ProductCard = {
Icon: Icon;
/* The same icon named as a string. The phone layout hands these cards to
FeatureGridSection, which is a client component, and a component reference
cannot cross that boundary from here. */
icon: GridFeatureIcon;
title: string;
description: string;
};
/** Shared OpenUI wordmark and outlined product-name chip. */
export function ProductLabel({
name,
tag,
className,
}: {
name: string;
tag?: string;
className?: string;
}) {
return (
<p className={`${styles.eyebrow} ${className ?? ""}`.trim()}>
{name}
{tag ? (
<>
{" "}
<span className={styles.eyebrowTag}>{tag}</span>
</>
) : null}
</p>
);
}
export type ProductSectionProps = {
/* Product name, and an optional chip beside it: "OpenUI Lang" + "Open
Source". Omit the tag for a band that needs no qualifier. */
name: string;
tag?: string;
headline: ReactNode;
/* Optional: a band can let its headline stand alone. */
description?: string;
/* Optional: a band with nothing to try yet shows only the docs link. */
primaryCta?: { label: string; href: string; external?: true };
secondaryCta: { label: string; href: string; external?: true };
/* "light" sits on the page background and follows the site theme. "dark" sits
on the black Cloud band, which is black on either theme, so its buttons use
the theme-independent variants instead of the adaptive ones. */
tone?: "light" | "dark";
/* Basename under /public, which -light and -dark hang off. Until the artwork
exists the stage renders its brief instead, at the same aspect ratio, so
dropping the images in later changes nothing about the layout. */
shot?: string;
/* A code-native illustration can replace the image pair while retaining the
same stage, spacing and responsive behaviour. */
art?: ReactNode;
/* Let artwork that already includes its own frame crop directly to the
section bounds instead of nesting it inside the shared inset stage. */
fullBleedArt?: boolean;
/* Drop the stage's own frame and shader, for art that draws its own panels
(the Lang band's three agents). */
bareStage?: boolean;
/* Optional artwork-specific ratios. Desktop exports can stay canonical;
mobile uses a controlled center crop instead of squeezing the frame. */
stageAspectRatio?: string;
stageMobileAspectRatio?: string;
cards: ProductCard[];
};
/* One product band: a split lockup, two calls to action, a wide visual, then
the capabilities as a row of cards.
*
* Deliberately one component rather than three copies. Lang, Gateway and
* Observability differ only in copy and tone, and a shared shape is what makes
* them read as three of the same thing rather than three separate pitches.
*/
export function ProductSection({
name,
tag,
headline,
description,
primaryCta,
secondaryCta,
tone = "light",
shot,
art,
fullBleedArt = false,
bareStage = false,
stageAspectRatio,
stageMobileAspectRatio,
cards,
}: ProductSectionProps) {
const primaryVariant = tone === "dark" ? "light" : "primary";
const secondaryVariant = tone === "dark" ? "dark" : "secondary";
return (
<section className={`${styles.product} ${tone === "dark" ? styles.onDark : ""}`.trim()}>
<div className={styles.lockup}>
<div className={styles.lead}>
<ProductLabel name={name} tag={tag} />
<h3 className={styles.headline}>{headline}</h3>
<div className={styles.ctas}>
{primaryCta && (
<BevelButton
className={styles.primaryCta}
variant={primaryVariant}
href={primaryCta.href}
label={primaryCta.label}
external={primaryCta.external}
badge={
primaryCta.external ? (
<ArrowUpRight size={16} weight="bold" />
) : (
<ArrowRight size={16} weight="bold" />
)
}
/>
)}
<BevelButton
className={styles.secondaryCta}
variant={secondaryVariant}
href={secondaryCta.href}
label={secondaryCta.label}
external={secondaryCta.external}
badge={
secondaryCta.external ? (
<ArrowUpRight size={16} weight="bold" />
) : (
<ArrowRight size={16} weight="bold" />
)
}
/>
</div>
</div>
{/* Opposite the headline on desktop, beneath it on a phone: the same
split the page hero uses. */}
{description && <p className={styles.description}>{description}</p>}
</div>
<div
className={`${styles.stage} ${fullBleedArt ? styles.stageFullBleed : ""} ${
bareStage ? styles.stageBare : ""
}`.trim()}
style={
{
"--product-stage-aspect": stageAspectRatio,
"--product-stage-mobile-aspect": stageMobileAspectRatio,
} as CSSProperties
}
>
{/* Behind the artwork, filling the transparent margin it is drawn with.
Client-only, since it is WebGPU. */}
{!bareStage && <FadedDither band={tone} className={styles.stageShader} />}
{art ??
(shot ? (
/* Two pairs, each in a wrapper the breakpoint switches off. The
phone artwork is a different drawing at 1440x1200, not the wide
one rescaled. The wrapper is display:contents when shown, so the
theme rules keep working on the images untouched. */
<>
<span className={styles.stageWide}>
<Image
className={`${styles.stageImage} ${styles.stageLight}`}
src={`${shot}-light.webp`}
alt=""
aria-hidden="true"
width={1280}
height={720}
loading="lazy"
sizes={STAGE_WIDE_SIZES}
/>
<Image
className={`${styles.stageImage} ${styles.stageDark}`}
src={`${shot}-dark.webp`}
alt=""
aria-hidden="true"
width={1280}
height={720}
loading="lazy"
sizes={STAGE_WIDE_SIZES}
/>
</span>
<span className={styles.stageCompact}>
<Image
className={`${styles.stageImage} ${styles.stageLight}`}
src={`${shot}-mobile-light.webp`}
alt=""
aria-hidden="true"
width={720}
height={600}
loading="lazy"
sizes={STAGE_COMPACT_SIZES}
/>
<Image
className={`${styles.stageImage} ${styles.stageDark}`}
src={`${shot}-mobile-dark.webp`}
alt=""
aria-hidden="true"
width={720}
height={600}
loading="lazy"
sizes={STAGE_COMPACT_SIZES}
/>
</span>
</>
) : null)}
</div>
{cards.length > 0 && (
<>
<div className={styles.cards}>
{cards.map(({ Icon: CardIcon, title, description: cardCopy }) => (
<div className={styles.card} key={title}>
<span className={styles.cardIcon} aria-hidden="true">
<CardIcon size={20} weight="light" />
</span>
<div className={styles.cardCopy}>
<h4 className={styles.cardTitle}>{title}</h4>
<p className={styles.cardDescription}>{cardCopy}</p>
</div>
</div>
))}
</div>
{/* Phones get the same capabilities as feature-grid rows, one open at
a time, so they read as the grid under the Lang band rather than
as a horizontal scroller of cards. The breakpoint shows exactly
one of the two. */}
<div className={styles.cardsCompact}>
<FeatureGridSection
features={cards.map(({ icon, title, description: cardCopy }) => ({
icon,
title,
description: cardCopy,
}))}
showHeader={false}
showHeaderSeparator={false}
showCompat={false}
showBottomSeparator={false}
flushSectionPadding
/>
</div>
</>
)}
</section>
);
}