Product Detail
Two-column storefront product detail layout pairing a multi-angle interactive photo gallery with a sticky buy box, live anodized finish swatches, color-temperature edition controls, quantity stepper, collapsible specifications accordion, and filterable customer reviews.

Customer Reviews
Verified studio impressions filtered by anodized finish
Zero monitor glare and genuinely weighted build
The micro-prismatic lens sits recessed enough that you never catch the emitter directly from a seated position. The Sand anodization reads like warm limestone in daylight, and the rotary dimmer has the damped resistance of an analog hi-fi dial.
Machining tolerances rival camera lenses
Picked up the Slate Tunable Pro for late-night CAD reviews. Shifting from crisp 4000K during material sampling down to 2200K at midnight happens smoothly without flicker on phone video. The linen cord lays completely flat out of the box.
Forest finish is understated and deep
In person the Forest tone is a quiet mineral pine rather than a loud green. Friction hinge holds any tilt angle without needing tools, and the 1.85 kg plinth stays anchored even when extended forward over a cutting mat.
Superb optical beam; wish the adapter matched the finish
Color rendering on physical swatches and print proofs is noticeably richer than my previous desk bar. Deducting a single star only because the inline 24W USB-C adapter is matte charcoal regardless of lamp color—otherwise flawless.
Install
1npx stylexblocks add product-detailSource
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641import * as stylex from "@stylexjs/stylex";import { useCallback, useId, useMemo, useRef, useState } from "react";import { Accordion } from "#components/ui/ui-sdk/accordion.tsx";import { AspectRatio } from "#components/ui/ui-sdk/aspect-ratio.tsx";import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { ColorSwatch } from "#components/ui/ui-sdk/color-swatch.tsx";import { DataList } from "#components/ui/ui-sdk/data-list.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { NumberInput } from "#components/ui/ui-sdk/number-input.tsx";import { Progress } from "#components/ui/ui-sdk/progress.tsx";import { RatingGroup } from "#components/ui/ui-sdk/rating-group.tsx";import { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Status } from "#components/ui/ui-sdk/status.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";import { accentPalette, amberPalette, greenPalette, redPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ── Types ─────────────────────────────────────────────────────────────────────
export type ProductFinishId = "sand" | "slate" | "forest";
export type ProductEditionId = "warm-2700k" | "studio-3000k" | "tunable-pro";
export type ProductGalleryAngleId = | "hero" | "profile" | "optics" | "dimmer" | "ambient" | "exploded";
export interface ProductFinishOption { id: ProductFinishId; label: string; materialNote: string; skuCode: string;}
export interface ProductEditionOption { id: ProductEditionId; label: string; shortLabel: string; skuCode: string; kelvinNote: string; opticsSummary: string; priceDelta: number;}
export interface ProductReview { id: string; author: string; initials: string; role: string; date: string; rating: number; finish: ProductFinishId; editionLabel: string; verified: boolean; title: string; body: string; helpfulCount: number;}
export interface AddToBagPayload { sku: string; name: string; finish: ProductFinishId; edition: ProductEditionId; quantity: number; unitPrice: number; totalPrice: number;}
export interface ProductDetailProps extends StyleOverrideProps { /** Studio or storefront brand displayed in the breadcrumb and eyebrow. */ brand?: string; /** Primary product title. */ name?: string; /** Concise subtitle or edition descriptor shown beneath the title. */ subtitle?: string; /** Base product price in USD before edition upgrades. */ basePrice?: number; /** Compare-at retail price in USD before edition upgrades. */ originalPrice?: number; /** Lead product description copy. */ description?: string; /** Initially selected anodized finish. */ initialFinish?: ProductFinishId; /** Initially selected color-temperature edition. */ initialEdition?: ProductEditionId; /** Called when the user adds the configured product to the bag. */ onAddToBag?: (payload: AddToBagPayload) => void; /** Called when the user saves or removes the product from their wishlist. */ onToggleWishlist?: (saved: boolean) => void;}
// ── Demo Data ─────────────────────────────────────────────────────────────────
const FINISHES: readonly ProductFinishOption[] = [ { id: "sand", label: "Sand", materialNote: "Bead-blasted warm limestone anodized aluminum", skuCode: "SND", }, { id: "slate", label: "Slate", materialNote: "Hard-anodized architectural graphite matte", skuCode: "SLT", }, { id: "forest", label: "Forest", materialNote: "Deep mineral pine satin anodization", skuCode: "FOR", },];
const EDITIONS: readonly ProductEditionOption[] = [ { id: "warm-2700k", label: "2700K Warm", shortLabel: "2700K", skuCode: "27K", kelvinNote: "Fixed 2700K evening warmth tuned for reading and quiet studio work.", opticsSummary: "CRI 97+ · R9 > 92 · 640 lm", priceDelta: 0, }, { id: "studio-3000k", label: "3000K Studio", shortLabel: "3000K", skuCode: "30K", kelvinNote: "Balanced 3000K neutral white calibrated for color-accurate drafting.", opticsSummary: "CRI 97+ · R9 > 94 · 680 lm", priceDelta: 0, }, { id: "tunable-pro", label: "Tunable Pro", shortLabel: "2200–4000K", skuCode: "TUN", kelvinNote: "Stepless 2200K–4000K dual-channel array with warm-dim memory (+$40).", opticsSummary: "CRI 98+ · R9 > 96 · 740 lm", priceDelta: 40, },];
interface GalleryAngleMeta { id: ProductGalleryAngleId; label: string; caption: string;}
const GALLERY_ANGLES: readonly GalleryAngleMeta[] = [ { id: "hero", label: "Studio hero", caption: "Three-quarter studio elevation on honed travertine", }, { id: "profile", label: "Side elevation", caption: "Orthographic silhouette · 415 mm H × 310 mm reach", }, { id: "optics", label: "Optical head", caption: "Micro-prismatic glare-free diffuser & chamfered bezel", }, { id: "dimmer", label: "Rotary dimmer", caption: "Knurled solid aluminum plinth dial with 1%–100% dimming", }, { id: "ambient", label: "Desk ambient", caption: "Evening beam cut-off on walnut studio workbench", }, { id: "exploded", label: "In the box", caption: "Lamp assembly, 2.4 m linen cord, PD adapter & hex key", },];
const RATING_BREAKDOWN = [ { stars: 5, count: 118, percent: 83 }, { stars: 4, count: 18, percent: 13 }, { stars: 3, count: 4, percent: 3 }, { stars: 2, count: 1, percent: 1 }, { stars: 1, count: 1, percent: 1 },] as const;
const REVIEWS: readonly ProductReview[] = [ { id: "rev-1", author: "Maren Lindholm", initials: "ML", role: "Architectural illustrator · Copenhagen", date: "2 weeks ago", rating: 5, finish: "sand", editionLabel: "3000K Studio", verified: true, title: "Zero monitor glare and genuinely weighted build", body: "The micro-prismatic lens sits recessed enough that you never catch the emitter directly from a seated position. The Sand anodization reads like warm limestone in daylight, and the rotary dimmer has the damped resistance of an analog hi-fi dial.", helpfulCount: 24, }, { id: "rev-2", author: "Kenji Takahashi", initials: "KT", role: "Industrial designer · Seattle", date: "1 month ago", rating: 5, finish: "slate", editionLabel: "Tunable Pro", verified: true, title: "Machining tolerances rival camera lenses", body: "Picked up the Slate Tunable Pro for late-night CAD reviews. Shifting from crisp 4000K during material sampling down to 2200K at midnight happens smoothly without flicker on phone video. The linen cord lays completely flat out of the box.", helpfulCount: 19, }, { id: "rev-3", author: "Claire Beaumont", initials: "CB", role: "Bookbinder & printmaker · Montreal", date: "6 weeks ago", rating: 5, finish: "forest", editionLabel: "2700K Warm", verified: true, title: "Forest finish is understated and deep", body: "In person the Forest tone is a quiet mineral pine rather than a loud green. Friction hinge holds any tilt angle without needing tools, and the 1.85 kg plinth stays anchored even when extended forward over a cutting mat.", helpfulCount: 14, }, { id: "rev-4", author: "Devon Patel", initials: "DP", role: "Staff product engineer · Chicago", date: "2 months ago", rating: 4, finish: "sand", editionLabel: "3000K Studio", verified: true, title: "Superb optical beam; wish the adapter matched the finish", body: "Color rendering on physical swatches and print proofs is noticeably richer than my previous desk bar. Deducting a single star only because the inline 24W USB-C adapter is matte charcoal regardless of lamp color—otherwise flawless.", helpfulCount: 9, },];
// ── Studio Photography ────────────────────────────────────────────────────────
const PRODUCT_IMAGE_BASE = "/images/blocks/product-detail/";
function lampPhotoSrc(finish: ProductFinishId, angle: ProductGalleryAngleId): string { return `${PRODUCT_IMAGE_BASE}${finish}-${angle}.webp`;}
// ── Inline Crisp SVG Icons ────────────────────────────────────────────────────
function ChevronDownSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m5 7.5 5 5 5-5" /> </Icon> );}
function ChevronLeftSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M12.5 5 7.5 10l5 5" /> </Icon> );}
function ChevronRightSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M7.5 5 12.5 10l-5 5" /> </Icon> );}
function BagSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4.5 7h11l-.9 9.5a1.5 1.5 0 0 1-1.5 1.35H6.9a1.5 1.5 0 0 1-1.5-1.35L4.5 7Z" /> <path d="M7.25 7V5.5a2.75 2.75 0 0 1 5.5 0V7" /> </Icon> );}
function HeartSvg({ filled }: { filled: boolean }) { return ( <Icon size="sm" viewBox="0 0 20 20" fill={filled ? "currentColor" : "none"} stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10 16.5s-6.25-3.75-6.25-8.4A3.55 3.55 0 0 1 10 5.75a3.55 3.55 0 0 1 6.25 2.35c0 4.65-6.25 8.4-6.25 8.4Z" /> </Icon> );}
function TruckSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M2.5 5.5h9.5v8H2.5z" /> <path d="M12 8h3.4l2.1 2.4V13.5H12" /> <circle cx="5.75" cy="14.5" r="1.5" /> <circle cx="14.5" cy="14.5" r="1.5" /> </Icon> );}
function ShieldSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10 2.75 16 5v4.6c0 3.7-2.55 6.85-6 7.65-3.45-.8-6-3.95-6-7.65V5l6-2.25Z" /> <path d="m7.5 10.1 1.75 1.75 3.4-3.6" /> </Icon> );}
function RotateCcwSvg() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4.2 7.5A6.25 6.25 0 1 1 5.2 14" /> <path d="M4 3.75v3.9h3.9" /> </Icon> );}
function ThumbUpSvg() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M6.5 9.2 9.4 3.8a1.45 1.45 0 0 1 2.7.72L11.6 8h4a1.6 1.6 0 0 1 1.56 1.95l-1 4.65A2 2 0 0 1 14.2 16.2H6.5V9.2Z" /> <path d="M6.5 9.2H3.8a.8.8 0 0 0-.8.8v5.4a.8.8 0 0 0 .8.8h2.7" /> </Icon> );}
// ── Styles ────────────────────────────────────────────────────────────────────
const finishSwatchStyles = stylex.create({ sand: { "--color": "#d5c6b0" }, slate: { "--color": "#4d5664" }, forest: { "--color": "#3f5b4e" },});
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, fontFamily: fonts.body, minHeight: "100%", paddingBlock: { default: spacing._8, "@media (max-width: 640px)": spacing._5, }, paddingInline: { default: spacing._6, "@media (max-width: 640px)": spacing._4, }, width: "100%", }, container: { marginInline: "auto", maxWidth: "75rem", width: "100%", }, skuText: { letterSpacing: "0.04em", }, productGrid: { gap: { default: spacing._10, "@media (max-width: 960px)": spacing._8, }, gridTemplateColumns: { default: "minmax(0, 1.12fr) minmax(0, 0.88fr)", "@media (max-width: 860px)": "minmax(0, 1fr)", }, width: "100%", }, heroStage: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderRadius: semanticRadii.panelLg, borderStyle: "solid", borderWidth: "1px", boxShadow: semanticShadows.sm, }, mediaImage: { display: "block", height: "100%", objectFit: "cover", width: "100%", }, heroOverlayBottom: { bottom: spacing._3, insetInlineEnd: spacing._3, insetInlineStart: spacing._3, pointerEvents: "none", position: "absolute", }, heroCaptionPill: { backdropFilter: "blur(10px)", backgroundColor: semanticColors.bgOverlay, borderColor: semanticColors.border, borderRadius: radii.full, borderStyle: "solid", borderWidth: "1px", maxWidth: "calc(100% - 5.5rem)", paddingBlock: spacing._1_5, paddingInline: spacing._3, pointerEvents: "auto", }, pointerAuto: { pointerEvents: "auto", }, heroNavBtn: { backdropFilter: "blur(10px)", backgroundColor: { default: semanticColors.bgOverlay, ":hover": semanticColors.bgElevated, }, borderColor: semanticColors.borderEmphasized, }, thumbGrid: { gap: spacing._2_5, gridTemplateColumns: { default: "repeat(3, minmax(0, 1fr))", "@media (max-width: 480px)": "repeat(2, minmax(0, 1fr))", }, }, thumbBtn: { appearance: "none", backgroundColor: semanticColors.bgMuted, borderColor: { default: semanticColors.border, ":hover": semanticColors.borderEmphasized, }, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", cursor: "pointer", display: "block", marginBlock: 0, marginInline: 0, outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: 0, ":focus-visible": "2px", }, paddingBlock: 0, paddingInline: 0, transitionDuration: durations.fast, transitionProperty: "border-color, box-shadow, transform", }, thumbBtnSelected: { borderColor: semanticColors.accentSolid, boxShadow: `0 0 0 2px ${semanticColors.accentSubtle}`, }, thumbLabel: { backdropFilter: "blur(6px)", backgroundColor: semanticColors.bgOverlay, bottom: spacing._1_5, borderRadius: semanticRadii.controlSm, insetInlineStart: spacing._1_5, maxWidth: "calc(100% - 0.75rem)", paddingBlock: "2px", paddingInline: spacing._1_5, position: "absolute", }, infoCol: { alignSelf: "start", position: { default: "sticky", "@media (max-width: 860px)": "static", }, top: { default: spacing._6, "@media (max-width: 860px)": null, }, }, headingReset: { marginBlock: 0, }, pt1: { paddingTop: spacing._1, }, pt3: { paddingTop: spacing._3, }, leadingSm: { lineHeight: lineHeights.sm, }, leadingMd: { lineHeight: lineHeights.md, }, leadingLg: { lineHeight: lineHeights.lg, }, lineThrough: { textDecorationLine: "line-through", }, noWrap: { whiteSpace: "nowrap", }, fullWidth: { width: "100%", }, ratingLink: { appearance: "none", backgroundColor: "transparent", borderWidth: 0, color: { default: semanticColors.fgMuted, ":hover": semanticColors.fg, }, cursor: "pointer", fontFamily: "inherit", fontSize: fontSizes.sm, lineHeight: lineHeights.sm, paddingBlock: 0, paddingInline: 0, textDecorationLine: "underline", textUnderlineOffset: "3px", }, finishCard: { alignItems: "center", appearance: "none", backgroundColor: { default: semanticColors.bgPanel, ":hover": semanticColors.bgSubtle, }, borderColor: { default: semanticColors.border, ":hover": semanticColors.borderEmphasized, }, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fg, cursor: "pointer", display: "flex", fontFamily: "inherit", fontSize: fontSizes.sm, fontWeight: fontWeights.medium, gap: spacing._2, justifyContent: "flex-start", lineHeight: lineHeights.sm, outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: 0, ":focus-visible": "2px", }, paddingBlock: spacing._2, paddingInline: spacing._2_5, transitionDuration: durations.fast, transitionProperty: "background-color, border-color, box-shadow", }, finishCardSelected: { backgroundColor: semanticColors.accentMuted, borderColor: semanticColors.accentSolid, boxShadow: `0 0 0 1px ${semanticColors.accentSolid}`, }, editionScroller: { maxWidth: "100%", overflowX: "auto", }, quantityInputBox: { width: "7.5rem", }, ctaSecondaryRow: { gap: spacing._2_5, gridTemplateColumns: { default: "repeat(2, minmax(0, 1fr))", "@media (max-width: 440px)": "minmax(0, 1fr)", }, }, assuranceGrid: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", gridTemplateColumns: { default: "repeat(3, minmax(0, 1fr))", "@media (max-width: 520px)": "minmax(0, 1fr)", }, paddingBlock: spacing._3, paddingInline: spacing._3_5, }, assuranceItem: { color: semanticColors.fgMuted, }, reviewsLayout: { gridTemplateColumns: { default: "minmax(0, 18rem) minmax(0, 1fr)", "@media (max-width: 860px)": "minmax(0, 1fr)", }, }, summaryScoreBig: { fontSize: fontSizes._4xl, lineHeight: 1, }, summaryBarRow: { gap: spacing._2_5, gridTemplateColumns: "2.25rem minmax(0, 1fr) 2rem", }, reviewsList: { gridTemplateColumns: { default: "repeat(2, minmax(0, 1fr))", "@media (max-width: 680px)": "minmax(0, 1fr)", }, },});
const formatUsd = (amount: number) => `$${amount.toFixed(2)}`;
// ── Component ─────────────────────────────────────────────────────────────────
/** * ProductDetail — responsive two-column storefront product detail block pairing * an interactive multi-angle studio gallery with a sticky buy box, live anodized * finish swatches, color-temperature edition selector, quantity stepper, * collapsible specification accordion, and filterable customer reviews. */export function ProductDetail({ brand = "Kōji Atelier", name = "Sora Desk Lamp · Edition 02", subtitle = "Machined 6061 anodized aluminum architectural task lamp", basePrice = 285, originalPrice = 340, description = "Milled from solid 6061-T6 aluminum and bead-blasted for a glare-free matte grain, Sora Edition 02 pairs a counter-weighted plinth with a precision friction hinge. Its recessed micro-prismatic optical head casts an even, high-CRI work pool across drafting tables without spill onto adjacent displays.", initialFinish = "sand", initialEdition = "studio-3000k", onAddToBag, onToggleWishlist, palette, style,}: ProductDetailProps) { const [selectedFinishId, setSelectedFinishId] = useState<ProductFinishId>(initialFinish); const [selectedEditionId, setSelectedEditionId] = useState<ProductEditionId>(initialEdition); const [selectedAngleIndex, setSelectedAngleIndex] = useState(0); const [quantity, setQuantity] = useState<number>(1); const [bagCount, setBagCount] = useState<number>(0); const [wishlisted, setWishlisted] = useState<boolean>(false); const [reviewFilter, setReviewFilter] = useState<string>("all"); const [helpfulVotes, setHelpfulVotes] = useState<Record<string, boolean>>({});
const reviewsRef = useRef<HTMLElement | null>(null); const finishLabelId = useId(); const editionLabelId = useId(); const quantityLabelId = useId();
const queue = useMemo(() => Toast.createToaster(), []);
const activeFinish = useMemo( () => FINISHES.find((item) => item.id === selectedFinishId) ?? FINISHES[0]!, [selectedFinishId], );
const activeEdition = useMemo( () => EDITIONS.find((item) => item.id === selectedEditionId) ?? EDITIONS[1]!, [selectedEditionId], );
const galleryPlates = useMemo( () => GALLERY_ANGLES.map((angle) => ({ ...angle, src: lampPhotoSrc(activeFinish.id, angle.id), alt: `${name} in ${activeFinish.label} finish (${activeEdition.label}) — ${angle.caption}`, })), [activeEdition.label, activeFinish.id, activeFinish.label, name], );
const activePlate = galleryPlates[selectedAngleIndex] ?? galleryPlates[0]!; const unitPrice = basePrice + activeEdition.priceDelta; const compareAtPrice = originalPrice + activeEdition.priceDelta; const savings = Math.max(0, compareAtPrice - unitPrice); const totalPrice = unitPrice * quantity; const sku = `SR02-${activeFinish.skuCode}-${activeEdition.skuCode}`;
const filteredReviews = useMemo(() => { if (reviewFilter === "all") return REVIEWS; return REVIEWS.filter((review) => review.finish === reviewFilter); }, [reviewFilter]);
const handleQuantityChange = useCallback((next: number | null) => { if (next == null || Number.isNaN(next)) { setQuantity(1); return; } setQuantity(Math.min(10, Math.max(1, Math.round(next)))); }, []);
const handlePrevAngle = useCallback(() => { setSelectedAngleIndex((idx) => idx === 0 ? galleryPlates.length - 1 : idx - 1, ); }, [galleryPlates.length]);
const handleNextAngle = useCallback(() => { setSelectedAngleIndex((idx) => idx === galleryPlates.length - 1 ? 0 : idx + 1, ); }, [galleryPlates.length]);
const handleAddToBag = useCallback(() => { setBagCount((count) => count + quantity); onAddToBag?.({ sku, name, finish: activeFinish.id, edition: activeEdition.id, quantity, unitPrice, totalPrice, }); queue.success(`Added ${quantity} × ${name} to bag`, { description: `${activeFinish.label} · ${activeEdition.label} · ${formatUsd(totalPrice)}`, }); }, [ activeEdition.id, activeEdition.label, activeFinish.id, activeFinish.label, name, onAddToBag, quantity, queue, sku, totalPrice, unitPrice, ]);
const handleToggleWishlist = useCallback(() => { setWishlisted((prev) => { const next = !prev; onToggleWishlist?.(next); queue.info( next ? `Saved ${name} to wishlist` : `Removed ${name} from wishlist`, { description: `${activeFinish.label} · ${activeEdition.label}`, }, ); return next; }); }, [activeEdition.label, activeFinish.label, name, onToggleWishlist, queue]);
const handleBuyNow = useCallback(() => { queue.info(`Express checkout ready for ${quantity} × ${name}`, { description: `${activeFinish.label} · ${activeEdition.label} · Total ${formatUsd(totalPrice)}`, }); }, [activeEdition.label, activeFinish.label, name, quantity, queue, totalPrice]);
const handleBreadcrumbClick = useCallback( (label: string) => (event: React.MouseEvent<HTMLAnchorElement>) => { event.preventDefault(); queue.info(`Browsing ${label}`, { description: `Viewing the ${brand} lighting catalog.`, }); }, [brand, queue], );
const handleJumpToReviews = useCallback(() => { reviewsRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); }, []);
const handleToggleHelpful = useCallback((reviewId: string) => { setHelpfulVotes((prev) => ({ ...prev, [reviewId]: !prev[reviewId], })); }, []);
return ( <div {...stylex.props(palette, styles.root, style)}> <VStack gap="10" style={styles.container}> {/* Top breadcrumb & SKU bar */} <HStack wrap="wrap" justify="between" gap="3"> <Breadcrumb.Root aria-label="Breadcrumb" variant="plain" size="sm"> <Breadcrumb.List> <Breadcrumb.Item> <Breadcrumb.Link href="#storefront" onClick={handleBreadcrumbClick(brand)} > {brand} </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true">/</Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.Link href="#lighting" onClick={handleBreadcrumbClick("Lighting")} > Lighting </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true">/</Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.Link href="#task-lamps" onClick={handleBreadcrumbClick("Task Lamps")} > Task Lamps </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true">/</Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.CurrentLink aria-current="page"> {name} </Breadcrumb.CurrentLink> </Breadcrumb.Item> </Breadcrumb.List> </Breadcrumb.Root>
<HStack wrap="wrap" gap="2"> <Text render={<span />} variant="mono" size="xs" tone="subtle" style={styles.skuText} > SKU {sku} </Text> {bagCount > 0 ? ( <Badge variant="subtle" size="sm" palette={accentPalette}> <BagSvg /> Bag ({bagCount}) </Badge> ) : null} </HStack> </HStack>
{/* Main 2-column product detail stage */} <Grid render={<main />} align="start" style={styles.productGrid}> {/* Left column: Multi-angle SVG product gallery */} <VStack render={<section aria-label="Product gallery" />} gap="3"> <AspectRatio ratio="4/5" rounded="lg" style={styles.heroStage}> <img src={activePlate.src} alt={activePlate.alt} {...stylex.props(styles.mediaImage)} />
<HStack justify="between" gap="2" style={styles.heroOverlayBottom}> <Text render={<span />} size="xs" weight="medium" truncate="true" style={styles.heroCaptionPill} > {activePlate.label} · {activeFinish.label} ·{" "} {activeEdition.shortLabel} </Text>
<HStack gap="1.5" style={styles.pointerAuto}> <IconButton variant="surface" size="sm" shape="rounded" aria-label="Previous product angle" onClick={handlePrevAngle} style={styles.heroNavBtn} > <ChevronLeftSvg /> </IconButton> <IconButton variant="surface" size="sm" shape="rounded" aria-label="Next product angle" onClick={handleNextAngle} style={styles.heroNavBtn} > <ChevronRightSvg /> </IconButton> </HStack> </HStack> </AspectRatio>
<Grid role="group" aria-label="Select gallery angle" columns="3" style={styles.thumbGrid} > {galleryPlates.map((plate, index) => { const isSelected = index === selectedAngleIndex; return ( <AspectRatio key={plate.id} ratio="square" rounded="md" render={ <button type="button" aria-label={`View ${plate.label}`} aria-pressed={isSelected} onClick={() => setSelectedAngleIndex(index)} /> } style={[ styles.thumbBtn, isSelected && styles.thumbBtnSelected, ]} > <img src={plate.src} alt={plate.label} {...stylex.props(styles.mediaImage)} /> <Text render={<span />} size="2xs" weight="medium" truncate="true" style={styles.thumbLabel} > {plate.label} </Text> </AspectRatio> ); })} </Grid> </VStack>
{/* Right column: Sticky buy box & specifications */} <VStack render={<aside aria-label="Product details" />} gap="5" style={styles.infoCol} > <VStack gap="2.5"> <HStack wrap="wrap" gap="2.5"> <Badge variant="subtle" size="sm" palette={accentPalette}> Edition 02 · Numbered Run </Badge> <Status.Root size="sm" palette={greenPalette}> <Status.Indicator /> In stock · Ships in 2 days </Status.Root> </HStack>
<Heading render={<h1 />} size="3xl" style={styles.headingReset}> {name} </Heading>
<Text variant="muted" size="sm"> {subtitle} </Text>
<HStack wrap="wrap" gap="2"> <RatingGroup count={5} value={5} readOnly size="sm" palette={amberPalette} aria-label="Rated 4.8 out of 5 stars" /> <Text render={<span />} size="sm" weight="semibold" tabular="true"> 4.8 </Text> <button type="button" onClick={handleJumpToReviews} {...stylex.props(styles.ratingLink)} > (142 verified reviews) </button> </HStack>
<HStack align="baseline" wrap="wrap" gap="2.5" style={styles.pt1}> <Text render={<span />} size="2xl" weight="semibold" tabular="true"> {formatUsd(unitPrice)} </Text> {compareAtPrice > unitPrice ? ( <Text render={<span />} variant="subtle" size="md" tabular="true" style={styles.lineThrough} > {formatUsd(compareAtPrice)} </Text> ) : null} {savings > 0 ? ( <Badge variant="subtle" size="sm" palette={redPalette}> Save ${savings} </Badge> ) : null} </HStack> </VStack>
<Text variant="muted" size="md" style={styles.leadingLg}> {description} </Text>
<Separator orientation="horizontal" size="sm" />
{/* Anodized finish swatches */} <VStack gap="2"> <HStack align="baseline" wrap="wrap" justify="between" gap="2"> <Text render={<span />} id={finishLabelId} size="sm" weight="medium"> Finish · {activeFinish.label} </Text> <Text render={<span />} variant="caption"> Anodized 6061-T6 </Text> </HStack>
<Grid role="radiogroup" aria-labelledby={finishLabelId} columns="3" gap="2" > {FINISHES.map((finish) => { const isSelected = finish.id === activeFinish.id; return ( <button key={finish.id} type="button" role="radio" aria-checked={isSelected} onClick={() => setSelectedFinishId(finish.id)} {...stylex.props( styles.finishCard, isSelected && styles.finishCardSelected, )} > <ColorSwatch size="md" shape="circle" style={finishSwatchStyles[finish.id]} /> <span>{finish.label}</span> </button> ); })} </Grid>
<Text variant="caption" style={styles.leadingSm}> {activeFinish.materialNote} </Text> </VStack>
{/* Color-temperature edition segmented control */} <VStack gap="2"> <HStack align="baseline" wrap="wrap" justify="between" gap="2"> <Text render={<span />} id={editionLabelId} size="sm" weight="medium"> Color temperature </Text> <Text render={<span />} variant="caption"> {activeEdition.opticsSummary} </Text> </HStack>
<div {...stylex.props(styles.editionScroller)}> <SegmentGroup.Root size="sm" value={selectedEditionId} onValueChange={(next) => setSelectedEditionId(next as ProductEditionId) } aria-labelledby={editionLabelId} > {EDITIONS.map((edition) => ( <SegmentGroup.Item key={edition.id} value={edition.id}> {edition.label} </SegmentGroup.Item> ))} </SegmentGroup.Root> </div>
<Text variant="caption" style={styles.leadingSm}> {activeEdition.kelvinNote} </Text> </VStack>
{/* Quantity stepper */} <VStack gap="2"> <Text render={<span />} id={quantityLabelId} size="sm" weight="medium"> Quantity </Text> <HStack wrap="wrap" justify="between" gap="4"> <NumberInput.Root value={quantity} onValueChange={handleQuantityChange} min={1} max={10} step={1} size="md" variant="outline" palette={accentPalette} style={styles.quantityInputBox} > <NumberInput.Group> <NumberInput.Input aria-labelledby={quantityLabelId} aria-label="Quantity" /> <NumberInput.Control /> </NumberInput.Group> </NumberInput.Root>
<Text render={<span />} variant="muted" size="sm" tabular="true"> Subtotal:{" "} <Text render={<strong />} size="sm" weight="semibold" tabular="true"> {formatUsd(totalPrice)} </Text> </Text> </HStack> </VStack>
{/* Primary & secondary CTAs */} <VStack gap="2.5"> <Button variant="solid" size="lg" palette={accentPalette} onClick={handleAddToBag} style={styles.fullWidth} > <BagSvg /> Add to bag · {formatUsd(totalPrice)} </Button>
<Grid columns="2" style={styles.ctaSecondaryRow}> <Button variant="surface" size="lg" palette={wishlisted ? redPalette : undefined} aria-pressed={wishlisted} onClick={handleToggleWishlist} style={styles.fullWidth} > <HeartSvg filled={wishlisted} /> {wishlisted ? "Saved" : "Save to wishlist"} </Button> <Button variant="outline" size="lg" onClick={handleBuyNow} style={styles.fullWidth} > Buy it now </Button> </Grid> </VStack>
{/* Fulfillment assurance strip */} <Grid columns="3" gap="3" style={styles.assuranceGrid}> <HStack align="start" gap="2" style={styles.assuranceItem}> <TruckSvg /> <VStack gap="0"> <Text render={<span />} size="xs" weight="medium"> Free shipping </Text> <Text render={<span />} variant="caption"> Insured 2–4 day courier </Text> </VStack> </HStack> <HStack align="start" gap="2" style={styles.assuranceItem}> <ShieldSvg /> <VStack gap="0"> <Text render={<span />} size="xs" weight="medium"> 5-year warranty </Text> <Text render={<span />} variant="caption"> Modular LED coverage </Text> </VStack> </HStack> <HStack align="start" gap="2" style={styles.assuranceItem}> <RotateCcwSvg /> <VStack gap="0"> <Text render={<span />} size="xs" weight="medium"> 30-day trial </Text> <Text render={<span />} variant="caption"> Prepaid studio returns </Text> </VStack> </HStack> </Grid>
{/* Collapsible specifications, shipping, and warranty accordion */} <Accordion.Root defaultValue={["specs"]} multiple variant="outline" size="md" > <Accordion.Item value="specs"> <Accordion.Header> <Accordion.Trigger> Specifications & Materials <Accordion.ItemIndicator> <ChevronDownSvg /> </Accordion.ItemIndicator> </Accordion.Trigger> </Accordion.Header> <Accordion.Panel> <Accordion.ItemBody> <DataList.Root size="sm" orientation="horizontal" variant="subtle" > <DataList.Item> <DataList.ItemLabel>Chassis</DataList.ItemLabel> <DataList.ItemValue> CNC-machined 6061-T6 aluminum · {activeFinish.label} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Dimensions</DataList.ItemLabel> <DataList.ItemValue> 415 mm H × 310 mm reach · Ø 128 mm base </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Weight</DataList.ItemLabel> <DataList.ItemValue> 1.85 kg with counter-weighted steel core </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Optics</DataList.ItemLabel> <DataList.ItemValue> {activeEdition.label} · {activeEdition.opticsSummary} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Dimming</DataList.ItemLabel> <DataList.ItemValue> Knurled rotary dial · 1%–100% flicker-free </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Power</DataList.ItemLabel> <DataList.ItemValue> 2.4 m braided linen cord · 24W USB-C PD adapter </DataList.ItemValue> </DataList.Item> </DataList.Root> </Accordion.ItemBody> </Accordion.Panel> </Accordion.Item>
<Accordion.Item value="shipping"> <Accordion.Header> <Accordion.Trigger> Shipping & Returns <Accordion.ItemIndicator> <ChevronDownSvg /> </Accordion.ItemIndicator> </Accordion.Trigger> </Accordion.Header> <Accordion.Panel> <Accordion.ItemBody> <Text variant="muted" size="sm" style={styles.leadingMd}> Complimentary carbon-neutral courier delivery across North America and the EU within 2–4 business days. Every lamp ships in a plastic-free molded pulp cradle with a numbered photometric calibration card. Try Sora in your workspace for 30 days—prepaid return labels are included with zero restocking fees. </Text> </Accordion.ItemBody> </Accordion.Panel> </Accordion.Item>
<Accordion.Item value="warranty"> <Accordion.Header> <Accordion.Trigger> Warranty & Care <Accordion.ItemIndicator> <ChevronDownSvg /> </Accordion.ItemIndicator> </Accordion.Trigger> </Accordion.Header> <Accordion.Panel> <Accordion.ItemBody> <Text variant="muted" size="sm" style={styles.leadingMd}> Backed by a 5-year mechanical and optical warranty. The COB LED cartridge, rotary encoder, and braided power cable are modular and user-serviceable with the included 2.5 mm hex key. Wipe the anodized aluminum finish with a dry or slightly damp microfiber cloth; avoid abrasive polishes. </Text> </Accordion.ItemBody> </Accordion.Panel> </Accordion.Item> </Accordion.Root> </VStack> </Grid>
<Separator orientation="horizontal" size="sm" />
{/* Customer reviews section */} <VStack render={<section ref={reviewsRef} aria-label="Customer reviews" />} gap="6" > <HStack align="end" wrap="wrap" justify="between" gap="4"> <VStack gap="1"> <Heading render={<h2 />} size="2xl" style={styles.headingReset}> Customer Reviews </Heading> <Text variant="muted" size="sm"> Verified studio impressions filtered by anodized finish </Text> </VStack>
<div {...stylex.props(styles.editionScroller)}> <SegmentGroup.Root size="sm" value={reviewFilter} onValueChange={setReviewFilter} aria-label="Filter reviews by finish" > <SegmentGroup.Item value="all"> All ({REVIEWS.length}) </SegmentGroup.Item> <SegmentGroup.Item value="sand">Sand</SegmentGroup.Item> <SegmentGroup.Item value="slate">Slate</SegmentGroup.Item> <SegmentGroup.Item value="forest">Forest</SegmentGroup.Item> </SegmentGroup.Root> </div> </HStack>
<Grid align="start" gap="6" style={styles.reviewsLayout}> {/* Rating distribution summary card */} <Card.Root variant="outline" size="md"> <Card.Body> <HStack align="baseline" gap="2.5"> <Text render={<span />} weight="semibold" tabular="true" style={styles.summaryScoreBig} > 4.8 </Text> <Text render={<span />} variant="muted" size="sm"> out of 5 </Text> </HStack>
<HStack wrap="wrap" gap="2"> <RatingGroup count={5} value={5} readOnly size="sm" palette={amberPalette} aria-label="Average rating 4.8 out of 5" /> <Text render={<span />} variant="caption"> 142 ratings </Text> </HStack>
<VStack gap="2" style={styles.pt3}> {RATING_BREAKDOWN.map((row) => ( <Grid key={row.stars} align="center" style={styles.summaryBarRow}> <Text render={<span />} variant="caption" tabular="true"> {row.stars}★ </Text> <Progress.Root value={row.percent} min={0} max={100} size="sm" variant="subtle" shape="full" palette={amberPalette} aria-label={`${row.stars} star reviews: ${row.percent}%`} > <Progress.Track> <Progress.Range /> </Progress.Track> </Progress.Root> <Text render={<span />} variant="caption" tone="subtle" align="end" tabular="true" > {row.count} </Text> </Grid> ))} </VStack> </Card.Body> </Card.Root>
{/* Review cards grid */} <Grid columns="2" gap="4" style={styles.reviewsList}> {filteredReviews.map((review) => { const isHelpful = Boolean(helpfulVotes[review.id]); const displayHelpful = review.helpfulCount + (isHelpful ? 1 : 0); const finishOption = FINISHES.find((f) => f.id === review.finish); return ( <Card.Root key={review.id} variant="outline" size="md"> <Card.Header> <HStack align="start" justify="between" gap="3"> <HStack gap="2.5"> <Avatar.Root size="sm" variant="subtle" shape="full"> <Avatar.Fallback>{review.initials}</Avatar.Fallback> </Avatar.Root> <VStack gap="0"> <Text render={<span />} size="sm" weight="medium"> {review.author} </Text> <Text render={<span />} variant="caption" tone="subtle"> {review.role} </Text> </VStack> </HStack> <Text render={<span />} variant="caption" tone="subtle" style={styles.noWrap} > {review.date} </Text> </HStack> </Card.Header>
<Card.Body> <VStack gap="2"> <HStack wrap="wrap" gap="1.5"> <RatingGroup count={5} value={review.rating} readOnly size="xs" palette={amberPalette} aria-label={`Rated ${review.rating} out of 5`} /> {review.verified ? ( <Badge variant="subtle" size="xs" palette={greenPalette} > Verified </Badge> ) : null} {finishOption ? ( <Badge variant="surface" size="xs"> {finishOption.label} · {review.editionLabel} </Badge> ) : null} </HStack>
<Text render={<h3 />} size="sm" weight="semibold"> {review.title} </Text> <Text variant="muted" size="sm" style={styles.leadingMd}> {review.body} </Text> </VStack> </Card.Body>
<Card.Footer> <HStack justify="between" style={styles.fullWidth}> <Button variant={isHelpful ? "subtle" : "ghost"} size="xs" palette={isHelpful ? accentPalette : undefined} aria-pressed={isHelpful} onClick={() => handleToggleHelpful(review.id)} > <ThumbUpSvg /> Helpful ({displayHelpful}) </Button> </HStack> </Card.Footer> </Card.Root> ); })} </Grid> </Grid> </VStack> </VStack>
<Toaster toaster={queue} /> </div> );}
Inspired by the Product Detail template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).