Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/27386-launcher-branding-gantt-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/app-shell': patch
'@object-ui/plugin-gantt': patch
---

fix(app-shell, plugin-gantt): the home launcher tile draws the app's branding, and a gantt's name column is headed by its object

Clause-②: no
Metadata-protocol: none

The console home's app tiles (and the `app:launcher` block, which draws the same strip) now follow the app's declared branding, the way the top-bar app pill and the app switcher already do: the `branding.logo` image when one is declared, else the app's icon on its `branding.primaryColor` when that is a hex, else the icon on the name-keyed gradient as before. A logo that fails to load falls back to the tile.

A gantt bound to an object now heads its task list's name column with that object's label (translated like every other surface that names the object), so a campaign gantt reads "Campaign" rather than "Task Name". An inline data set, an object that declares no label, and a mixed-object tree (`objectField`) keep the generic heading.
66 changes: 53 additions & 13 deletions ui/packages/app-shell/src/console/home/HomeAppsStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
*
* The strip's look is the Home artboard's apps section (objectui#12601): a
* 15 px heading with a count pill, 112 px tiles with a 56 px icon on the app's
* colour and a 13 px name on one line. Three optional parts ride along, all
* colour and a 13 px name on one line. The icon square follows the app's own
* branding, the way `AppMark` does in the top bar and the switcher: its
* `branding.logo` when it declares one, else its `icon` on its
* `branding.primaryColor` when that is a hex, else its `icon` on the
* name-keyed gradient. A logo that fails to load falls back to the tile. Three optional parts ride along, all
* off unless the host asks: an 11 px "2 hr. ago" line under a tile's
* name (`lastOpened`, which Home reads from the recent-items store), a muted
* "System Settings" link at the heading's right (`settingsHref` — Home moves
Expand All @@ -32,7 +36,7 @@
*
* @module
*/
import { useMemo, useState } from 'react';
import { useMemo, useState, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { LayoutGrid, Plus, Settings, Star } from 'lucide-react';
import { cn } from '@object-ui/components';
Expand All @@ -43,13 +47,58 @@ import { timeAgo } from '../../utils/relativeTime.js';
import { TILE_OPENED_TIME_FORMAT } from './appLastOpened.js';
import type { FavoriteItem } from '../../hooks/useFavorites.js';
import { ICON_BOX_CLASSES, TILE_CLASSES, launcherIconGradient } from './launcherTile.js';
import { BRANDED_TILE_CLASSES, appTileColors, appTileStyle } from '../../layout/appTileColors.js';

const COMPACT_LIMIT = 19;

/** The 12 px links at the heading's right. */
const HEADER_LINK_CLASSES =
'inline-flex items-center gap-1.5 rounded-sm text-xs transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';

/**
* One app's 56 px icon square, drawn from the app's branding (see the module
* header). `children` is the favourite badge, which rides on every face.
*/
function LauncherAppIcon({ app, children }: { app: any; children?: ReactNode }) {
const logo = typeof app?.branding?.logo === 'string' && app.branding.logo ? app.branding.logo : undefined;
// The URL that failed to load, so a later, different logo is tried afresh.
const [failedLogo, setFailedLogo] = useState<string | undefined>(undefined);
const box = cn(ICON_BOX_CLASSES, 'shadow-sm transition-transform group-hover:scale-105');

if (logo && logo !== failedLogo) {
return (
<span className={cn(box, 'bg-card')} data-testid={`app-tile-logo-${app.name}`}>
<img
src={logo}
alt=""
aria-hidden
onError={() => setFailedLogo(logo)}
className="size-full rounded-[14px] object-contain"
/>
{children}
</span>
);
}

const Icon = getIcon(app?.icon);
const colors = appTileColors(app?.branding?.primaryColor);
return (
<span
className={cn(
box,
colors ? BRANDED_TILE_CLASSES : cn('bg-gradient-to-br text-white', launcherIconGradient(app.name)),
)}
style={colors ? appTileStyle(colors) : undefined}
data-testid={`app-tile-icon-${app.name}`}
data-branded={colors ? 'true' : undefined}
>
{/* eslint-disable-next-line react-hooks/static-components -- getIcon returns a stable icon component from a static registry, not one created during render */}
<Icon className="size-[26px]" />
{children}
</span>
);
}

export function HomeAppsStrip({
apps,
favorites,
Expand Down Expand Up @@ -169,10 +218,8 @@ export function HomeAppsStrip({
{/* `-ml-2` puts the first icon under the heading: a tile pads its icon 8 px. */}
<div className="-ml-2 flex flex-wrap gap-1">
{visible.map((app) => {
const Icon = getIcon(app.icon);
const label = appLabel({ name: app.name, label: resolveKeyedI18nLabel(app.label, t) });
const fav = favNames.has(app.name);
const grad = launcherIconGradient(app.name);
const openedAgo = timeAgo(lastOpened?.get(app.name), displayLocale, TILE_OPENED_TIME_FORMAT);
return (
<Link
Expand All @@ -183,20 +230,13 @@ export function HomeAppsStrip({
className={TILE_CLASSES}
data-testid={`app-tile-${app.name}`}
>
<span
className={cn(
ICON_BOX_CLASSES,
'bg-gradient-to-br text-white shadow-sm transition-transform group-hover:scale-105',
grad,
)}
>
<Icon className="size-[26px]" />
<LauncherAppIcon app={app}>
{fav && (
<span className="absolute -right-1 -top-1 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 ring-2 ring-background">
<Star className="h-2.5 w-2.5 fill-white text-white" />
</span>
)}
</span>
</LauncherAppIcon>
<span className="w-full truncate text-[13px] font-medium">{label}</span>
{openedAgo && (
<span
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#27386 row 4 — a launcher tile draws the app's own branding.
*
* The 56 px icon square on Home (and the `app:launcher` block, which mounts the
* same strip) follows the ladder `AppMark` uses in the top bar and the app
* switcher: `branding.logo` when declared, else the app's `icon` on its
* `branding.primaryColor` when that is a hex, else the `icon` on the name-keyed
* gradient. A logo that fails to load falls back to the tile.
*/

import '@testing-library/jest-dom/vitest';
import { describe, it, expect, afterEach } from 'vitest';
import React from 'react';
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { HomeAppsStrip } from '../HomeAppsStrip';
import { launcherIconGradient } from '../launcherTile';
import { appTileColors } from '../../../layout/appTileColors';

function renderStrip(apps: Record<string, unknown>[], favorites: { id: string }[] = []) {
return render(
<MemoryRouter initialEntries={['/home']}>
<HomeAppsStrip
apps={apps}
favorites={favorites as any}
onBrowseMarketplace={() => {}}
isAdmin={false}
/>
</MemoryRouter>,
);
}

describe('HomeAppsStrip — tile branding (objectstack#27386 row 4)', () => {
afterEach(cleanup);

it('draws a declared hex primaryColor instead of the name-keyed gradient', () => {
renderStrip([{ name: 'hotcrm', label: 'HotCRM', icon: 'Flame', branding: { primaryColor: '#ea580c' } }]);
const icon = screen.getByTestId('app-tile-icon-hotcrm');
expect(icon).toHaveAttribute('data-branded', 'true');
expect(icon.className).not.toContain('bg-gradient-to-br');
for (const cls of launcherIconGradient('hotcrm').split(' ')) expect(icon.className).not.toContain(cls);
const colors = appTileColors('#ea580c')!;
expect(icon.style.getPropertyValue('--os-app-tile-bg')).toBe(colors.bg);
expect(icon.style.getPropertyValue('--os-app-tile-fg')).toBe(colors.fg);
expect(icon.style.getPropertyValue('--os-app-tile-bg-dark')).toBe(colors.bgDark);
expect(icon.style.getPropertyValue('--os-app-tile-fg-dark')).toBe(colors.fgDark);
});

it('keeps the name-keyed gradient when no usable colour is declared', () => {
renderStrip([
{ name: 'plain', label: 'Plain', icon: 'Box' },
// Not a hex: the spec's colour is a hex code, and `AppMark` reads only that.
{ name: 'named', label: 'Named', icon: 'Box', branding: { primaryColor: 'orange' } },
]);
for (const name of ['plain', 'named']) {
const icon = screen.getByTestId(`app-tile-icon-${name}`);
expect(icon).not.toHaveAttribute('data-branded');
expect(icon.className).toContain('bg-gradient-to-br');
for (const cls of launcherIconGradient(name).split(' ')) expect(icon.className).toContain(cls);
expect(icon.getAttribute('style')).toBeNull();
}
});

it('draws a declared logo, and falls back to the coloured tile when it fails to load', () => {
renderStrip(
[{ name: 'hotcrm', label: 'HotCRM', icon: 'Flame', branding: { logo: '/logo.png', primaryColor: '#ea580c' } }],
[{ id: 'app:hotcrm' }],
);
const logoBox = screen.getByTestId('app-tile-logo-hotcrm');
const img = logoBox.querySelector('img');
expect(img).toHaveAttribute('src', '/logo.png');
expect(screen.queryByTestId('app-tile-icon-hotcrm')).toBeNull();
// The favourite badge rides on the logo face too.
expect(logoBox.querySelector('.bg-amber-400')).not.toBeNull();

fireEvent.error(img!);
expect(screen.queryByTestId('app-tile-logo-hotcrm')).toBeNull();
const icon = screen.getByTestId('app-tile-icon-hotcrm');
expect(icon).toHaveAttribute('data-branded', 'true');
expect(icon.querySelector('.bg-amber-400')).not.toBeNull();
});
});
5 changes: 4 additions & 1 deletion ui/packages/app-shell/src/console/home/launcherTile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function hashStr(s: string): number {
return Math.abs(h);
}

/** The icon gradient for a tile, chosen by a stable key (an app's `name`). */
/**
* The icon gradient for a tile, chosen by a stable key (an app's `name`). An
* app tile draws it only when the app declares no branding (`HomeAppsStrip`).
*/
export function launcherIconGradient(key: string): string {
return ICON_GRADIENTS[hashStr(key) % ICON_GRADIENTS.length];
}
Expand Down
23 changes: 2 additions & 21 deletions ui/packages/app-shell/src/layout/AppMark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import * as React from 'react';
import { cn } from '@object-ui/components';
import { getIcon } from '../utils/getIcon.js';
import { appTileColors } from './appTileColors.js';
import { BRANDED_TILE_CLASSES, appTileColors, appTileStyle } from './appTileColors.js';

/** The app fields this glyph reads — the spec's `AppSchema` names. */
export interface AppMarkApp {
Expand All @@ -42,16 +42,6 @@ const SIZE_CLASSES: Record<AppMarkSize, { box: string; glyph: string }> = {
md: { box: 'size-[26px] rounded-md', glyph: 'size-4' },
};

/**
* The tile for a declared `primaryColor`. The utility strings are literals so
* Tailwind emits them at build time; the author's colour reaches them only as
* CSS custom properties, so `dark:` stays a real variant the theme controls
* (AGENTS.md section 2, the author-declared colour carve-out).
*/
const BRANDED_TILE_CLASSES =
'bg-[color:var(--os-app-tile-bg)] text-[color:var(--os-app-tile-fg)] ' +
'dark:bg-[color:var(--os-app-tile-bg-dark)] dark:text-[color:var(--os-app-tile-fg-dark)]';

/** The tile for an app that declares no usable colour — theme tokens only. */
const NEUTRAL_TILE_CLASSES = 'border bg-muted text-muted-foreground';

Expand Down Expand Up @@ -92,16 +82,7 @@ export function AppMark({ app, size = 'sm', className }: AppMarkProps) {
colors ? BRANDED_TILE_CLASSES : NEUTRAL_TILE_CLASSES,
className,
)}
style={
colors
? ({
'--os-app-tile-bg': colors.bg,
'--os-app-tile-fg': colors.fg,
'--os-app-tile-bg-dark': colors.bgDark,
'--os-app-tile-fg-dark': colors.fgDark,
} as React.CSSProperties)
: undefined
}
style={colors ? appTileStyle(colors) : undefined}
>
{/* eslint-disable-next-line react-hooks/static-components -- getIcon returns a stable icon component from a static registry, not one created during render */}
<Icon className={sizeClasses.glyph} />
Expand Down
26 changes: 24 additions & 2 deletions ui/packages/app-shell/src/layout/appTileColors.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/**
* The fallback app tile's colours, derived from an app's declared
* `branding.primaryColor` (objectui#12201). `AppMark` publishes them as CSS
* custom properties on the tile; see that component for why.
* `branding.primaryColor` (objectui#12201). `AppMark` and the home launcher's
* tiles publish them as CSS custom properties on the tile (`appTileStyle`),
* which the static `BRANDED_TILE_CLASSES` utilities consume.
*
* @module
*/

import type { CSSProperties } from 'react';
import { contrastRatio, hexToHSL } from '@object-ui/core';

/** The two foregrounds `AppShell` pairs with a brand colour (`--primary-foreground`). */
Expand Down Expand Up @@ -47,3 +49,23 @@ export function appTileColors(primaryColor: unknown): AppTileColors | undefined
fgDark: ON_BRAND_DARK,
};
}

/**
* The tile for a declared `primaryColor`. The utility strings are literals so
* Tailwind emits them at build time; the author's colour reaches them only as
* CSS custom properties, so `dark:` stays a real variant the theme controls
* (AGENTS.md section 2, the author-declared colour carve-out).
*/
export const BRANDED_TILE_CLASSES =
'bg-[color:var(--os-app-tile-bg)] text-[color:var(--os-app-tile-fg)] ' +
'dark:bg-[color:var(--os-app-tile-bg-dark)] dark:text-[color:var(--os-app-tile-fg-dark)]';

/** The custom properties `BRANDED_TILE_CLASSES` reads, for a tile's `style`. */
export function appTileStyle(colors: AppTileColors): CSSProperties {
return {
'--os-app-tile-bg': colors.bg,
'--os-app-tile-fg': colors.fg,
'--os-app-tile-bg-dark': colors.bgDark,
'--os-app-tile-fg-dark': colors.fgDark,
} as CSSProperties;
}
8 changes: 7 additions & 1 deletion ui/packages/plugin-gantt/src/GanttView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ export interface GanttViewProps {
* overwriting each other in the Downloads folder.
*/
exportFileName?: string
/**
* Heading of the task list's name column — what the rows are, e.g. the bound
* object's label ("Campaign"). Falls back to the generic "Task Name".
*/
taskColumnLabel?: string
/**
* Per-interaction switches. Omit for all-on. See
* {@link GanttInteractions}: e.g. `{ resize: false }` keeps bars movable and
Expand Down Expand Up @@ -928,6 +933,7 @@ export function GanttView({
dependencyTypes = true,
timeZone,
exportFileName,
taskColumnLabel,
interactions,
onBeforeTaskUpdate,
}: GanttViewProps) {
Expand Down Expand Up @@ -3821,7 +3827,7 @@ export function GanttView({
className="flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm"
style={{ width: taskListWidth, minWidth: taskListWidth }}
>
<div className="flex-1 truncate">{t('gantt.column.taskName')}</div>
<div className="flex-1 truncate" data-testid="gantt-task-column-heading">{taskColumnLabel || t('gantt.column.taskName')}</div>
{showSEColumns && (
<>
<div className="w-16 gantt-sm-w20 text-right">{t('gantt.column.start')}</div>
Expand Down
Loading
Loading