Skip to content

Commit 79351a6

Browse files
committed
feat(app-shell): the record page's and the record drawer's record row lead with the object's colour tile
Claude-Session: https://claude.ai/code/session_01L6bhgWCsFBKwcq7ocDfUhR Co-authored-by: Claude <noreply@anthropic.com>
1 parent 14c1cfa commit 79351a6

4 files changed

Lines changed: 41 additions & 14 deletions

File tree

‎.changeset/35985-object-color-tile-everywhere.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ Metadata-protocol: none
1515
The tile the navigation already draws for an object (a white glyph on the object's palette colour, gray when it has none) now also names the object in:
1616

1717
- **List and data pages:** the page bar and the view bar's object name in front of the view switcher; the URL data page's header.
18+
- **The record page and the record drawer:** the record row in front of the record's name.
1819
- **The record page's related lists:** each section's title, with the list's own icon else the related object's, on that object's colour.
1920
- **Search:** the command palette's recent records, record hits and object entries; the search results page (group headings and hit cards); the global search block.
2021
- **Home:** a record row in "Recently accessed".
2122
- **References:** a pointer cell in a grid (`referenceVia`) and the record hover card.
2223
- **Studio:** the data pillar's object list and header, and the interfaces pillar's object entries and header.
2324

24-
`ConsolePageHeader` takes `iconTile`, an icon that draws its own square, drawn as given in every posture in place of `icon`. `RecordSearchHit.color` carries the object's palette name beside `icon`. `ObjectIconTile`'s glyph keeps its size inside a host row that sizes every nested `svg`.
25+
`ConsolePageHeader` takes `iconTile`, an icon that draws its own square, drawn as given in every posture in place of `icon`. `RecordSearchHit.color` carries the object's palette name beside `icon`, and `RecordHoverCardObjectDef` names `color` beside `icon`. `ObjectIconTile`'s glyph keeps its size inside a host row that sizes every nested `svg`.

‎ui/packages/app-shell/src/views/RecordDetailView.topBar-27524.test.tsx‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const APP = 'demo';
7171
const LEAD = 'crm_lead';
7272
const BASE_FIELDS = { id: { type: 'text', label: 'Id' }, name: { type: 'text', label: 'Name' } };
7373
const OBJECTS = [
74-
{ name: LEAD, label: 'Lead', pluralLabel: 'Leads', fields: BASE_FIELDS },
74+
// objectstack#35985 — a coloured object, so the record row's tile is pinned below.
75+
{ name: LEAD, label: 'Lead', pluralLabel: 'Leads', icon: 'user', color: 'orange', fields: BASE_FIELDS },
7576
{ name: 'crm_task', label: 'Task', pluralLabel: 'Tasks', fields: { ...BASE_FIELDS, lead: { type: 'lookup', reference: LEAD, label: 'Lead' } } },
7677
];
7778
const ROWS = ['r-1', 'r-2', 'r-3'];
@@ -361,3 +362,28 @@ describe('the pane\'s top bar names the record (objectstack#27524)', () => {
361362
await waitFor(() => expect(paneTitle()).toBe('Record r-2'), { timeout: 5000 });
362363
});
363364
});
365+
366+
describe('the record row leads with the object\'s colour tile (objectstack#35985)', () => {
367+
it('on the page: the tile in the object\'s colour, before the record\'s name', async () => {
368+
mountPage(`/apps/${APP}/${LEAD}/record/r-1`);
369+
await screen.findByRole('group', { name: 'Panels' }, { timeout: 5000 });
370+
const record = pageBar()!.querySelector('[data-record-top-bar-record]') as HTMLElement;
371+
const tiles = record.querySelectorAll('[data-object-icon-tile]');
372+
expect(tiles).toHaveLength(1);
373+
expect(tiles[0].getAttribute('data-object-icon-tile')).toBe('orange');
374+
});
375+
376+
it('in a pane: the pane\'s record row draws the same tile', async () => {
377+
render(
378+
<MemoryRouter initialEntries={[`/apps/${APP}/${LEAD}?recordId=r-1`]}>
379+
<MetadataCtx.Provider value={metadata}>
380+
<PaneHost dataSource={makeDataSource()} />
381+
</MetadataCtx.Provider>
382+
</MemoryRouter>,
383+
);
384+
await waitFor(() => expect(document.querySelector('[data-record-bar-title] h1')?.textContent).toBe('Record r-1'), { timeout: 5000 });
385+
const tiles = document.querySelectorAll('[data-record-top-bar] [data-object-icon-tile]');
386+
expect(tiles).toHaveLength(1);
387+
expect(tiles[0].getAttribute('data-object-icon-tile')).toBe('orange');
388+
});
389+
});

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
* (`buildDefaultPageSchema`).
99
*/
1010

