// Example B — composition (2nd priority): a simplified viewer header // Logo → File → Layer → Color → K // Only public components; the layout is the consumer's (example-layout.css) and provides tokens. import { useState } from "react" import { SWHeaderActions, SWHeaderColorMenu, SWHeaderDocumentTitle, SWHeaderHome, SWHeaderLayerMenu, SWTheme, type SWHeaderColorMode, type SWHeaderColorValue, } from "@hm-design/sw" import { colors, documents, layers } from "./sample-data" import "./example-layout.css" export function ExampleBViewerHeader({ onEvent }: { onEvent?: (name: string) => void }) { const [activeDocumentId, setActiveDocumentId] = useState(documents[0].id) const [activeLayerId, setActiveLayerId] = useState("0") const [color, setColor] = useState({ value: "ByLayer", swatch: "#ffffff" }) const [colorMode, setColorMode] = useState("byLayer") return ( onEvent?.("home")} /> item.id === activeDocumentId)?.name ?? ""} documents={documents} activeDocumentId={activeDocumentId} onDocumentSelect={document => { setActiveDocumentId(document.id); onEvent?.(`document:${document.id}`) }} onNew={() => onEvent?.("document:new")} onOpen={() => onEvent?.("document:open")} />
{ setActiveLayerId(layer.id); onEvent?.(`layer:${layer.id}`) }} onVisibilityChange={(layer, next) => onEvent?.(`layer-visible:${layer.id}:${next}`)} /> { setColor({ value: option.label ?? option.color, swatch: option.color }); setColorMode(null); onEvent?.(`color:${option.id}`) }} onModeChange={mode => { setColorMode(mode); onEvent?.(`colorMode:${mode}`) }} />
{/* K only: the existing actions pill with print removed. */} onEvent?.("popupGuide")} />
) }