import { createContext, useContext, useState } from "react"; import "./openui-options.css"; import type { ReactNode } from "react"; export type Option = { id: "a" | "b" | "c"; title: string; strength: string; tradeoff: string; detail: string; specimen: "current" | "plain" | "styled"; }; type Filter = "all" | Option["specimen"]; type View = "gallery" | "comparison" | "details"; let FilterContext = createContext("all"); let ViewContext = createContext("gallery"); export function OptionsSection( { title, introduction, children }: { title: string; introduction: string; children: ReactNode }, ) { let [filter, setFilter] = useState("all"); return (

{title}

{introduction}

{children}
); } export function OptionGallery( { title, layout, children }: { title: string; layout: "grid" | "rail"; children: ReactNode }, ) { return (

{title}

{children}
); } export function OptionComparison({ title, children }: { title: string; children: ReactNode }) { return (

{title}

{children}
Option Strength Tradeoff
); } export function OptionDetails({ title, children }: { title: string; children: ReactNode }) { return (

{title}

{children}
); } function Specimen({ kind, title }: { kind: Option["specimen"]; title: string }) { return (
); } export function DesignOption({ option }: { option: Option }) { let filter = useContext(FilterContext); let view = useContext(ViewContext); if (filter !== "all" && filter !== option.specimen) return null; if (view === "comparison") { return ( {option.title} {option.strength} {option.tradeoff} ); } if (view === "details") { return (
{option.title}

{option.detail}

); } return (
Illustrative output
{option.title}

{option.strength}

); }