11-
import { createElement, useState, useEffect, useLayoutEffect, useCallback, useContext, useMemo, useRef, type ReactElement } from 'react';
11+
import { useState, useEffect, useLayoutEffect, useCallback, useContext, useMemo, useRef, type ReactElement } from 'react';
1212
import { useParams, useNavigate, useLocation, useSearchParams, Link } from 'react-router-dom';
1313
import { activityRowToFeedItem, composeImpersonatedActor, IMPERSONATED_ACTOR_FALLBACK, auditEntriesToFeedItems, bodyTableIdsOf, claimQueuedRecord, RECORD_PAGE_TIMELINE_PANEL, RECORD_TIMELINE_PANEL_MAX_ENTRIES, RecordFieldChangesContext, RecordFieldHistoryContext, RecordTimelineTotalContext, DefaultRecordPageContext, EMPTY_RELATED_ARRANGEMENT, InlineEditSaveBar, RecordBodyTablesContext, RecordMetaFooter, RecordPageColumns, buildDefaultPageColumns, buildDefaultPageSchema, extractMentions, isRefusedFeedRead, recordPageTierHasRightColumn, recordSitsInQueue, resolveTitleField, useQueueClaimOffered, useRecordEditable, useRecordPageTier } from '@object-ui/plugin-detail';
14-
import { Empty, EmptyTitle, EmptyDescription, Button, PageHeaderActions, PageHeaderPhoneContext, PageHeaderTrailingContext, PanelToggles, RecordHeaderBarContext, RecordHeaderStateContext, RecordTopBar, RecordTopBarButton, cn, useRecordStepKeys, type PanelToggleItem, type RecordHeaderBar, type RecordHeaderGroupParts, type RecordHeaderState, type RecordTopBarStepper } from '@object-ui/components';
15-
import { getIcon } from '../utils/getIcon.js';
14+
import { Empty, EmptyTitle, EmptyDescription, Button, PageHeaderActions, PageHeaderPhoneContext, PageHeaderTrailingContext, PanelToggles, ObjectIconTile, RecordHeaderBarContext, RecordHeaderStateContext, RecordTopBar, RecordTopBarButton, cn, useRecordStepKeys, type PanelToggleItem, type RecordHeaderBar, type RecordHeaderGroupParts, type RecordHeaderState, type RecordTopBarStepper } from '@object-ui/components';
1615
import { isActingApprover } from '../utils/approvalDecisionFold.js';
1716
import { useAuth, createAuthenticatedFetch } from '@object-ui/auth';
1817
import { usePermissions } from '@object-ui/permissions';
@@ -5278,10 +5277,11 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
52785277
data-record-bar-title=""
52795278
/>
52805279
);
5280+
// objectstack#35985 — the record row leads with the object's tile: white
5281+
// glyph on the object's colour, gray without one.
52815282
const objectIconName = typeof (objectDef as any)?.icon === 'string' ? ((objectDef as any).icon as string) : undefined;
5282-
const objectIcon = objectIconName
5283-
? createElement(getIcon(objectIconName), { className: 'h-4 w-4 shrink-0 text-muted-foreground', 'aria-hidden': true })
5284-
: null;
5283+
const objectColor = typeof (objectDef as any)?.color === 'string' ? ((objectDef as any).color as string) : undefined;
5284+
const objectIcon = objectIconName ? <ObjectIconTile icon={objectIconName} color={objectColor} /> : null;
52855285
const pageLeading = embedded ? null : pageTrail.length > 0 ? (
52865286
<>
52875287
{originFrom?.pathname && (

‎ui/packages/app-shell/src/views/recordDrawerStack.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import {
4242
Fragment,
4343
createContext,
44-
createElement,
4544
useCallback,
4645
useContext,
4746
useEffect,
@@ -56,13 +55,13 @@ import {
5655
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
5756
import { createPortal } from 'react-dom';
5857
import { ChevronRight } from 'lucide-react';
59-
import { getIcon } from '../utils/getIcon.js';
6058
import {
6159
NavigationOverlay,
6260
type NavigationOverlayMode,
6361
type RecordTopBarStepper,
6462
RecordHeaderBarContext,
6563
type RecordHeaderBar,
64+
ObjectIconTile,
6665
} from '@object-ui/components';
6766
import { overlayWidthFor } from '@object-ui/plugin-view/core';
6867
import type { FieldContainerLike } from '@object-ui/core';
@@ -552,10 +551,11 @@ export function RecordStackDrawer({
552551
const titleOf = (level: RecordDrawerLevel) => titles[levelKey(level)!] || level.title || shortId(level.recordId);
553552
const crumbClass =
554553
'min-w-0 truncate rounded px-1 hover:bg-accent hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring';
555-
// The record row's icon: the object's, as the full page draws it.
556-
const rootIconName = current ? (defOf(current.objectName) as { icon?: unknown } | undefined)?.icon : undefined;
557-
const rootIcon = typeof rootIconName === 'string'
558-
? createElement(getIcon(rootIconName), { className: 'h-4 w-4 shrink-0 text-muted-foreground', 'aria-hidden': true })
554+
// The record row's icon: the object's tile, as the full page draws it
555+
// (objectstack#35985 — white glyph on the object's colour, gray without one).
556+
const rootDef = current ? (defOf(current.objectName) as { icon?: unknown; color?: unknown } | undefined) : undefined;
557+
const rootIcon = typeof rootDef?.icon === 'string'
558+
? <ObjectIconTile icon={rootDef.icon} color={typeof rootDef.color === 'string' ? rootDef.color : undefined} />
559559
: null;
560560
// objectstack#35853 — the bar's record row: the icon, then the record's
561561
// name and tags as the record header draws them into the slot; until it

0 commit comments

Comments
 (0)