Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

feat(branding): introduce support for icon-only branding and flexible logo configurations (#428)>

Govinda Vashishtha3539da2adc5b
diff --git a/.changeset/brand-icon-wordmark.md b/.changeset/brand-icon-wordmark.md
new file mode 100644
index 000000000..a4e82360a
--- /dev/null
+++ b/.changeset/brand-icon-wordmark.md
@@ -0,0 +1,6 @@
+---
+"@truefoundry/trueforge-ui": minor
+"@truefoundry/trueforge": patch
+---
+
+Add `brand.mode` (`icon-title` | `icon-only` | `logo`) so hosts pick chrome look first; `name` always labels the mark, and `resolveBrandChrome` maps mode to layout chrome.
diff --git a/docs/ui-sdk/guides/layouts-and-theme.mdx b/docs/ui-sdk/guides/layouts-and-theme.mdx
index 34bddbbec..529749af4 100644
--- a/docs/ui-sdk/guides/layouts-and-theme.mdx
+++ b/docs/ui-sdk/guides/layouts-and-theme.mdx
@@ -58,22 +58,37 @@ Built-in layouts are code-split, so only the layout you use is loaded into your
## Preset Themes
-Choose from four built-in themes - Claude, ChatGPT, Gemini, and TrueFoundry, or create a [custom theme](../setup-custom-ui/custom-theme) to match your brand.
+Choose from four built-in themes - Claude, ChatGPT, Gemini, and TrueForge, or create a [custom theme](../setup-custom-ui/custom-theme) to match your brand.
## The theme object
```ts
+type BrandImage = string | { src?: string; light?: string; dark?: string };
+
+type BrandMode = "icon-title" | "icon-only" | "logo";
+
+type BrandConfig =
+ | { mode: "icon-title"; name: string; icon?: BrandImage; logo?: never; href?: string }
+ | { mode: "icon-only"; name: string; icon: BrandImage; logo?: never; href?: string }
+ | { mode: "logo"; name: string; icon: BrandImage; logo: BrandImage; href?: string };
+
type ThemeConfig = {
preset?: "trueforge" | "claude" | "chatgpt" | "gemini"; // default "trueforge"
mode?: "light" | "dark" | "system";
- brand?: {
- name: string; // required when `brand` is set
- logo?: string | BrandLogoConfig;
- },
+ brand?: BrandConfig;
...
};
```
+Set `brand.mode`, then pass the fields that mode requires. `name` always labels the mark.
+
+| Look | `mode` | Required | Expanded | Collapsed |
+| --- | --- | --- | --- | --- |
+| Default | omit `brand` | — | TrueForge wordmark | TrueForge square |
+| Icon + title | `"icon-title"` | `name` (+ optional `icon`) | square + title | square |
+| Icon only | `"icon-only"` | `name`, `icon` | square | square |
+| Wide logo | `"logo"` | `name`, `icon`, `logo` | wide logo | square |
+
```tsx App.tsx
<TrueForgeUI
...
@@ -81,13 +96,20 @@ type ThemeConfig = {
preset: "trueforge",
mode: "system",
brand: {
- name: "TrueForge",
- logo: "/logo.svg",
+ mode: "logo",
+ name: "Acme",
+ icon: "/icon.svg",
+ logo: "/wordmark.svg",
}
}}
/>
```
+`icon` is the square asset used in collapsed and compact surfaces. `logo` is the wider
+asset used when `mode` is `"logo"` and requires `icon` as its compact fallback. When
+`brand` is omitted, expanded chrome uses the built-in TrueForge wordmark and compact
+surfaces use the built-in square mark.
+
The `chatgpt`, `claude`, and `gemini` themes are shown below:
<Columns cols={3}>
@@ -124,24 +146,30 @@ You can also provide separate logos for light and dark modes, allowing your bran
theme={{
...
brand: {
- name: "TrueForge",
+ mode: "logo",
+ name: "Acme",
+ icon: {
+ light: "/icon/light.svg",
+ dark: "/icon/dark.svg",
+ },
logo: {
- light: "/logo/light.svg",
- dark: "/logo/dark.svg",
- href: "https://trueforge.dev", // URL to redirect on logo click
+ light: "/wordmark/light.svg",
+ dark: "/wordmark/dark.svg",
},
+ href: "https://example.com",
}
}}
/>
```
-The logo source is selected based on the resolved theme mode. When mode is omitted, the logo automatically follows the system theme.
+The icon and logo sources are selected based on the resolved theme mode. When mode is omitted, they automatically follow the system theme.
-* Provide both light and dark to use a different logo for each mode.
-* Provide only one of light or dark to use the same logo in both modes.
-* Use src for a mode-independent logo.
-* `name` sets the brand name in the topbar right next to the logo.
-* Set `href` to make the logo clickable.
+* Provide both light and dark to use a different image for each mode.
+* Provide only one of light or dark to use the same image in both modes.
+* Use src for a mode-independent image.
+* Set `brand.mode` first (`icon-title` | `icon-only` | `logo`); `name` is required and always labels images.
+* Visible title text only appears for `mode: "icon-title"`.
+* Set the brand-level `href` to make configured images clickable.
For more advanced use cases, such as rendering an inline SVG or an animated logo, override the BrandLogo slot instead of passing a React node through the theme object.
diff --git a/docs/ui-sdk/reference/theme.mdx b/docs/ui-sdk/reference/theme.mdx
index ac8361a97..e7225ebf4 100644
--- a/docs/ui-sdk/reference/theme.mdx
+++ b/docs/ui-sdk/reference/theme.mdx
@@ -9,7 +9,7 @@ description: "Theme provider, hooks, presets, brand, and slots."
| --- | --- |
| `ThemeProvider` | Owns light/dark/system state and injects token CSS variables on a wrapper `div.aui-theme-root`. |
| `SlotsProvider` | Slot override registry. Must sit outside `TrueFoundryChatProvider`. |
-| `BrandLogo` | The product mark: renders `theme.brand.logo` for the active mode as an image labelled with `theme.brand.name`, linked when the config sets `href`. Falls back to the default mark. Overridable slot. Props: `{ className? }`. |
+| `BrandLogo` | Product mark. `variant="icon"` renders the compact square asset; `variant="logo"` renders the wider asset and falls back to the icon. With no brand override, the logo variant uses the built-in TrueForge wordmark. Overridable slot. Props: `{ className?, variant?: "icon" \| "logo" }`. |
| `Icon` | Renders a built-in icon by name, or your replacement when `theme.icons` maps that name. Props: `{ name: string \| readonly string[] } & IconProps`. An array resolves to its **last** element, accommodating Font Awesome-style `["far", "clone"]` tuples; it is not a fallback chain. An unresolved name renders nothing. |
## Hooks
@@ -19,7 +19,8 @@ description: "Theme provider, hooks, presets, brand, and slots."
| `useTheme()` | `{ preset, mode, preference, isDark, setTheme }`. `setTheme` is a no-op when `theme.mode` is controlled. |
| `useThemeMode()` | Resolved `"light" \| "dark"`. Reads the mode published by `SlotsProvider`, so it returns `"light"` when no `SlotsProvider` is above it — even in dark mode. |
| `useBrand()` | The active `BrandConfig`. |
-| `useBrandName()` | `theme.brand.name`, or `"TrueForge"` when unset. Safe outside a provider. |
+| `useBrandName()` | The configured name; `undefined` for unnamed custom branding; or `"TrueForge"` when no custom image is configured. Safe outside a provider. |
+| `resolveBrandChrome(brand)` | `{ expandedVariant, collapsedVariant, showTitle }` from `brand.mode`. Prefer this over re-deriving field combinations. |
| `useThemeIcons()` | The `IconMap` from `theme.icons`. |
| `useContentClassNames()` | `theme.classNames`; throws outside a provider. |
| `useOptionalContentClassNames()` | Same, but returns `{}` outside a provider instead of throwing — no null check needed. |
@@ -35,8 +36,8 @@ description: "Theme provider, hooks, presets, brand, and slots."
## Types
-`ThemeConfig`, `ThemeMode`, `ThemePreset`, `SemanticTokens`, `BrandConfig`, `BrandLogoConfig`,
-`ContentClassNames`, `IconMap`, `ThemeIconProps`, `IconProps`, `LayoutProp`, `AtomSlots`,
+`ThemeConfig`, `ThemeMode`, `ThemePreset`, `SemanticTokens`, `BrandConfig`, `BrandMode`, `BrandImage`, `BrandLogoConfig`,
+`BrandChrome`, `ContentClassNames`, `IconMap`, `ThemeIconProps`, `IconProps`, `LayoutProp`, `AtomSlots`,
`SlotOverrides`.
```ts
diff --git a/docs/ui-sdk/reference/trueforge-ui.mdx b/docs/ui-sdk/reference/trueforge-ui.mdx
index d18f722d5..7a00849cd 100644
--- a/docs/ui-sdk/reference/trueforge-ui.mdx
+++ b/docs/ui-sdk/reference/trueforge-ui.mdx
@@ -132,15 +132,29 @@ import { TrueForgeUI } from "@truefoundry/trueforge-ui";
</Expandable>
</ParamField>
<ParamField path="brand" type="BrandConfig">
- Optional. Omit it to keep the default mark and the `"TrueForge"` name; setting it
- requires a `name`.
+ Optional. Omit it to use the built-in TrueForge wordmark in expanded chrome and
+ square mark in compact surfaces. When set, choose `mode` first, then pass the
+ fields that mode requires.
<Expandable title="BrandConfig">
- <ParamField path="name" type="string" required>
- Shown beside the mark, and used as the logo's accessible label.
+ <ParamField path="mode" type='"icon-title" | "icon-only" | "logo"'>
+ Chrome look. `icon-title` shows `name` beside the square mark; `icon-only`
+ and `logo` keep `name` for alt only.
+ </ParamField>
+ <ParamField path="name" type="string">
+ Required. Accessible image label (`alt` / `aria-label`). Also shown as title
+ text beside the square icon when `mode` is `icon-title`.
+ </ParamField>
+ <ParamField path="icon" type="string | BrandLogoConfig">
+ Square image used in collapsed and compact surfaces. Optional for
+ `icon-title` (default mark); required for `icon-only` and `logo`.
</ParamField>
<ParamField path="logo" type="string | BrandLogoConfig">
- Image URL, or per-mode sources. Omit to pair your name with the default mark.
+ Wider image used when `mode` is `logo`. Falls back to `icon` in
+ `BrandLogo` if needed. Required for `mode: "logo"`.
+ </ParamField>
+ <ParamField path="href" type="string">
+ Wraps configured brand images in a same-tab link.
</ParamField>
</Expandable>
@@ -154,14 +168,12 @@ import { TrueForgeUI } from "@truefoundry/trueforge-ui";
<ParamField path="src" type="string">
Mode-agnostic source, used when neither `light` nor `dark` is set.
</ParamField>
- <ParamField path="href" type="string">
- Wraps the logo in a same-tab link, labelled with `name`.
- </ParamField>
</Expandable>
A single configured mode is used for both modes, so `{ light }` alone never renders a
- missing image. To render a component rather than an image, override the `BrandLogo` slot
- through `overrides`.
+ missing image. Use `BrandLogo` with `variant="icon"` or `variant="logo"` in custom
+ layouts. To render a component rather than an image, override its slot through
+ `overrides`.
</ParamField>
<ParamField path="icons" type="IconMap">
Replace registry icons by name. Values are Lucide components, React nodes, render
@@ -238,7 +250,10 @@ Persisted sessions remain available through the thread list.
server={{ type: "truefoundry", apiKey, controlPlaneURL }}
layout="sidebar"
agentConfig={{ mode: "AgentComposer", defaultAgentSpec: { model: { name: "openai-main/gpt-4.1" } } }}
- theme={{ preset: "claude", brand: { name: "Acme", logo: "/logo.svg" } }}
+ theme={{
+ preset: "claude",
+ brand: { mode: "logo", name: "Acme", icon: "/icon.svg", logo: "/wordmark.svg" },
+ }}
overrides={{ ClearChatButton: MyClearButton }}
className="h-full min-h-0"
onError={(e) => reportError(e)}
diff --git a/packages/trueforge-ui/CHANGELOG.md b/packages/trueforge-ui/CHANGELOG.md
index 7f008bf30..d6c69d0e2 100644
--- a/packages/trueforge-ui/CHANGELOG.md
+++ b/packages/trueforge-ui/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## Unreleased
+
+### Minor Changes
+
+- **`brand.mode`** — explicit chrome look. Set `mode`, then pass the fields it requires.
+ `name` always labels the mark (`alt` / `aria-label`):
+ - **`'icon-title'`** — `name` + optional `icon` (title shown in expanded chrome)
+ - **`'icon-only'`** — `name` + `icon` (alt kept, no title text)
+ - **`'logo'`** — `name` + `icon` + `logo` (wordmark in expanded chrome; `name` is alt only)
+ - **Default** — omit `brand` for the TrueForge wordmark / square mark
+- **`resolveBrandChrome()`** — maps `brand.mode` to
+ `{ expandedVariant, collapsedVariant, showTitle }`. `SidebarLayout` uses it; custom
+ layouts should too.
+
+### Changed
+
+- **`BrandConfig`** — discriminated on `mode` (`BrandMode`). Removed `showTitle` from
+ config; visible title follows the mode.
+
## 0.2.4
### Patch Changes
diff --git a/packages/trueforge-ui/README.md b/packages/trueforge-ui/README.md
index 6a03ff83c..838d6e169 100644
--- a/packages/trueforge-ui/README.md
+++ b/packages/trueforge-ui/README.md
@@ -207,7 +207,7 @@ export default function App() {
}}
theme={{
preset: 'claude',
- brand: { name: 'Acme', logo: '/logo.svg' },
+ brand: { mode: 'icon-title', name: 'Acme', icon: '/icon.svg' },
}}
overrides={{/* slot overrides */}}
className="h-full"
@@ -319,7 +319,15 @@ package). Host CSS on `.aui-markdown` / `.aui-syntax-highlighter` / `.aui-openui
## Brand / logo
-**Base layouts** — pass `theme.brand` and the SDK positions the mark + name in the default slots:
+Set `brand.mode`, then pass the fields that mode requires. `name` always labels the
+mark (`alt` / `aria-label`).
+
+| Look | `mode` | Required | Expanded chrome | Collapsed / compact |
+| ------------ | -------------- | -------------------------- | ------------------------- | ------------------- |
+| Default | omit `brand` | — | TrueForge wordmark | TrueForge square |
+| Icon + title | `'icon-title'` | `name` (+ optional `icon`) | square + title text | square |
+| Icon only | `'icon-only'` | `name`, `icon` | square (no title text) | square |
+| Wide logo | `'logo'` | `name`, `icon`, `logo` | wide logo (no title text) | square |
```tsx
<TrueForgeUI
@@ -327,15 +335,28 @@ package). Host CSS on `.aui-markdown` / `.aui-syntax-highlighter` / `.aui-openui
layout="sidebar"
theme={{
brand: {
+ mode: 'icon-title',
name: 'Acme',
- logo: '/brand/logo.svg',
+ icon: '/brand/icon.svg',
},
}}
/>
```
-**Light / dark marks** — pass `light` / `dark` sources instead and the SDK picks the one matching
-the resolved mode. `href` wraps the logo in a same-tab link:
+Icon-only chrome (`name` kept for alt):
+
+```tsx
+theme={{
+ brand: {
+ mode: 'icon-only',
+ name: 'Acme',
+ icon: '/brand/icon.svg',
+ },
+}}
+```
+
+Wide logo for expanded chrome. A square `icon` is required because collapsed chrome,
+the welcome screen, and the widget button continue to use the square asset:
```tsx
<TrueForgeUI
@@ -343,14 +364,19 @@ the resolved mode. `href` wraps the logo in a same-tab link:
layout="sidebar"
theme={{
brand: {
+ mode: 'logo',
name: 'Acme',
- logo: { light: '/brand/logo-light.svg', dark: '/brand/logo-dark.svg', href: '/' },
+ icon: '/brand/icon.svg',
+ logo: '/brand/wordmark.svg',
+ href: '/',
},
}}
/>
```
-Set only one mode and it is used for both. `name` labels the image, so no `alt` is needed.
+Both `icon` and `logo` accept `{ src, light, dark }`. The SDK picks the source matching the
+resolved theme mode; setting only one light/dark source uses it for both. `href` wraps
+configured images in a same-tab link.
**Component marks** — `theme.brand` takes image URLs only. To render an inline SVG or a custom
component, override the `BrandLogo` slot, the same way you replace any other atom:
@@ -359,7 +385,10 @@ component, override the `BrandLogo` slot, the same way you replace any other ato
<TrueForgeUI server={server} layout="sidebar" overrides={{ BrandLogo: MyMark }} />
```
-**Custom layouts** — import `BrandLogo` and place it anywhere; pair it with `useBrandName()` when you also want the name as text (see [Custom layouts](#custom-layouts)).
+**Custom layouts** — import `BrandLogo` and use `variant="icon"` for compact surfaces or
+`variant="logo"` for expanded chrome. Prefer `resolveBrandChrome(useBrand())` so expanded
+vs collapsed choices match the base layouts. Pair with `useBrandName()` when chrome should
+show the title text (see [Custom layouts](#custom-layouts)).
> _Screenshot: external brand mark rendered in the base layout header._
@@ -429,17 +458,15 @@ Built-in `layout` values:
For full control, pass a React component as `layout`. The SDK still wires server, shell mode, slots, and runtime behind it.
```tsx
-import { Thread, ThreadListContainer, BrandLogo, useBrandName, useTheme } from '@truefoundry/trueforge-ui';
+import { Thread, ThreadListContainer, BrandLogo, useTheme } from '@truefoundry/trueforge-ui';
function Layout({ className }: { className?: string }) {
const { mode, setTheme } = useTheme();
- const brandName = useBrandName();
return (
<div className={className} style={{ display: 'flex', height: '100%' }}>
<aside style={{ width: 256 }}>
- <BrandLogo className="size-6" />
- <span>{brandName}</span>
+ <BrandLogo variant="logo" className="h-6 w-auto max-w-40" />
<ThreadListContainer />
</aside>
<main style={{ flex: 1, minWidth: 0 }}>
@@ -587,6 +614,7 @@ See [docs/server.md](./docs/server.md) for the full method list and BYO guidance
| `TrueForgeServerConfig` | Type | `server` prop: `truefoundry` / `trueforge` / `AgentUIServer` |
| `createTrueFoundryServer` | Function | Compose chat + builder into `AgentUIServer` |
| `Thread`, `ThreadListContainer`, `BrandLogo` | Components | Layout primitives for custom layouts |
+| `resolveBrandChrome`, `useBrandName`, `useBrand` | Helpers | Brand chrome look + name for custom layouts |
| Composer / message / tool atoms | Components | Overridable, themeable building blocks |
| `SlotsProvider`, `useSlot`, `useTheme` | API | Overrides + theme mode |
| `AgentUIServer`, `AgentChatServer`, `AgentBuilderServer` | Types | Resolved server contract |
diff --git a/packages/trueforge-ui/docs/customization.md b/packages/trueforge-ui/docs/customization.md
index 1b24229ba..85392bb6b 100644
--- a/packages/trueforge-ui/docs/customization.md
+++ b/packages/trueforge-ui/docs/customization.md
@@ -29,7 +29,7 @@ over hacking third-party CSS:
preset: 'claude',
mode: 'dark',
tokens: { primary: '#e11d48' },
- brand: { name: 'Acme', logo: '/brand/logo.svg' },
+ brand: { mode: 'logo', name: 'Acme', icon: '/brand/icon.svg', logo: '/brand/wordmark.svg' },
icons: { send: MySendSvg },
classNames: {
markdown: 'prose max-w-none',
diff --git a/packages/trueforge-ui/docs/server.md b/packages/trueforge-ui/docs/server.md
index 7edf48f70..3c44e60e6 100644
--- a/packages/trueforge-ui/docs/server.md
+++ b/packages/trueforge-ui/docs/server.md
@@ -808,7 +808,9 @@ export function App() {
theme={{
preset: 'chatgpt',
brand: {
+ mode: 'logo',
name: 'MyCo',
+ icon: { src: '/myco-icon.svg' },
logo: { src: '/myco-wordmark.svg' },
},
}}
diff --git a/packages/trueforge-ui/docs/theming.md b/packages/trueforge-ui/docs/theming.md
index 7f53d33da..c5a22e703 100644
--- a/packages/trueforge-ui/docs/theming.md
+++ b/packages/trueforge-ui/docs/theming.md
@@ -16,7 +16,7 @@ the SDK. Layers (each independently overridable):
| ------------------ | -------------------------------------------- | --------------------------------------------- |
| Preset | Baseline look | `theme.preset` |
| Tokens | Colors, radius, fonts, bubble colors | `theme.tokens` + CSS vars |
-| Brand | Logo image + display name | `theme.brand` (marks via slots) |
+| Brand | Square icon, wide logo, and display name | `theme.brand` (marks via slots) |
| Icons | Action / UI icon set | `theme.icons` (Lucide + SVG transforms) |
| Content classNames | Markdown, syntax-highlighter, OpenUI, Monaco | `theme.classNames` |
| Root class | Arbitrary host utilities | `theme.className` |
@@ -41,7 +41,7 @@ track (orthogonal to [`docs/server.md`](./server.md)).
| Coverage | Everything currently pulled from tfy |
| Slot API | **Breaking** — drop `Button.Primary` / icon-string contracts; new shadcn-aligned props |
| Icons | Lucide defaults; host can replace map + supply SVG transforms |
-| Brand | Logo URL (per-mode) via `theme.brand`; component marks via the `BrandLogo` slot |
+| Brand | Icon/logo URLs (per-mode) via `theme.brand`; component marks via the `BrandLogo` slot |
| Theme API | Object (not string-only); every look aspect customizable |
| Presets | Inspired-by packs: `trueforge` (default), `claude`, `chatgpt`, `gemini` |
| Custom styles | CSS tokens + `className`; host may also import CSS (documented). No “load CSS file” prop |
@@ -84,12 +84,12 @@ props):
### Theme / icons / brand infra
-| Remove | Replace with |
-| -------------------------------- | ---------------------------------------------------------------------------- |
-| `tfy-web-components/theme.css` | Own palette + semantic tokens in `styles.css` |
-| tfy `ThemeProvider` / `useTheme` | SDK `ThemeProvider` owned here |
-| `IconProvider` + `registerIcons` | `IconRegistry` + `theme.icons` / `setIcons` |
-| Hard-coded TFY marks | `theme.brand.logo` consumed by header, welcome, widget FAB, avatar fallbacks |
+| Remove | Replace with |
+| -------------------------------- | ----------------------------------------------------------------------- |
+| `tfy-web-components/theme.css` | Own palette + semantic tokens in `styles.css` |
+| tfy `ThemeProvider` / `useTheme` | SDK `ThemeProvider` owned here |
+| `IconProvider` + `registerIcons` | `IconRegistry` + `theme.icons` / `setIcons` |
+| Hard-coded TFY marks | `theme.brand.icon` / `logo` consumed by header, welcome, and widget FAB |
### Code surfaces (Monaco + syntax highlighter)
@@ -171,17 +171,17 @@ type IconMap = Record<
>;
/**
- * Logo sources. `light` / `dark` pick per resolved theme mode and fall back to
- * each other, then to `src`. `href` wraps the logo in a same-tab link labelled
- * with the brand name.
+ * Brand image sources. `light` / `dark` pick per resolved theme mode and fall
+ * back to each other, then to `src`.
*/
type BrandLogoConfig = {
src?: string;
light?: string;
dark?: string;
- href?: string;
};
+type BrandImage = string | BrandLogoConfig;
+
/**
* Product branding — distinct from `icons` (UI chrome).
* Consumed wherever a product mark appears (header, welcome, widget FAB,
@@ -190,21 +190,24 @@ type BrandLogoConfig = {
* Images only: to render a component, override the `BrandLogo` slot instead, so
* brand marks follow the same replacement path as every other atom.
*
- * `theme.brand` is optional; setting it requires a `name` (it labels the logo).
- * `logo` is optional — omit it to pair host text with the stock mark.
+ * Set `mode`, then pass the fields that mode requires:
+ * - omit `brand`: TrueForge wordmark / square mark
+ * - `icon-title`: `name` + optional `icon`
+ * - `icon-only`: `name` + `icon`
+ * - `logo`: `name` + `icon` + `logo`
*/
-type BrandConfig = {
- /** Display name beside the mark, and the logo's accessible label. */
- name: string;
- /** Image URL, or per-mode sources. Omit to keep the default mark. */
- logo?: string | BrandLogoConfig;
-};
+type BrandMode = "icon-title" | "icon-only" | "logo";
+
+type BrandConfig =
+ | { mode: "icon-title"; name: string; icon?: BrandImage; logo?: never; href?: string }
+ | { mode: "icon-only"; name: string; icon: BrandImage; logo?: never; href?: string }
+ | { mode: "logo"; name: string; icon: BrandImage; logo: BrandImage; href?: string };
type ThemeConfig = {
preset?: ThemePreset; // default: "trueforge"
mode?: ThemeMode; // omit = uncontrolled (useTheme().setTheme)
tokens?: Partial<SemanticTokens>;
- brand?: BrandConfig; // logo image + display name
+ brand?: BrandConfig; // set brand.mode, then required fields
className?: string; // applied on .aui-root (or theme root)
icons?: IconMap; // full/partial UI icon replace + SVG transforms
/** Per-surface className hooks for content renderers */
@@ -269,7 +272,9 @@ function MyLayout({ className }: { className?: string }) {
mode: 'dark',
tokens: { primaryButtonBg: '#…', fontFamily: '"My Font", system-ui' },
brand: {
+ mode: 'logo',
name: 'Acme Agent',
+ icon: { light: '/acme-icon.svg', dark: '/acme-icon-dark.svg' },
logo: { light: '/acme-wordmark.svg', dark: '/acme-wordmark-dark.svg' },
},
className: 'my-chat',
@@ -326,21 +331,26 @@ as `children`.
1. All product marks render through `<BrandLogo />` — one component, never
hard-coded TFY assets in layouts or atoms. Layouts resolve it via `useSlot`, so
a host override reaches every call site.
-2. `BrandLogo` renders the mark only. Callers that also want the name as text pair
- it with `useBrandName()`, so each layout owns its own arrangement (the sidebar
- sets mark + name; the widget FAB and welcome screen show the mark alone). A
- second "wordmark" component would only re-encode one caller's arrangement.
-3. `theme.brand` carries **image sources only** (URL or `{ src, light, dark, href }`).
+2. Hosts pick chrome with `brand.mode` (`icon-title` | `icon-only` | `logo`).
+ Layout chrome uses `resolveBrandChrome(brand)` for expanded/collapsed mark
+ variant and whether to show the text title. Custom layouts should call the
+ same helper instead of re-deriving fields.
+3. `BrandLogo` renders `icon` for compact surfaces. With `variant="logo"`, it
+ renders the optional wider logo and falls back to the square icon.
+4. `theme.brand` carries **image sources only** (URL or `{ src, light, dark }`).
Component-valued marks go through the `BrandLogo` slot, so brand replacement
uses the same mechanism as every other atom instead of a second node-shaped
escape hatch in the theme config.
-4. `theme.brand.name` → the accessible label for a configured logo (and its link,
- when `href` is set), plus whatever text a caller renders alongside.
-5. Omitting `brand` keeps the default `TrueForge` name and robot mark.
-6. `{ light, dark }` sources resolve against the provider's mode, so a host mark
- tracks light/dark without a custom component. A single configured mode covers
- both, so `{ light }` alone never renders a missing image; a config with no
- usable source falls back to the default mark rather than an empty `<img>`.
+5. `theme.brand.name` is required with every mode and always labels configured
+ images. Visible title text only appears for `mode: 'icon-title'`. For
+ `icon-only` and `logo`, `name` is alt-only.
+6. Omitting `brand` keeps the default TrueForge wordmark in expanded chrome and
+ the square mark when collapsed. `href` wraps configured images in a same-tab
+ link.
+7. `{ light, dark }` sources resolve against the provider's theme mode, so a host
+ mark tracks light/dark without a custom component. A single configured source
+ covers both, so `{ light }` alone never renders a missing image; a config with
+ no usable source falls back to the default mark rather than an empty `<img>`.
## Icon system
@@ -354,7 +364,7 @@ as `children`.
identity stays separate from action icons.
For named UI icons the order is `theme.icons[name]` → registry default. The
-robot is also the final brand fallback, so `theme.brand.logo` still takes
+robot is also the final brand fallback, so `theme.brand.icon` still takes
precedence over `theme.icons.robot`. Preset-specific icons such as
`welcome-sparkle` and OAuth state icons (`oauth-loading`, `oauth-success`,
`oauth-error`) use the same lookup order.
@@ -374,7 +384,7 @@ compose path), for example:
- `Thread` / `ThreadContainer`
- `ThreadListContainer`
- `Composer` pieces / slot-backed atoms as needed
-- Brand helpers (`BrandLogo`, `useBrandName`) and `useTheme`
+- Brand helpers (`BrandLogo`, `resolveBrandChrome`, `useBrandName`) and `useTheme`
The shell still wraps the custom layout with theme + slots + chat provider;
only the chrome tree is replaced. Equivalent to skipping built-in layouts
@@ -471,7 +481,7 @@ TrueForgeUI({ layout, theme, overrides, … })
`<BrandLogo />`) even if defaults still point at TFY assets.
**Done when:** app runs with owned tokens (tfy components may still be present);
-host can override `--primary-button-bg` and swap `theme.brand.logo`.
+host can override `--primary-button-bg` and swap `theme.brand.icon` / `logo`.
### Phase 2 — shadcn primitives + icon + brand registry
@@ -533,7 +543,8 @@ no longer depends on tfy.
- Prefer
`theme={{ preset, tokens, brand, icons, className, classNames }}`
over hacking a third-party theme.
-- Replace product marks with `theme.brand.logo` (URL or per-mode sources), or
+- Replace product marks with `theme.brand.icon` and optional wide `logo` (URLs
+ or per-mode sources), or
override the `BrandLogo` slot for component marks.
- Pass `layout={MyLayout}` to own chrome; compose `Thread` /
`ThreadListContainer` / etc.
diff --git a/packages/trueforge-ui/src/atoms/WelcomeScreen.tsx b/packages/trueforge-ui/src/atoms/WelcomeScreen.tsx
index 7eee42d97..35579ba74 100644
--- a/packages/trueforge-ui/src/atoms/WelcomeScreen.tsx
+++ b/packages/trueforge-ui/src/atoms/WelcomeScreen.tsx
@@ -20,7 +20,7 @@ export function WelcomeScreen({ heading = 'How can I help you today?', icon, cla
) : preset === 'chatgpt' ? null : preset === 'claude' ? (
<Icon name="welcome-sparkle" className="size-5 fill-current text-primary-button-bg" />
) : (
- <BrandLogo className={'size-10'} />
+ <BrandLogo variant="icon" className="size-10" />
);
return (
diff --git a/packages/trueforge-ui/src/icons/trueforge-logo-dark.svg b/packages/trueforge-ui/src/icons/trueforge-logo-dark.svg
new file mode 100644
index 000000000..a46d05feb
--- /dev/null
+++ b/packages/trueforge-ui/src/icons/trueforge-logo-dark.svg
@@ -0,0 +1,13 @@
+<svg width="737" height="120" viewBox="0 0 737 120" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_10580_645)">
+<path d="M0 0.015625L40 20.0156V40L20 40V80.0156H40V100.016L0 120.016V0.015625Z" fill="white"/>
+<path d="M120 0L80 20V40H100V80H80V100L120 120V0Z" fill="white"/>
+<path d="M59.9971 39.8193C61.0556 45.6178 63.1951 50.1614 66.5771 53.5215C69.9455 56.868 74.4738 58.9678 80.2051 60.0088C74.4712 61.0714 69.9429 63.2075 66.5752 66.5752C63.1954 69.955 61.0558 74.5036 59.9971 80.2666C58.933 74.5031 56.7854 69.9547 53.4004 66.5752C50.0276 63.2078 45.4981 61.0704 39.7725 60.0078C45.4953 58.9668 50.0251 56.8676 53.3984 53.5215C56.7857 50.1616 58.9332 45.6182 59.9971 39.8193Z" fill="white" stroke="white" stroke-width="1.6" stroke-linejoin="round"/>
+</g>
+<path d="M622.099 24.752C631.17 24.752 637.822 27.7322 642.056 33.6934V27.084H659.938V90.4531C659.938 99.87 656.785 107.127 650.479 112.225C644.172 117.408 636.008 120 625.986 120C614.669 120 603.784 116.76 593.33 110.28L602.66 96.1553C611.559 101.252 619.248 103.801 625.728 103.801C635.835 103.801 640.89 98.7473 640.89 88.6396V84.752C636.57 89.8491 630.306 92.3975 622.099 92.3975C613.632 92.3974 606.548 89.2442 600.846 82.9375C595.23 76.6308 592.423 68.5094 592.423 58.5742C592.423 48.6393 595.23 40.5185 600.846 34.2119C606.548 27.9052 613.632 24.752 622.099 24.752ZM292.13 69.46C292.13 76.285 295.456 79.6982 302.108 79.6982C310.229 79.6982 314.29 75.421 314.29 66.8682V27.084H333.729V94.4707H315.975V87.3438C311.914 93.564 305.391 96.6738 296.406 96.6738C288.458 96.6738 282.497 94.773 278.522 90.9717C274.635 87.1704 272.691 81.7275 272.691 74.6436V27.084H292.13V69.46ZM378.339 24.752C388.62 24.752 396.525 27.7322 402.054 33.6934C407.669 39.6545 410.478 48.0349 410.478 58.834C410.478 61.2528 410.391 63.758 410.218 66.3496H362.658C364.732 75.5937 370.693 80.2158 380.542 80.2158C384.084 80.2158 387.237 79.6109 390.002 78.4014C392.766 77.1055 396.049 74.8595 399.851 71.6631L410.478 83.8447C401.579 92.3976 391.427 96.6738 380.023 96.6738C368.965 96.6738 360.153 93.4345 353.587 86.9551C347.108 80.4757 343.868 71.836 343.868 61.0371C343.868 50.4108 346.978 41.7279 353.198 34.9893C359.419 28.1642 367.799 24.752 378.339 24.752ZM499.098 24.752C509.465 24.752 517.974 28.121 524.626 34.8594C531.278 41.5116 534.604 50.1077 534.604 60.6475C534.604 71.2738 531.278 79.9566 524.626 86.6953C517.974 93.3474 509.465 96.6738 499.098 96.6738C488.644 96.6738 480.091 93.3476 473.438 86.6953C466.786 79.9567 463.46 71.2738 463.46 60.6475C463.46 50.1077 466.786 41.5116 473.438 34.8594C480.091 28.1207 488.644 24.752 499.098 24.752ZM704.464 24.752C714.745 24.752 722.65 27.7322 728.179 33.6934C733.794 39.6545 736.603 48.0349 736.603 58.834C736.603 61.2528 736.516 63.758 736.343 66.3496H688.783C690.857 75.5937 696.818 80.2158 706.667 80.2158C710.209 80.2158 713.362 79.6109 716.127 78.4014C718.891 77.1055 722.174 74.8595 725.976 71.6631L736.603 83.8447C727.704 92.3976 717.552 96.6738 706.148 96.6738C695.09 96.6738 686.278 93.4345 679.712 86.9551C673.233 80.4757 669.993 71.836 669.993 61.0371C669.993 50.4108 673.103 41.7279 679.323 34.9893C685.544 28.1642 693.924 24.752 704.464 24.752ZM194.087 27.085H209.249V41.5996H194.087V73.0898C194.087 75.3359 194.605 76.9345 195.642 77.8848C196.678 78.7486 198.277 79.1797 200.437 79.1797C202.078 79.1797 204.626 78.8347 208.082 78.1436L210.285 93.6943C204.842 95.3358 199.702 96.1562 194.864 96.1562C187.694 96.1562 182.51 94.6013 179.313 91.4912C176.203 88.3811 174.649 83.4137 174.648 76.5889V41.5996H162.855V27.085H174.648V7.3877H194.087V27.085ZM254.532 25.9189C257.21 25.9189 260.883 26.6959 265.548 28.251L261.919 45.3574C257.858 44.4071 254.921 43.9316 253.106 43.9316C248.787 43.9317 245.374 45.6162 242.869 48.9854C240.364 52.2683 239.111 56.8044 239.111 62.5928V94.4717H219.673V27.085H237.686V36.6748C241.314 29.5042 246.93 25.919 254.532 25.9189ZM579.519 25.9189C582.197 25.9189 585.869 26.6959 590.534 28.251L586.905 45.3574C582.845 44.4072 579.908 43.9317 578.094 43.9316C573.774 43.9316 570.361 45.616 567.855 48.9854C565.35 52.2683 564.098 56.8044 564.098 62.5928V94.4717H544.659V27.085H562.672V36.6748C566.3 29.5043 571.916 25.9191 579.519 25.9189ZM449.276 0C453.942 0 458.866 0.77795 464.05 2.33301L460.681 16.7168C458.175 16.1121 455.627 15.8096 453.035 15.8096C450.53 15.8096 448.758 16.3712 447.722 17.4941C446.685 18.5309 446.167 20.3892 446.167 23.0674V27.084H460.292V41.5986H446.167V94.4707H426.729V41.5986H415.454V27.084H426.729V22.2891C426.729 7.42983 434.244 0.000142379 449.276 0ZM499.098 41.209C494.346 41.209 490.501 42.9803 487.563 46.5225C484.626 50.0645 483.158 54.773 483.158 60.6475C483.158 66.6084 484.626 71.3603 487.563 74.9023C490.501 78.4445 494.346 80.2158 499.098 80.2158C503.849 80.2157 507.65 78.4444 510.501 74.9023C513.438 71.3602 514.907 66.6085 514.907 60.6475C514.907 54.7729 513.438 50.0645 510.501 46.5225C507.564 42.9806 503.763 41.2091 499.098 41.209ZM626.764 41.3389C622.358 41.3389 618.772 42.9373 616.008 46.1338C613.33 49.2439 611.99 53.3908 611.99 58.5742C611.99 63.7578 613.373 67.948 616.138 71.1445C618.902 74.341 622.444 75.9394 626.764 75.9395C631.17 75.9395 634.755 74.341 637.52 71.1445C640.284 67.948 641.667 63.7578 641.667 58.5742C641.667 53.3907 640.284 49.2439 637.52 46.1338C634.755 42.9374 631.17 41.3389 626.764 41.3389ZM378.08 39.9131C370.218 39.9131 365.207 44.1902 363.047 52.7432H391.945C390.995 44.1904 386.374 39.9132 378.08 39.9131ZM704.205 39.9131C696.343 39.9131 691.332 44.1902 689.172 52.7432H718.07C717.12 44.1904 712.499 39.9132 704.205 39.9131Z" fill="white"/>
+<defs>
+<clipPath id="clip0_10580_645">
+<rect width="120" height="120" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/packages/trueforge-ui/src/icons/trueforge-logo.svg b/packages/trueforge-ui/src/icons/trueforge-logo.svg
new file mode 100644
index 000000000..08d5127d7
--- /dev/null
+++ b/packages/trueforge-ui/src/icons/trueforge-logo.svg
@@ -0,0 +1,13 @@
+<svg width="614" height="100" viewBox="0 0 614 100" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_10581_1412)">
+<path d="M-0.00195312 0.0136719L33.3314 16.6803V33.334L16.6647 33.334V66.6803H33.3314V83.347L-0.00195312 100.014V0.0136719Z" fill="#05090E"/>
+<path d="M99.998 0L66.6647 16.6667V33.3333H83.3314V66.6667H66.6647V83.3333L99.998 100V0Z" fill="#05090E"/>
+<path d="M49.9961 33.1826C50.8782 38.0147 52.6612 41.8005 55.4795 44.6006C58.2863 47.3892 62.0592 49.1393 66.835 50.0068C62.057 50.8924 58.2839 52.6732 55.4775 55.4795C52.6611 58.2959 50.8784 62.0863 49.9961 66.8887C49.1093 62.0858 47.3189 58.2958 44.498 55.4795C41.6875 52.6735 37.9135 50.8924 33.1426 50.0068C37.9113 49.1393 41.6861 47.3898 44.4971 44.6016C47.3198 41.8016 49.1095 38.0151 49.9961 33.1826Z" fill="#6D58FB" stroke="#6D58FB" stroke-width="1.33333" stroke-linejoin="round"/>
+</g>
+<path d="M518.559 20.627C526.12 20.627 531.665 23.1106 535.193 28.0781V22.5703H550.1V75.3789C550.1 83.2261 547.47 89.2739 542.214 93.5215C536.957 97.8409 530.153 100.001 521.8 100.001C512.367 100.001 503.293 97.3008 494.58 91.9014L502.356 80.1299C509.773 84.3774 516.182 86.5019 521.583 86.502C530.008 86.502 534.221 82.2902 534.221 73.8672V70.627C530.62 74.8745 525.399 76.998 518.559 76.998C511.502 76.998 505.597 74.3706 500.845 69.1152C496.164 63.8597 493.823 57.0918 493.823 48.8125C493.823 40.5333 496.164 33.7663 500.845 28.5107C505.597 23.2553 511.502 20.627 518.559 20.627ZM315.383 20.627C323.952 20.627 330.541 23.1106 335.149 28.0781C339.83 33.0457 342.17 40.0293 342.17 49.0283C342.17 51.0441 342.098 53.1322 341.954 55.292H302.312C304.041 62.9954 309.01 66.8477 317.219 66.8477C320.171 66.8476 322.799 66.3429 325.104 65.335C327.408 64.2551 330.144 62.3835 333.312 59.7197L342.17 69.8711C334.753 76.9984 326.292 80.5624 316.787 80.5625C307.57 80.5625 300.225 77.8624 294.752 72.4629C289.351 67.0633 286.65 59.8635 286.65 50.8643C286.65 42.0091 289.243 34.7737 294.428 29.1582C299.612 23.4707 306.598 20.627 315.383 20.627ZM416.036 20.627C424.677 20.627 431.77 23.4346 437.314 29.0498C442.859 34.5934 445.632 41.7577 445.632 50.541C445.632 59.3961 442.859 66.6316 437.314 72.2471C431.77 77.7904 424.677 80.5625 416.036 80.5625C407.323 80.5625 400.194 77.7905 394.649 72.2471C389.105 66.6316 386.332 59.3961 386.332 50.541C386.332 41.7577 389.105 34.5934 394.649 29.0498C400.194 23.4345 407.323 20.627 416.036 20.627ZM587.211 20.627C595.78 20.627 602.369 23.1106 606.978 28.0781C611.658 33.0457 613.998 40.0292 613.998 49.0283C613.998 51.0441 613.926 53.1322 613.782 55.292H574.141C575.869 62.9953 580.838 66.8476 589.047 66.8477C591.999 66.8477 594.627 66.3428 596.932 65.335C599.236 64.2551 601.972 62.3834 605.141 59.7197L613.998 69.8711C606.581 76.9984 598.12 80.5624 588.615 80.5625C579.398 80.5625 572.053 77.8624 566.58 72.4629C561.179 67.0633 558.479 59.8635 558.479 50.8643C558.479 42.0091 561.071 34.7737 566.256 29.1582C571.441 23.4707 578.426 20.627 587.211 20.627ZM243.526 57.8838C243.526 63.5711 246.299 66.415 251.844 66.415C258.612 66.4149 261.997 62.8509 261.997 55.7236V22.5703H278.199V78.7256H263.4V72.7861C260.016 77.9696 254.58 80.5615 247.091 80.5615C240.466 80.5615 235.497 78.9782 232.185 75.8105C228.944 72.6428 227.324 68.1067 227.324 62.2031V22.5703H243.526V57.8838ZM161.807 22.5713H174.444V34.666H161.807V60.9082C161.807 62.7799 162.239 64.1114 163.104 64.9033C163.968 65.6232 165.299 65.9834 167.1 65.9834C168.468 65.9834 170.592 65.6951 173.473 65.1191L175.309 78.0781C170.772 79.446 166.488 80.1299 162.455 80.1299C156.478 80.1299 152.158 78.834 149.493 76.2422C146.901 73.6504 145.604 69.5106 145.604 63.8232V34.666H135.775V22.5713H145.604V6.15625H161.807V22.5713ZM212.189 21.5977C214.422 21.5977 217.482 22.2453 221.37 23.541L218.346 37.7959C214.962 37.004 212.513 36.6084 211.001 36.6084C207.401 36.6085 204.556 38.0126 202.468 40.8203C200.38 43.5561 199.336 47.3357 199.336 52.1592V78.7256H183.134V22.5693H198.147V30.5605C201.172 24.5852 205.853 21.5977 212.189 21.5977ZM374.509 0C378.397 0 382.502 0.647547 386.822 1.94336L384.015 13.9307C381.926 13.4267 379.802 13.1748 377.642 13.1748C375.553 13.1748 374.077 13.6432 373.213 14.5791C372.349 15.4431 371.917 16.9909 371.917 19.2227V22.5703H383.69V34.665H371.917V78.7256H355.715V34.665H346.317V22.5703H355.715V18.5742C355.715 6.19146 361.979 5.23399e-05 374.509 0ZM483.068 21.5977C485.301 21.5977 488.361 22.2453 492.249 23.541L489.225 37.7959C485.84 37.004 483.392 36.6084 481.88 36.6084C478.279 36.6084 475.435 38.0125 473.347 40.8203C471.258 43.5561 470.214 47.3357 470.214 52.1592V78.7256H454.012V22.5693H469.026V30.5605C472.051 24.5853 476.732 21.5977 483.068 21.5977ZM416.036 34.3418C412.076 34.3418 408.871 35.8178 406.423 38.7695C403.975 41.7213 402.75 45.6454 402.75 50.541C402.75 55.5084 403.975 59.4682 406.423 62.4199C408.871 65.3715 412.076 66.8477 416.036 66.8477C419.996 66.8476 423.165 65.3715 425.541 62.4199C427.989 59.4682 429.214 55.5084 429.214 50.541C429.214 45.6454 427.989 41.7213 425.541 38.7695C423.093 35.8179 419.925 34.3418 416.036 34.3418ZM522.447 34.4502C518.775 34.4502 515.787 35.7817 513.482 38.4453C511.25 41.0371 510.134 44.4929 510.134 48.8125C510.134 53.1321 511.286 56.6243 513.59 59.2881C515.894 61.9518 518.847 63.2831 522.447 63.2832C526.12 63.2832 529.109 61.9519 531.413 59.2881C533.717 56.6243 534.869 53.1321 534.869 48.8125C534.869 44.493 533.717 41.0371 531.413 38.4453C529.109 35.7815 526.12 34.4502 522.447 34.4502ZM315.166 33.2617C308.613 33.2619 304.437 36.8258 302.637 43.9531H326.724C325.932 36.8257 322.079 33.2617 315.166 33.2617ZM586.995 33.2617C580.442 33.2617 576.265 36.8257 574.465 43.9531H598.552C597.76 36.8258 593.908 33.2619 586.995 33.2617Z" fill="black"/>
+<defs>
+<clipPath id="clip0_10581_1412">
+<rect width="100" height="100" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/packages/trueforge-ui/src/index.ts b/packages/trueforge-ui/src/index.ts
index 9cc5cbf9c..ca2f6ccbb 100644
--- a/packages/trueforge-ui/src/index.ts
+++ b/packages/trueforge-ui/src/index.ts
@@ -2,7 +2,8 @@
import './icons/registerAgentIcons.js';
-export { BrandLogo, useBrandName } from './theme/brand.js';
+export { BrandLogo, resolveBrandChrome, useBrandName } from './theme/brand.js';
+export type { BrandChrome } from './theme/brand.js';
export { defaultSlots } from './theme/defaultSlots.js';
export { PRESETS, resolvePresetTokens } from './theme/presets/index.js';
export type { PublicAtomSlots as AtomSlots, SlotOverrides } from './theme/publicSlots.js';
@@ -17,7 +18,9 @@ export {
} from './theme/ThemeProvider.js';
export type {
BrandConfig,
+ BrandImage,
BrandLogoConfig,
+ BrandMode,
ContentClassNames,
IconMap,
LayoutProp,
diff --git a/packages/trueforge-ui/src/layouts/SidebarLayout.tsx b/packages/trueforge-ui/src/layouts/SidebarLayout.tsx
index 21511cfb1..c34c6f1a2 100644
--- a/packages/trueforge-ui/src/layouts/SidebarLayout.tsx
+++ b/packages/trueforge-ui/src/layouts/SidebarLayout.tsx
@@ -13,18 +13,23 @@ import { ThreadListContainer } from '../containers/ThreadListContainer.js';
import { useChatHeaderContentVisible } from '../hooks/useChatChromeActionsVisible.js';
import { Icon } from '../icons/Icon.js';
import { useOptionalShellMode } from '../server/ShellModeContext.js';
-import { useBrandName } from '../theme/brand.js';
+import { resolveBrandChrome, useBrandName } from '../theme/brand.js';
import { useSlot } from '../theme/SlotsProvider.js';
+import { useBrand } from '../theme/ThemeProvider.js';
const TruefoundrySettingsBuilder = lazy(() => import('../containers/SettingsBuilder/index.js'));
// Survives ChatProvider remounts when openDraft / selectAgent bumps runtimeKey.
let desktopCollapsed = false;
+const brandLogoClassName = 'h-5 max-w-40 shrink-0 object-contain';
+
export function SidebarLayout({ className }: { className?: string }) {
const aui = useAui();
const shell = useOptionalShellMode();
+ const brand = useBrand();
const brandName = useBrandName();
+ const chrome = resolveBrandChrome(brand);
const BrandLogo = useSlot('BrandLogo');
const AgentsLibraryButton = useSlot('AgentsLibraryButton');
const ClearChatButton = useSlot('ClearChatButton');
@@ -93,8 +98,13 @@ export function SidebarLayout({ className }: { className?: string }) {
className={cn('flex shrink-0 items-center px-3 py-3', collapsed ? 'flex-col gap-3' : 'justify-between gap-2')}
>
<div className={cn('flex min-w-0 items-center text-text-primary', collapsed ? 'justify-center' : 'gap-2')}>
- <BrandLogo className="size-5 shrink-0 object-contain" />
- {!collapsed ? <span className="truncate text-lg font-semibold tracking-tight">{brandName}</span> : null}
+ <BrandLogo
+ variant={collapsed ? chrome.collapsedVariant : chrome.expandedVariant}
+ className={cn(brandLogoClassName, (collapsed || chrome.expandedVariant === 'icon') && 'w-5')}
+ />
+ {!collapsed && chrome.showTitle && brandName != null ? (
+ <span className="truncate text-lg font-semibold tracking-tight">{brandName}</span>
+ ) : null}
</div>
<button
type="button"
@@ -215,8 +225,13 @@ export function SidebarLayout({ className }: { className?: string }) {
tabIndex={-1}
>
<div className="flex shrink-0 items-center gap-2 border-b border-border px-3 py-3 text-text-primary">
- <BrandLogo className="size-5 shrink-0 object-contain" />
- <span className="truncate text-lg font-semibold tracking-tight">{brandName}</span>
+ <BrandLogo
+ variant={chrome.expandedVariant}
+ className={cn(brandLogoClassName, chrome.expandedVariant === 'icon' && 'w-5')}
+ />
+ {chrome.showTitle && brandName != null ? (
+ <span className="truncate text-lg font-semibold tracking-tight">{brandName}</span>
+ ) : null}
</div>
<ThreadListContainer onThreadOpen={() => setMobileNavOpen(false)} />
</div>
diff --git a/packages/trueforge-ui/src/layouts/WidgetLayout.tsx b/packages/trueforge-ui/src/layouts/WidgetLayout.tsx
index 0c762f9ce..c915b5dd1 100644
--- a/packages/trueforge-ui/src/layouts/WidgetLayout.tsx
+++ b/packages/trueforge-ui/src/layouts/WidgetLayout.tsx
@@ -87,7 +87,7 @@ export function WidgetLayout({ className }: { className?: string }) {
×
</span>
) : (
- <BrandLogo className="size-6" />
+ <BrandLogo variant="icon" className="size-6" />
)}
</button>
</div>
diff --git a/packages/trueforge-ui/src/theme/brand.tsx b/packages/trueforge-ui/src/theme/brand.tsx
index 9b4ebb5a0..af93c7b56 100644
--- a/packages/trueforge-ui/src/theme/brand.tsx
+++ b/packages/trueforge-ui/src/theme/brand.tsx
@@ -2,58 +2,101 @@
import { useContext } from 'react';
+import { cn } from '../atoms/lib/cn.js';
import { Icon } from '../icons/Icon.js';
+import TrueForgeLogoDark from '../icons/trueforge-logo-dark.svg';
+import TrueForgeLogoLight from '../icons/trueforge-logo.svg';
import { ThemeContext } from './ThemeProvider.js';
-import type { BrandLogoConfig } from './types.js';
+import type { BrandConfig, BrandLogoConfig } from './types.js';
const DEFAULT_BRAND_NAME = 'TrueForge';
+/** Expanded / collapsed chrome choices derived from `theme.brand.mode`. */
+export type BrandChrome = {
+ expandedVariant: 'icon' | 'logo';
+ collapsedVariant: 'icon';
+ /** Whether to render `name` as visible text beside the mark in expanded chrome. */
+ showTitle: boolean;
+};
+
+/**
+ * Maps `brand.mode` to layout chrome. Layouts should not re-derive field combinations.
+ */
+export function resolveBrandChrome(brand: Partial<BrandConfig> | undefined): BrandChrome {
+ switch (brand?.mode) {
+ case 'logo':
+ return { expandedVariant: 'logo', collapsedVariant: 'icon', showTitle: false };
+ case 'icon-only':
+ return { expandedVariant: 'icon', collapsedVariant: 'icon', showTitle: false };
+ case 'icon-title':
+ return { expandedVariant: 'icon', collapsedVariant: 'icon', showTitle: true };
+ default:
+ // Omit `brand` (or incomplete Partial) → default TrueForge wordmark.
+ return { expandedVariant: 'logo', collapsedVariant: 'icon', showTitle: false };
+ }
+}
+
/** Mode-matched source, falling back to the other mode then the mode-agnostic `src`. */
-function resolveLogoSrc({
- logo,
+function resolveImageSrc({
+ image,
mode,
}: {
- logo: string | BrandLogoConfig;
+ image: string | BrandLogoConfig;
mode: 'light' | 'dark';
}): string | undefined {
- if (typeof logo === 'string') return logo;
- const preferred = mode === 'dark' ? logo.dark : logo.light;
- return preferred ?? logo.light ?? logo.dark ?? logo.src;
+ if (typeof image === 'string') return image;
+ const preferred = mode === 'dark' ? image.dark : image.light;
+ return preferred ?? image.light ?? image.dark ?? image.src;
}
-/** Configured brand name, or the SDK default. Safe outside a `ThemeProvider`. */
-export function useBrandName(): string {
- return useContext(ThemeContext)?.brand.name ?? DEFAULT_BRAND_NAME;
+/** Configured display name, or the SDK default when no custom brand is set. */
+export function useBrandName(): string | undefined {
+ const brand = useContext(ThemeContext)?.brand;
+ if (brand?.name != null) return brand.name;
+ return brand?.mode == null ? DEFAULT_BRAND_NAME : undefined;
}
/**
- * The product mark: `theme.brand.logo` resolved against the active theme mode,
- * labelled with the brand name, and linked when the config carries an `href`.
- * Falls back to the default mark when no logo is configured.
- *
- * Callers that also want the name as text render it themselves — the SDK layouts
- * pair this with `useBrandName()` so each one controls its own arrangement.
+ * The product mark resolved against the active theme mode. Compact surfaces use
+ * `icon`; expanded surfaces use `logo` and fall back to `icon`.
*/
-export function BrandLogo({ className }: { className?: string }) {
+export function BrandLogo({ className, variant = 'icon' }: { className?: string; variant?: 'icon' | 'logo' }) {
const theme = useContext(ThemeContext);
- const logo = theme?.brand.logo;
- const name = theme?.brand.name ?? DEFAULT_BRAND_NAME;
-
+ const brand = theme?.brand;
+ const name = useBrandName();
+ const label = name ?? DEFAULT_BRAND_NAME;
const mode = theme?.mode ?? 'light';
- const src = logo == null ? undefined : resolveLogoSrc({ logo, mode });
+ const preferredImage = variant === 'logo' ? brand?.logo : brand?.icon;
+ const preferredSrc = preferredImage == null ? undefined : resolveImageSrc({ image: preferredImage, mode });
+ const icon = brand?.icon;
+ const src = preferredSrc ?? (variant === 'logo' && icon != null ? resolveImageSrc({ image: icon, mode }) : undefined);
+
if (src == null) {
+ if (variant === 'logo') {
+ const Wordmark = mode === 'dark' ? TrueForgeLogoDark : TrueForgeLogoLight;
+ // svgr pins width/height to 1em; clearing both lets the viewBox aspect
+ // ratio widen the wordmark to match the caller's height.
+ return (
+ <Wordmark
+ className={cn('w-auto', className)}
+ width={undefined}
+ height={undefined}
+ role="img"
+ aria-label={label}
+ />
+ );
+ }
return (
<Icon name={mode === 'dark' ? 'trueforge-logomark-dark' : 'trueforge-logomark-light'} className={className} />
);
}
- // `name` is the accessible label: the image itself carries no text alternative.
- const image = <img src={src} alt={name} className={className} />;
- const href = typeof logo === 'string' ? undefined : logo?.href;
+ const image = <img src={src} alt={label} className={className} />;
+ const href = brand?.href;
if (href == null) return image;
return (
- <a href={href} aria-label={name} className="inline-flex items-center">
+ <a href={href} aria-label={label} className="inline-flex items-center">
{image}
</a>
);
diff --git a/packages/trueforge-ui/src/theme/types.ts b/packages/trueforge-ui/src/theme/types.ts
index 8cf86c66b..5ef3c01bf 100644
--- a/packages/trueforge-ui/src/theme/types.ts
+++ b/packages/trueforge-ui/src/theme/types.ts
@@ -68,29 +68,56 @@ export type IconEntry = IconComponent | ReactNode;
export type IconMap = Record<string, IconEntry>;
/**
- * Logo sources. `light` / `dark` pick per resolved theme mode and fall back to
- * each other, then to `src`. `href` wraps the logo in a same-tab link. The logo
- * is labelled with `name`; replace the mark itself through the slot table when
- * an image URL is not enough.
+ * Brand image sources. `light` / `dark` pick per resolved theme mode and fall
+ * back to each other, then to `src`.
*/
export type BrandLogoConfig = {
src?: string;
light?: string;
dark?: string;
- href?: string;
};
+export type BrandImage = string | BrandLogoConfig;
+
+/** Chrome look for `theme.brand`. Omit `brand` entirely for the default TrueForge marks. */
+export type BrandMode = 'icon-title' | 'icon-only' | 'logo';
+
/**
- * Setting `brand` requires a `name`: it labels the logo, so a logo without one has
- * no accessible name. `logo` is optional — omit it to pair host text with the stock
- * mark.
+ * Product branding. Set `mode`, then pass the fields that mode requires.
+ * `name` always labels the mark (`alt` / `aria-label`).
*/
-export type BrandConfig = {
- /** Display name, and the logo's accessible label. */
- name: string;
- /** Image URL, or per-mode sources. Omit to keep the default mark. */
- logo?: string | BrandLogoConfig;
-};
+export type BrandConfig =
+ | {
+ mode: 'icon-title';
+ /** Accessible label and visible title beside the square mark in expanded chrome. */
+ name: string;
+ /** Square image, or per-mode sources. Omit to keep the default mark. */
+ icon?: BrandImage;
+ logo?: never;
+ /** Wraps configured brand images in a same-tab link. */
+ href?: string;
+ }
+ | {
+ mode: 'icon-only';
+ /** Accessible label only — no title text in expanded chrome. */
+ name: string;
+ /** Square image, or per-mode sources. */
+ icon: BrandImage;
+ logo?: never;
+ /** Wraps configured brand images in a same-tab link. */
+ href?: string;
+ }
+ | {
+ mode: 'logo';
+ /** Accessible label only — wide logo replaces the text title in expanded chrome. */
+ name: string;
+ /** Square image, or per-mode sources, used when compact. */
+ icon: BrandImage;
+ /** Wider image, or per-mode sources, used when expanded. */
+ logo: BrandImage;
+ /** Wraps configured brand images in a same-tab link. */
+ href?: string;
+ };
export type ContentClassNames = {
markdown?: string;
diff --git a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx
index ec27f2baa..a020840e6 100644
--- a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx
+++ b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx
@@ -304,7 +304,7 @@ describe('StackChatPanel', () => {
describe('SidebarLayout', () => {
it('shows the app brand in the mobile sessions drawer', () => {
render(
- <SlotsProvider theme={{ brand: { name: 'Acme', logo: { src: '/acme.svg' } } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: { src: '/acme.svg' } } }}>
<RuntimeHarness messages={[]}>
<div className="h-96">
<SidebarLayout />
@@ -320,9 +320,63 @@ describe('SidebarLayout', () => {
expect(within(drawer).getByAltText('Acme')).toHaveAttribute('src', '/acme.svg');
});
+ it('shows the default wordmark without a name in expanded chrome', () => {
+ const { container } = render(
+ <SlotsProvider>
+ <RuntimeHarness messages={[]}>
+ <div className="h-96">
+ <SidebarLayout />
+ </div>
+ </RuntimeHarness>
+ </SlotsProvider>,
+ );
+
+ const mark = container.querySelector('aside svg');
+ expect(mark).toHaveAttribute('viewBox', '0 0 614 100');
+ expect(screen.queryByText('TrueForge')).not.toBeInTheDocument();
+ });
+
+ it('shows a wide logo when expanded and its square icon when collapsed', () => {
+ const { container } = render(
+ <SlotsProvider
+ theme={{ brand: { mode: 'logo', name: 'Acme', icon: '/acme-icon.svg', logo: '/acme-wordmark.svg' } }}
+ >
+ <RuntimeHarness messages={[]}>
+ <div className="h-96">
+ <SidebarLayout />
+ </div>
+ </RuntimeHarness>
+ </SlotsProvider>,
+ );
+
+ expect(container.querySelector('aside img')).toHaveAttribute('src', '/acme-wordmark.svg');
+ expect(screen.queryByText('Acme')).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Collapse sidebar' }));
+ expect(container.querySelector('aside img')).toHaveAttribute('src', '/acme-icon.svg');
+
+ fireEvent.click(screen.getByRole('button', { name: 'Expand sidebar' }));
+ });
+
+ it('supports icon-only branding in expanded chrome', () => {
+ const { container } = render(
+ <SlotsProvider theme={{ brand: { mode: 'icon-only', name: 'Acme', icon: '/acme-icon.svg' } }}>
+ <RuntimeHarness messages={[]}>
+ <div className="h-96">
+ <SidebarLayout />
+ </div>
+ </RuntimeHarness>
+ </SlotsProvider>,
+ );
+
+ expect(container.querySelector('aside img')).toHaveAttribute('src', '/acme-icon.svg');
+ expect(container.querySelector('aside img')).toHaveAttribute('alt', 'Acme');
+ expect(screen.queryByText('Acme')).not.toBeInTheDocument();
+ });
+
it('shows the brand and toggles the desktop sidebar rail', () => {
const { unmount } = render(
- <SlotsProvider theme={{ brand: { name: 'Acme', logo: '/acme.svg' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: '/acme.svg' } }}>
<RuntimeHarness messages={[]}>
<div className="h-96">
<SidebarLayout />
@@ -341,7 +395,7 @@ describe('SidebarLayout', () => {
// New Chat / Agents remount ChatProvider via runtimeKey; collapse must survive.
unmount();
render(
- <SlotsProvider theme={{ brand: { name: 'Acme', logo: '/acme.svg' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: '/acme.svg' } }}>
<RuntimeHarness messages={[]}>
<div className="h-96">
<SidebarLayout />
@@ -354,7 +408,7 @@ describe('SidebarLayout', () => {
it('toggles theme from the footer and shows settings only when catalog is provided', async () => {
const { rerender } = render(
- <SlotsProvider theme={{ brand: { name: 'Acme' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme' } }}>
<ServerProvider server={mockServer(stubCatalog)}>
<ShellModeProvider>
<RuntimeHarness messages={[]}>
@@ -382,7 +436,7 @@ describe('SidebarLayout', () => {
// Settings stays available with a locked agentName when catalog is present.
rerender(
- <SlotsProvider theme={{ brand: { name: 'Acme' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme' } }}>
<ServerProvider server={mockServer(stubCatalog)}>
<ShellModeProvider agentConfig={{ mode: 'SingleAgent', name: 'locked-agent' }}>
<RuntimeHarness messages={[]}>
@@ -404,7 +458,7 @@ describe('SidebarLayout', () => {
expect(await screen.findByRole('heading', { name: 'Settings' })).toBeInTheDocument();
rerender(
- <SlotsProvider theme={{ brand: { name: 'Acme' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme' } }}>
<ServerProvider
server={createMockAgentUIServer({
catalog: stubCatalog,
@@ -434,7 +488,7 @@ describe('SidebarLayout', () => {
// No catalog → no Settings button.
rerender(
- <SlotsProvider theme={{ brand: { name: 'Acme' } }}>
+ <SlotsProvider theme={{ brand: { mode: 'icon-title', name: 'Acme' } }}>
<ServerProvider server={mockServer()}>
<ShellModeProvider>
<RuntimeHarness messages={[]}>
diff --git a/packages/trueforge-ui/test/publicUiExports.test.ts b/packages/trueforge-ui/test/publicUiExports.test.ts
index 249a0e2c7..aeb910515 100644
--- a/packages/trueforge-ui/test/publicUiExports.test.ts
+++ b/packages/trueforge-ui/test/publicUiExports.test.ts
@@ -110,6 +110,7 @@ const expectedRuntimeExports: Array<keyof typeof sdk> = [
'libraryAgentId',
'mergeAgentSpec',
'preloadMarkdownOpenUI',
+ 'resolveBrandChrome',
'resolvePresetTokens',
'shellIsMutable',
'threadHasPendingMcpAuth',
diff --git a/packages/trueforge-ui/test/theme/ThemeProvider.test.tsx b/packages/trueforge-ui/test/theme/ThemeProvider.test.tsx
index 4ee9ed938..089a83cc5 100644
--- a/packages/trueforge-ui/test/theme/ThemeProvider.test.tsx
+++ b/packages/trueforge-ui/test/theme/ThemeProvider.test.tsx
@@ -138,7 +138,7 @@ describe('ThemeProvider', () => {
it('exposes brand config and labels BrandLogo with the brand name', () => {
render(
- <ThemeProvider theme={{ brand: { name: 'Acme', logo: '/acme.svg' } }}>
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: '/acme.svg' } }}>
<BrandProbe />
<BrandLogo className="size-4" />
</ThemeProvider>,
diff --git a/packages/trueforge-ui/test/theme/brand.test.tsx b/packages/trueforge-ui/test/theme/brand.test.tsx
index 8e6791f18..d00d800e7 100644
--- a/packages/trueforge-ui/test/theme/brand.test.tsx
+++ b/packages/trueforge-ui/test/theme/brand.test.tsx
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { WelcomeScreen } from '@/atoms/WelcomeScreen.js';
-import { BrandLogo, useBrandName } from '@/theme/brand.js';
+import { BrandLogo, resolveBrandChrome, useBrandName } from '@/theme/brand.js';
import { SlotsProvider } from '@/theme/SlotsProvider.js';
import { ThemeProvider } from '@/theme/ThemeProvider.js';
@@ -10,6 +10,53 @@ function BrandNameProbe() {
return <output data-testid="brand-name">{useBrandName()}</output>;
}
+describe('resolveBrandChrome', () => {
+ it('uses the default wordmark when brand.mode is omitted', () => {
+ expect(resolveBrandChrome(undefined)).toEqual({
+ expandedVariant: 'logo',
+ collapsedVariant: 'icon',
+ showTitle: false,
+ });
+ expect(resolveBrandChrome({})).toEqual({
+ expandedVariant: 'logo',
+ collapsedVariant: 'icon',
+ showTitle: false,
+ });
+ });
+
+ it('shows icon + title for mode icon-title', () => {
+ expect(resolveBrandChrome({ mode: 'icon-title', name: 'Acme', icon: '/icon.svg' })).toEqual({
+ expandedVariant: 'icon',
+ collapsedVariant: 'icon',
+ showTitle: true,
+ });
+ });
+
+ it('hides the text title for mode icon-only', () => {
+ expect(resolveBrandChrome({ mode: 'icon-only', name: 'Acme', icon: '/icon.svg' })).toEqual({
+ expandedVariant: 'icon',
+ collapsedVariant: 'icon',
+ showTitle: false,
+ });
+ });
+
+ it('uses the wide logo for mode logo', () => {
+ expect(resolveBrandChrome({ mode: 'logo', name: 'Acme', icon: '/icon.svg', logo: '/wordmark.svg' })).toEqual({
+ expandedVariant: 'logo',
+ collapsedVariant: 'icon',
+ showTitle: false,
+ });
+ });
+
+ it('pairs a host name with the default mark in icon-title without icon', () => {
+ expect(resolveBrandChrome({ mode: 'icon-title', name: 'Acme' })).toEqual({
+ expandedVariant: 'icon',
+ collapsedVariant: 'icon',
+ showTitle: true,
+ });
+ });
+});
+
describe('BrandLogo', () => {
it('renders the default mark without a provider', () => {
const { container } = render(<BrandLogo className="host-logo" />);
@@ -31,18 +78,30 @@ describe('BrandLogo', () => {
expect(icon).toHaveAttribute('viewBox', '0 0 120 120');
});
- it('labels the configured logo with the brand name', () => {
+ it('labels the configured icon with the brand name', () => {
render(
- <ThemeProvider theme={{ brand: { name: 'Acme', logo: { src: '/acme-logo.svg' } } }}>
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: { src: '/acme-icon.svg' } } }}>
<BrandLogo className="logo-image" />
</ThemeProvider>,
);
const logo = screen.getByRole('img', { name: 'Acme' });
- expect(logo).toHaveAttribute('src', '/acme-logo.svg');
+ expect(logo).toHaveAttribute('src', '/acme-icon.svg');
expect(logo).toHaveClass('logo-image');
});
+ it('keeps the brand name as alt for icon-only chrome', () => {
+ render(
+ <ThemeProvider theme={{ brand: { mode: 'icon-only', name: 'Acme', icon: '/acme-icon.svg' } }}>
+ <BrandNameProbe />
+ <BrandLogo />
+ </ThemeProvider>,
+ );
+
+ expect(screen.getByTestId('brand-name')).toHaveTextContent('Acme');
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/acme-icon.svg');
+ });
+
it('renders the default mark and name when brand is omitted', () => {
const { container } = render(
<ThemeProvider theme={{ preset: 'claude' }}>
@@ -56,9 +115,32 @@ describe('BrandLogo', () => {
expect(screen.getByTestId('brand-name')).toHaveTextContent('TrueForge');
});
- it('pairs a host name with the default mark when logo is omitted', () => {
+ it('renders the default wordmark for the logo variant', () => {
+ const { container, rerender } = render(
+ <ThemeProvider theme={{ mode: 'light' }}>
+ <BrandLogo variant="logo" className="host-logo" />
+ </ThemeProvider>,
+ );
+
+ const light = screen.getByRole('img', { name: 'TrueForge' });
+ expect(light).toHaveClass('host-logo', 'w-auto');
+ expect(light).toHaveAttribute('viewBox', '0 0 614 100');
+ // Sizing must come from the viewBox, not svgr's 1em width/height.
+ expect(light).not.toHaveAttribute('width');
+ expect(light).not.toHaveAttribute('height');
+ expect(container.querySelector('svg[aria-hidden="true"]')).toBeNull();
+
+ rerender(
+ <ThemeProvider theme={{ mode: 'dark' }}>
+ <BrandLogo variant="logo" className="host-logo" />
+ </ThemeProvider>,
+ );
+ expect(screen.getByRole('img', { name: 'TrueForge' })).toHaveAttribute('viewBox', '0 0 737 120');
+ });
+
+ it('pairs a host name with the default mark when icon is omitted', () => {
const { container } = render(
- <ThemeProvider theme={{ brand: { name: 'Acme' } }}>
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', name: 'Acme' } }}>
<BrandNameProbe />
<BrandLogo className="host-logo" />
</ThemeProvider>,
@@ -69,50 +151,91 @@ describe('BrandLogo', () => {
expect(screen.getByTestId('brand-name')).toHaveTextContent('Acme');
});
- it('treats a bare string as an image source', () => {
+ it('treats a bare string as an icon source', () => {
render(
- <ThemeProvider theme={{ brand: { logo: '/acme-logo.svg', name: 'Acme' } }}>
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', icon: '/acme-icon.svg', name: 'Acme' } }}>
<BrandLogo className="logo-image" />
</ThemeProvider>,
);
const img = screen.getByRole('img', { name: 'Acme' });
- expect(img).toHaveAttribute('src', '/acme-logo.svg');
+ expect(img).toHaveAttribute('src', '/acme-icon.svg');
expect(img).toHaveClass('logo-image');
});
it('picks the light source in light mode and the dark source in dark mode', () => {
- const logo = { light: '/logo/light.svg', dark: '/logo/dark.svg' };
+ const icon = { light: '/icon/light.svg', dark: '/icon/dark.svg' };
const { rerender } = render(
- <ThemeProvider theme={{ mode: 'light', brand: { name: 'Acme', logo } }}>
+ <ThemeProvider theme={{ mode: 'light', brand: { mode: 'icon-title', name: 'Acme', icon } }}>
<BrandLogo />
</ThemeProvider>,
);
- expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/logo/light.svg');
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/icon/light.svg');
rerender(
- <ThemeProvider theme={{ mode: 'dark', brand: { name: 'Acme', logo } }}>
+ <ThemeProvider theme={{ mode: 'dark', brand: { mode: 'icon-title', name: 'Acme', icon } }}>
<BrandLogo />
</ThemeProvider>,
);
- expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/logo/dark.svg');
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/icon/dark.svg');
});
it('falls back to the other mode when only one source is configured', () => {
render(
- <ThemeProvider theme={{ mode: 'dark', brand: { name: 'Acme', logo: { light: '/logo/light.svg' } } }}>
+ <ThemeProvider
+ theme={{ mode: 'dark', brand: { mode: 'icon-title', name: 'Acme', icon: { light: '/icon/light.svg' } } }}
+ >
<BrandLogo />
</ThemeProvider>,
);
- expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/logo/light.svg');
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/icon/light.svg');
+ });
+
+ it('uses the wide logo only for the logo variant', () => {
+ const brand = {
+ mode: 'logo' as const,
+ name: 'Acme',
+ icon: '/acme-icon.svg',
+ logo: '/acme-wordmark.svg',
+ };
+ const { rerender } = render(
+ <ThemeProvider theme={{ brand }}>
+ <BrandLogo variant="icon" />
+ </ThemeProvider>,
+ );
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/acme-icon.svg');
+
+ rerender(
+ <ThemeProvider theme={{ brand }}>
+ <BrandLogo variant="logo" />
+ </ThemeProvider>,
+ );
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/acme-wordmark.svg');
+ });
+
+ it('falls back to the square icon when the wide logo is omitted from BrandLogo logo variant', () => {
+ render(
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: '/acme-icon.svg' } }}>
+ <BrandLogo variant="logo" />
+ </ThemeProvider>,
+ );
+
+ expect(screen.getByRole('img', { name: 'Acme' })).toHaveAttribute('src', '/acme-icon.svg');
});
it('wraps the logo in a same-tab link when href is set', () => {
render(
<ThemeProvider
- theme={{ brand: { name: 'Acme', logo: { light: '/logo/light.svg', href: 'https://trueforge.dev' } } }}
+ theme={{
+ brand: {
+ mode: 'icon-title',
+ name: 'Acme',
+ icon: { light: '/icon/light.svg' },
+ href: 'https://trueforge.dev',
+ },
+ }}
>
<BrandLogo />
</ThemeProvider>,
@@ -121,7 +244,7 @@ describe('BrandLogo', () => {
const link = screen.getByRole('link', { name: 'Acme' });
expect(link).toHaveAttribute('href', 'https://trueforge.dev');
expect(link).not.toHaveAttribute('target');
- expect(link.querySelector('img')).toHaveAttribute('src', '/logo/light.svg');
+ expect(link.querySelector('img')).toHaveAttribute('src', '/icon/light.svg');
});
it('lets a slot override replace the mark with a component', () => {
@@ -130,7 +253,10 @@ describe('BrandLogo', () => {
}
render(
- <SlotsProvider overrides={{ BrandLogo: CustomMark }} theme={{ brand: { name: 'Acme', logo: '/logo.svg' } }}>
+ <SlotsProvider
+ overrides={{ BrandLogo: CustomMark }}
+ theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: '/icon.svg' } }}
+ >
<WelcomeScreen />
</SlotsProvider>,
);
@@ -139,9 +265,9 @@ describe('BrandLogo', () => {
expect(screen.queryByRole('img', { name: 'Acme' })).toBeNull();
});
- it('falls back to the default mark when a logo config resolves to no source', () => {
+ it('falls back to the default mark when an icon config resolves to no source', () => {
const { container } = render(
- <ThemeProvider theme={{ brand: { name: 'Acme', logo: { href: '/' } } }}>
+ <ThemeProvider theme={{ brand: { mode: 'icon-title', name: 'Acme', icon: {}, href: '/' } }}>
<BrandLogo className="host-logo" />
</ThemeProvider>,
);