"use client"
import * as React from "react"
import { useTheme } from "@exxatdesignux/ui/hooks/use-color-scheme"
import { FieldGroup } from "@/components/ui/field"
import { RadioGroup, RadioGroupItem, RadioGroupLabel } from "@/components/ui/radio-group"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import { SelectionTileGrid } from "@/components/ui/selection-tile-grid"
import { useAppTheme, type Brand, type TextSizePreference } from "@/hooks/use-app-theme"
import { useDashboardView, type DashboardView } from "@/contexts/dashboard-view-context"
import { useChartVariant, type ChartVariant } from "@/contexts/chart-variant-context"
import { SettingsFormRow } from "@/components/settings-form-row"
import { BrandColorPicker } from "@/components/brand-color-picker"
import { ExxatProductLogo, ExxatProductWordmarkEditor } from "@/components/exxat-product-logo"
import { useProduct, syncActiveProductThemeFromStore } from "@/contexts/product-context"
import { useProductSwitch } from "@/contexts/product-route-sync"
import { DEFAULT_CUSTOM_PRODUCT_BRAND, type CustomProductBrand, type Product, isCustomProductPlaceholder, isListedCustomProduct } from "@/stores/app-store"
import {
brandForProduct,
brandPreviewPanelSurfaces,
customProductBrandConfig,
getProductBrand,
productBrandLabel,
} from "@/lib/product-brand"
import { normalizeBrandAccentColor } from "@/lib/brand-accent-color"
import { brandColorsEquivalent } from "@/lib/brand-color-match"
import { validateCustomProductSuffix, customSuffixCollidesWithBuiltInProduct } from "@/lib/product-routing"
import {
isProductRefHidden,
isStartupProductRef,
productRefKey,
type ProductRef,
} from "@/lib/product-ref"
import { Tip } from "@/components/ui/tip"
import {
downloadProductScaffold,
downloadShippedTenantCatalog,
isBuilderDevSyncEnvironment,
tenantRecordFromCustomBrand,
} from "@exxatdesignux/product-framework"
import { useProductAuthoringEnabled } from "@exxatdesignux/ui/components/shell"
import { cn } from "@/lib/utils"
export type SettingsAppearanceMode = "products-only" | "display-only" | "all"
function RadioRow({
value,
id,
label,
iconClass,
}: {
value: string
id: string
label: string
iconClass?: string
}) {
return (
{iconClass ? (
) : null}
{label}
)
}
/** Illustrative split sidebars when “system” shows light+dark (tokens follow active brand hue). */
const SPLIT_SIDEBAR: Record = {
one: {
light: "oklch(0.935 0.024 286.1)",
dark: "oklch(0.32 0.085 286.1)",
markLight: "oklch(0.58 0.18 286.1)",
markDark: "oklch(0.72 0.18 286.1)",
},
prism: {
light: "oklch(0.96 0.04 342)",
dark: "oklch(0.34 0.13 342)",
markLight: "oklch(0.62 0.21 342)",
markDark: "oklch(0.78 0.18 342)",
},
}
/** Fills the square preview in Settings appearance tiles (see SelectionTileGraphic below-mode sizing). */
const APPEARANCE_TILE_SVG = "block h-full w-auto max-h-full max-w-full shrink-0 object-contain"
/** Fixed palettes per labeled mode — do not use `var(--background)` etc. (those follow the *current* theme). */
const CHROME_LIGHT = {
shell: "oklch(1 0 0)",
shellStroke: "oklch(0.90 0.003 270)",
headerBar: "oklch(0.96 0.004 270)",
headerStroke: "oklch(0.92 0.003 270)",
content: "oklch(0.985 0.003 270)",
card: "oklch(1 0 0)",
cardStroke: "oklch(0.91 0.003 270)",
navRow: "oklch(0.86 0.012 270)",
pill: "oklch(0.94 0.003 270)",
windowRed: "#FF5F57",
windowYellow: "#FEBC2E",
windowGreen: "#28C840",
} as const
const CHROME_DARK = {
shell: "oklch(0.13 0.01 270)",
shellStroke: "oklch(0.32 0.015 270)",
headerBar: "oklch(0.19 0.013 270)",
headerStroke: "oklch(0.28 0.013 270)",
content: "oklch(0.155 0.012 270)",
card: "oklch(0.20 0.013 270)",
cardStroke: "oklch(0.32 0.013 270)",
navRow: "oklch(0.42 0.014 270)",
pill: "oklch(0.25 0.013 270)",
windowRed: "#FF5F57",
windowYellow: "#FEBC2E",
windowGreen: "#28C840",
} as const
type ChromeTokens = { -readonly [K in keyof typeof CHROME_LIGHT]: string }
/**
* Reusable mini-chrome — Mac-style traffic lights, sidebar with brand-tinted
* mark + nav rows, header bar with search pill + avatar, three content cards
* (KPI tile, mini bar chart, list rows). Coordinates are scoped to a fixed
* 96×56 viewBox so the System mode can place two side-by-side via ``.
*
* `strokeBoost` thickens every border for the high-contrast variants without
* forking the whole illustration.
*/
function ChromeIllustration({
tokens,
sidebar,
sidebarMark,
strokeBoost = 1,
contentAccent,
}: {
tokens: ChromeTokens
sidebar: string
sidebarMark: string
strokeBoost?: number
contentAccent?: string
}) {
const sw = (n: number) => n * strokeBoost
return (
{/* Mac-style traffic lights */}
{/* Sidebar */}
{/* Brand-tinted product mark + faux team name */}
{/* Active nav row + 4 inactive rows */}
{/* Header bar: search pill + avatar */}
{/* KPI card */}
{/* Bar-chart card */}
{/* List card */}
)
}
/** Mini browser chrome: illustrative light / dark / split (brand sidebars from SPLIT_SIDEBAR). */
/**
* One window, two halves — render the full chrome twice in the same SVG, each
* clipped to a triangular half by a diagonal that runs from the top-right
* corner to the bottom-left corner. Light fills the top-left triangle, dark
* fills the bottom-right triangle. Because both halves use identical geometry
* inside one viewBox, the result reads as a single window with a diagonal
* theme split (macOS / iOS "Auto" pattern) rather than two adjacent windows.
*/
function SplitSystemSvg({
light,
dark,
}: {
light: { tokens: ChromeTokens; sidebar: string; sidebarMark: string; strokeBoost?: number; contentAccent?: string }
dark: { tokens: ChromeTokens; sidebar: string; sidebarMark: string; strokeBoost?: number; contentAccent?: string }
}) {
// useId keeps clipPath ids unique across tile instances on the same page.
const baseId = React.useId().replace(/:/g, "")
const lightId = `chrome-split-light-${baseId}`
const darkId = `chrome-split-dark-${baseId}`
return (
{/* Top-left triangle — top edge + left edge + diagonal to bottom-left. */}
{/* Bottom-right triangle — right edge + bottom edge + diagonal. */}
)
}
function ThemeModeSvg({ mode, brand }: { mode: "system" | "light" | "dark"; brand: Brand }) {
const split = SPLIT_SIDEBAR[brand]
if (mode === "light") {
return (
)
}
if (mode === "dark") {
return (
)
}
// System: one window with a diagonal light↔dark split inside.
return (
)
}
const HC_STROKE = "oklch(0.18 0.02 270)"
const HC_LIGHT_TOKENS: ChromeTokens = {
...CHROME_LIGHT,
shellStroke: HC_STROKE,
headerStroke: HC_STROKE,
cardStroke: HC_STROKE,
}
const HC_WINDOWS_TOKENS: ChromeTokens = {
...CHROME_DARK,
shell: "#000000",
shellStroke: "#FFFFFF",
headerBar: "#FFFF00",
headerStroke: "#FFFF00",
content: "#000000",
card: "#000000",
cardStroke: "#FFFFFF",
navRow: "#FFFFFF",
pill: "#000000",
}
/** Illustrative light chrome; stroke weight shows contrast (not tied to active color theme). */
function ContrastPrefSvg({
pref,
brand,
}: {
pref: "system" | "normal" | "high" | "windows"
brand: Brand
}) {
const split = SPLIT_SIDEBAR[brand]
if (pref === "normal") {
return (
)
}
if (pref === "high") {
return (
)
}
if (pref === "windows") {
return (
)
}
// System: one window with a diagonal Normal↔High split inside.
return (
)
}
const CHART_LABELS: Record = {
normal: "Normal",
tabs: "With tabs",
selector: "With filters",
"metrics-tabs": "Tabs + metrics",
"kpi-chart": "KPI + chart",
}
const VIEW_LABELS: Record = {
report: "Report",
simple: "Simple",
mix: "Mix",
}
/** Settings tile previews — map active product to the built-in split sidebar hue. */
function previewBrandForProduct(product: Product): Brand {
return product === "exxat-prism" ? "prism" : "one"
}
const THEME_CHOICE_LABEL: Record<"system" | "light" | "dark", string> = {
system: "System default",
light: "Light",
dark: "Dark",
}
const TEXT_SIZE_LABEL: Record = {
compact: "Tiny",
default: "Default",
large: "Large",
}
type ProductListOption = {
value: Product
label: string
/**
* Sub-line shown next to the wordmark for the Exxat One siblings. Both
* share `suffix: "One"` so without this qualifier the two rows look
* identical to sighted users — the full label only reaches screen readers.
* Matches the pattern used by `ProductSwitcher`.
*/
scope?: "Schools" | "Sites"
customIndex?: number
}
function productRefFromOption(option: ProductListOption): ProductRef {
return option.customIndex !== undefined
? { product: option.value, customIndex: option.customIndex }
: { product: option.value }
}
import {
BUILTIN_SETTINGS_PRODUCTS,
} from "@/lib/product-switcher-catalog"
function labelForProductRef(
ref: ProductRef,
customProducts: CustomProductBrand[],
): string {
if (ref.product === "exxat-custom" && ref.customIndex !== undefined) {
const brand = customProducts[ref.customIndex]
return brand
? productBrandLabel(customProductBrandConfig(brand))
: "Custom product"
}
return (
BUILTIN_SETTINGS_PRODUCTS.find(entry => entry.id === ref.product)?.label ??
ref.product
)
}
type DeleteProductTarget = {
product: Product
customIndex?: number
}
type BrandConfig = ReturnType
const CONTRAST_LABEL = {
system: "System",
normal: "Normal",
high: "High",
windows: "Windows",
} as const
const TEXT_SIZE_SAMPLE_CLASS: Record = {
compact: "text-sm",
default: "text-lg",
large: "text-2xl",
}
function useSafeAppearance() {
const { theme } = useTheme()
const { mounted } = useAppTheme()
const safeTheme = mounted ? ((theme ?? "system") as "system" | "light" | "dark") : "system"
return { safeTheme, mounted }
}
function sectionHeaderCopy(
showProducts: boolean,
showDisplay: boolean,
productAuthoringEnabled: boolean,
): { title: string; description: string } {
if (!(showProducts && !showDisplay)) {
return { title: "Appearance & display", description: "Saved in this browser." }
}
return {
title: "Products & branding",
description: productAuthoringEnabled
? "Workspace-wide, shared across every product in this browser. Add products, set default startup, and tune panel tints."
: "Products shipped on this deploy are listed below. Builders author and rebrand them in dev, then commit and redeploy.",
}
}
function productsRowDescription(productAuthoringEnabled: boolean): string {
return productAuthoringEnabled
? "Builder-only. End users see new products only after you intentionally ship the generated tenant-products.json and redeploy this app."
: "Products available on this deploy. Switch to Builder mode to add, rebrand, or hide products."
}
function isSameOption(a: ProductListOption, b: ProductListOption): boolean {
return a.value === b.value && a.customIndex === b.customIndex
}
function isOptionActive(
option: ProductListOption,
activeProduct: Product,
activeCustomIndex: number | undefined,
): boolean {
return (
activeProduct === option.value &&
(option.customIndex === undefined || activeCustomIndex === option.customIndex)
)
}
function optionBrand(
option: ProductListOption,
customProducts: CustomProductBrand[],
productBrandColors: Parameters[2],
): BrandConfig {
const customBrand =
option.customIndex !== undefined ? customProducts[option.customIndex] : null
return brandForProduct(option.value, customBrand, productBrandColors)
}
function optionKey(option: ProductListOption): string {
return option.customIndex !== undefined
? `${option.value}-${option.customIndex}`
: option.value
}
function optionPickerId(option: ProductListOption): string {
const suffix = option.customIndex !== undefined ? `-${option.customIndex}` : ""
return `settings-product-color-${option.value}${suffix}`
}
function blockedReasonForDraft(
nameDraft: string,
colorDraft: string,
customProducts: CustomProductBrand[],
): string | null {
const suffix = nameDraft.trim()
if (!suffix) return "Enter a product name after Exxat."
const brandColor = colorDraft.trim() || DEFAULT_CUSTOM_PRODUCT_BRAND.brandColor
if (isCustomProductPlaceholder({ suffix, brandColor })) {
return "Pick a name other than Custom, or change the brand color."
}
return validateCustomProductSuffix(suffix, customProducts)
}
function prefersDark(safeTheme: "system" | "light" | "dark"): boolean {
if (safeTheme !== "system") return safeTheme === "dark"
return typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches
}
/**
* Persist the new product's artifacts and return the hint to show.
*
* In dev with the builder dev-sync Vite plugin active, the catalog is already
* being written to `public/tenant-products.json` on disk by the middleware
* every time the tenant store changes. Firing the browser-side `download*`
* helpers in that mode just produces redundant "Save As" dialogs, so they are
* skipped when dev-sync is live; they remain wired for production builds.
*/
function persistNewProduct(suffix: string, brandColor: string): string {
if (isBuilderDevSyncEnvironment()) {
return "Saved to ignored public/tenant-products.json on the dev server. Force-add it only when you intend to ship this product."
}
downloadShippedTenantCatalog()
downloadProductScaffold(tenantRecordFromCustomBrand(suffix, brandColor))
return "Downloaded public/tenant-products.json and scaffold files. Force-add the catalog only when you intend to ship it, then pnpm build and deploy."
}
function applyColorChange({
option,
customBrand,
defaultConfig,
next,
updateCustomProduct,
setProductBrandColor,
}: {
option: ProductListOption
customBrand: CustomProductBrand | null
defaultConfig: BrandConfig | undefined
next: string
updateCustomProduct: (index: number, brand: CustomProductBrand) => void
setProductBrandColor: (product: Product, color: string | null) => void
}) {
const normalized = normalizeBrandAccentColor(next)
if (option.customIndex !== undefined && customBrand) {
updateCustomProduct(option.customIndex, {
suffix: customBrand.suffix.trim() || DEFAULT_CUSTOM_PRODUCT_BRAND.suffix,
brandColor: normalized,
})
setProductBrandColor("exxat-custom", null)
return
}
const matchesDefault = defaultConfig && brandColorsEquivalent(normalized, defaultConfig.brandColor)
setProductBrandColor(option.value, matchesDefault ? null : normalized)
}
const STATUS_PILL =
"inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium uppercase tracking-wide text-foreground"
function ActiveBadge() {
return (
Active
)
}
function DefaultBadge() {
return (
Default
)
}
function DefaultStartupSlot({
isDefault,
authoringEnabled,
onSetDefault,
}: {
isDefault: boolean
authoringEnabled: boolean
onSetDefault: () => void
}) {
if (isDefault) return
if (!authoringEnabled) return null
return (
Set as default
)
}
function ProductColorControl({
option,
config,
defaultConfig,
usedBy,
authoringEnabled,
onChange,
}: {
option: ProductListOption
config: BrandConfig
defaultConfig: BrandConfig | undefined
usedBy: Record
authoringEnabled: boolean
onChange: (next: string) => void
}) {
if (!authoringEnabled) {
return (
)
}
const pickerId = optionPickerId(option)
return (
<>
Brand color for {option.label}
>
)
}
/**
* Per-row overflow: delete (custom only) or hide (any non-active built-in).
* Active products can't be hidden — the user has to switch first, which
* prevents the picker from becoming unreachable.
*/
function ProductRowOverflow({
option,
authoringEnabled,
onDelete,
onHide,
}: {
option: ProductListOption
authoringEnabled: boolean
onDelete: () => void
onHide: () => void
}) {
if (!authoringEnabled) return null
const canDelete = option.customIndex !== undefined
const label = canDelete ? `Remove ${option.label}` : `Hide ${option.label} from switcher`
return (
)
}
function ProductRow({
option,
productOptions,
onRequestDelete,
}: {
option: ProductListOption
productOptions: ProductListOption[]
onRequestDelete: (target: DeleteProductTarget) => void
}) {
const productAuthoringEnabled = useProductAuthoringEnabled()
const {
product: activeProduct,
activeCustomIndex,
customProducts,
updateCustomProduct,
productBrandColors,
setProductBrandColor,
hideProduct,
startupProduct,
setStartupProduct,
} = useProduct()
const switchProduct = useProductSwitch()
const customBrand =
option.customIndex !== undefined ? customProducts[option.customIndex] : null
const config = optionBrand(option, customProducts, productBrandColors)
const defaultConfig =
option.value === "exxat-custom"
? customProductBrandConfig(customBrand)
: getProductBrand(option.value)
const isActive = isOptionActive(option, activeProduct, activeCustomIndex)
const rowRef = productRefFromOption(option)
const isDefault = isStartupProductRef(rowRef, startupProduct)
const usedBy: Record = {}
for (const other of productOptions) {
if (isSameOption(other, option)) continue
const otherConfig = optionBrand(other, customProducts, productBrandColors)
const otherActive = isOptionActive(other, activeProduct, activeCustomIndex)
usedBy[otherConfig.brandColor] = otherActive ? `${other.label} (active)` : other.label
}
const handleColorChange = (next: string) => {
applyColorChange({
option,
customBrand,
defaultConfig,
next,
updateCustomProduct,
setProductBrandColor,
})
if (isActive) {
requestAnimationFrame(() => syncActiveProductThemeFromStore())
}
}
const handleSetDefault = () => {
setStartupProduct(rowRef)
switchProduct(rowRef.product, rowRef.customIndex)
}
return (
{option.label}
{option.scope && (
· {option.scope}
)}
onRequestDelete({ product: option.value, customIndex: option.customIndex })
}
onHide={() => hideProduct(rowRef)}
/>
)
}
function AddProductHint({ blockedReason, publishHint }: { blockedReason: string | null; publishHint: string | null }) {
return (
<>
{blockedReason ? (
{blockedReason}
) : (
Type the suffix after Exxat. The wordmark stays Exxat pink; the
panel tint follows your brand color. After Add, review the generated{" "}
public/tenant-products.json and
force-add it only for a deploy that should ship this product.
)}
{publishHint ? (
{publishHint}
) : null}
>
)
}
function AddProductPanel() {
const { customProducts, addCustomProduct } = useProduct()
const switchProduct = useProductSwitch()
const { safeTheme } = useSafeAppearance()
const productNameId = React.useId()
const productColorId = React.useId()
const [open, setOpen] = React.useState(false)
const [nameDraft, setNameDraft] = React.useState("")
const [colorDraft, setColorDraft] = React.useState(DEFAULT_CUSTOM_PRODUCT_BRAND.brandColor)
const [publishHint, setPublishHint] = React.useState(null)
const previewBrand = React.useMemo(
() => ({
suffix: nameDraft.trim() || "Product",
brandColor: normalizeBrandAccentColor(
colorDraft.trim() || DEFAULT_CUSTOM_PRODUCT_BRAND.brandColor,
),
}),
[colorDraft, nameDraft],
)
const blockedReason = React.useMemo(
() => blockedReasonForDraft(nameDraft, colorDraft, customProducts),
[customProducts, colorDraft, nameDraft],
)
const panelSurfaces = React.useMemo(
() => brandPreviewPanelSurfaces(previewBrand.brandColor, prefersDark(safeTheme)),
[previewBrand.brandColor, safeTheme],
)
const resetDrafts = () => {
setNameDraft("")
setColorDraft(DEFAULT_CUSTOM_PRODUCT_BRAND.brandColor)
}
const handleToggle = () => {
const next = !open
setOpen(next)
if (next) resetDrafts()
}
const handleAdd = () => {
const suffix = nameDraft.trim()
const brandColor = normalizeBrandAccentColor(
colorDraft.trim() || DEFAULT_CUSTOM_PRODUCT_BRAND.brandColor,
)
if (!suffix || blockedReason) return
const nextIndex = addCustomProduct({ suffix, brandColor })
switchProduct("exxat-custom", nextIndex)
setPublishHint(persistNewProduct(suffix, brandColor))
setOpen(false)
resetDrafts()
}
return (
Add product
Create a product name and brand color.
{open ? (
) : null}
)
}
function HiddenProductsList() {
const { hiddenProducts, showProduct, customProducts } = useProduct()
if (hiddenProducts.length === 0) return null
return (
Hidden:
{hiddenProducts.map(ref => (
showProduct(ref)}
>
Show {labelForProductRef(ref, customProducts)}
))}
)
}
/** Destructive confirm for removing the Custom slot — routed through a dialog per the no-toast rule. */
function DeleteProductDialog({
open,
onOpenChange,
targetRef,
}: {
open: boolean
onOpenChange: (open: boolean) => void
targetRef: React.MutableRefObject
}) {
const { product: activeProduct, activeCustomIndex, removeCustomProduct } = useProduct()
const switchProduct = useProductSwitch()
const handleRemove = () => {
const target = targetRef.current
if (target?.product === "exxat-custom" && target.customIndex !== undefined) {
removeCustomProduct(target.customIndex)
if (activeProduct === "exxat-custom" && activeCustomIndex === target.customIndex) {
switchProduct("exxat-prism")
}
}
onOpenChange(false)
targetRef.current = null
}
return (
Remove custom product?
The slot will disappear from the switcher. You can re-add it
later from this page; brand colour and name will reset to
defaults.
onOpenChange(false)}>
Cancel
Remove
)
}
// Exxat ships **four apps** in the product switcher: Prism, One — Schools,
// One — Sites, and Custom (Prism IA with tenant-configured branding). Both
// Exxat One variants share the indigo accent + pink wordmark; the
// brand-color picker here recolours each independently so a workspace can
// theme one without affecting the other. The Custom slot only appears in
// this list once the tenant has configured a suffix + brand color via the
// "Add product" affordance below. See
// `apps/web/docs/multi-product-routing-pattern.md`.
function useProductOptions(): ProductListOption[] {
const { customProducts, hiddenProducts } = useProduct()
return React.useMemo((): ProductListOption[] => {
const builtIns: ProductListOption[] = BUILTIN_SETTINGS_PRODUCTS.map(entry => ({
value: entry.id,
label: entry.label,
scope: entry.scope,
}))
const customs: ProductListOption[] = customProducts.flatMap((cp, customIndex) =>
isListedCustomProduct(cp) && !customSuffixCollidesWithBuiltInProduct(cp.suffix)
? [{ value: "exxat-custom" as const, label: `Exxat ${cp.suffix}`, customIndex }]
: [],
)
return [...builtIns, ...customs].filter(
option => !isProductRefHidden(productRefFromOption(option), hiddenProducts),
)
}, [customProducts, hiddenProducts])
}
function ProductsSettingsRow() {
const productAuthoringEnabled = useProductAuthoringEnabled()
const productOptions = useProductOptions()
const [deleteProductOpen, setDeleteProductOpen] = React.useState(false)
const deleteProductTargetRef = React.useRef(null)
const requestDelete = (target: DeleteProductTarget) => {
deleteProductTargetRef.current = target
setDeleteProductOpen(true)
}
return (
<>
{productOptions.map(option => (
))}
{productAuthoringEnabled ?
: null}
{productAuthoringEnabled ? : null}
>
)
}
function DisplaySettingsRows() {
const { setTheme } = useTheme()
const { setContrast, setTextSize, contrastPref, textSizePref, mounted } = useAppTheme()
const { product: activeProduct } = useProduct()
const { safeTheme } = useSafeAppearance()
const { activeView, setActiveView } = useDashboardView()
const { chartVariant, setChartVariant } = useChartVariant()
const safeBrand = mounted ? previewBrandForProduct(activeProduct) : "one"
const safeContrast = mounted ? contrastPref : "system"
const safeTextSize = mounted ? textSizePref : "default"
const themeTiles = React.useMemo(
() =>
(["system", "light", "dark"] as const).map((m) => ({
value: m,
label: THEME_CHOICE_LABEL[m],
leading: ,
})),
[safeBrand],
)
const contrastTiles = React.useMemo(
() =>
(["system", "normal", "high", "windows"] as const).map((p) => ({
value: p,
label: CONTRAST_LABEL[p],
leading: ,
})),
[safeBrand],
)
const textSizeTiles = React.useMemo(
() =>
(["compact", "default", "large"] as const).map((v) => ({
value: v,
label: TEXT_SIZE_LABEL[v],
leading: (
Aa
),
})),
[],
)
return (
<>
className="w-full"
labelPlacement="below"
options={themeTiles}
columns={4}
value={safeTheme}
onValueChange={(v) => setTheme(v)}
interaction="button"
/>
className="w-full"
labelPlacement="below"
options={contrastTiles}
columns={4}
value={safeContrast}
onValueChange={(v) => setContrast(v)}
interaction="button"
/>
className="w-full"
labelPlacement="below"
options={textSizeTiles}
columns={4}
value={safeTextSize}
onValueChange={(v) => setTextSize(v)}
interaction="button"
/>
setActiveView(v as DashboardView)}
className="flex flex-col gap-3"
aria-label="Dashboard view"
itemVariant="outline"
itemMotion="glow"
>
setChartVariant(v as ChartVariant)}
>
{(Object.keys(CHART_LABELS) as ChartVariant[]).map((key) => (
{CHART_LABELS[key]}
))}
>
)
}
export function SettingsAppearanceCard({
mode = "display-only",
}: {
/** `products-only` — workspace/org (Add product). `display-only` — personal display prefs. */
mode?: SettingsAppearanceMode
}) {
const showProducts = mode === "products-only" || mode === "all"
const showDisplay = mode === "display-only" || mode === "all"
const productAuthoringEnabled = useProductAuthoringEnabled()
const { mounted } = useSafeAppearance()
const header = sectionHeaderCopy(showProducts, showDisplay, productAuthoringEnabled)
return (
{header.title}
{header.description}
{!mounted && showDisplay ? (
Loading theme…
) : (
{showProducts ? : null}
{showDisplay ? : null}
)}
)
}