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
25 changes: 25 additions & 0 deletions .changeset/35883-phone-list-toolbar-panels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'@object-ui/plugin-list': patch
'@object-ui/plugin-grid': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(list): a phone's object list gets its own top row, one row of pills, and bottom-sheet sort, filter and view panels that apply on 「✓」

Clause-②: yes (widening)
Metadata-protocol: none

At phone width (below `sm`) the console's object list changes its containers, not its content:

- The app bar's row becomes the page's own: 「‹」, the object's icon and name, and 「⋮ More」 at the right. The app pill, the page title, the search, the bell and the avatar are not drawn while the list is on screen (the phone has them in the bottom bar and on the app's home). 「⋮ More」 offers 「Select」 (only on a card list whose rows take more than one tick), the object's description, Import and the favorite.
- Below it, one row of pills: the view switcher, Sort and Filter with a count of what is in force, and Search, which expands into a field in place. There is no condition row on a phone.
- Sort, Filter, the view switcher and View settings open as bottom sheets. The sort and filter sheets edit a copy: 「✓」 applies it through the same write the desktop chips use, 「×」 drops it. The sort sheet lists each level on two lines (field over direction) with a handle a finger can drag (or ArrowUp / ArrowDown moves), a ⋯ menu per level (change field, direction, remove) and 「Add sort」. The filter sheet lists the conditions, each with a ⋯ menu (edit, remove), and shows a sentence and 「Add filter」 when there are none. A view whose filter is an 「or」 group says it uses an advanced filter and is changed on a computer. View settings keeps its desktop content and applies as before. 「✓」 on an untouched copy writes nothing. While the on-screen keyboard is up, a sheet stands on it (it reads `visualViewport`), so its 「✓」 and the focused field stay in view.
- A long press on a card starts selecting with that card ticked, as 「Select」 in 「⋮ More」 does with none; a tap then ticks or unticks a card, and unticking the last ends it. The selection shows in the list's floating selection bar, which after 「Select」 reads 「0 selected ×」 until a card is ticked. The 「+」 create button is not drawn while selecting. A card is also a keyboard control: Enter opens it, and while selecting Enter or Space toggles it.

New exports and props:

- `@object-ui/plugin-list`: `PhonePanelSheet`, `useListPhonePanels`, `PHONE_CHIP`, `PHONE_CHIP_ACTIVE` and the types `PhonePanelSheetProps`, `ListPhonePanels`.
- `@object-ui/plugin-grid`: `requestListSelection`, `useListPageSelecting` and `useListPageSelectable` (would 「Select」 open a selection in this page's list); `BulkActionBar` takes `open` (show 「0 selected ×」 with no actions while a host's selection is open and empty).

`@object-ui/app-shell` changes no public export: the page's top row is an internal store (`PhonePageBarProvider`, mounted by `ConsoleLayout`).
4 changes: 3 additions & 1 deletion ui/e2e/list-frame-geometry-35548.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ const SWITCHER_TRIGGER = carrying(
);
/** The trigger's children in source order, read off their test ids. */
const SWITCHER_PARTS = ['type-icon', 'label', 'count', 'caret'] as const;
const switcherBody = SRC.switcher.slice(SRC.switcher.indexOf('data-testid="list-view-switcher"'), SRC.switcher.indexOf('</PopoverTrigger>'));
// The desktop trigger, inside its popover's trigger: the phone toolbar's pill
// (objectstack#35883) comes first in the file and draws no type icon.
const switcherBody = SRC.switcher.slice(SRC.switcher.indexOf('<PopoverTrigger'), SRC.switcher.indexOf('</PopoverTrigger>'));

// ── grid ────────────────────────────────────────────────────────────────────
const DENSITY = (() => {
Expand Down
230 changes: 83 additions & 147 deletions ui/e2e/list-toolbar-view-name-phone.spec.ts

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions ui/packages/app-shell/src/layout/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
} from 'lucide-react';
import { usePhoneViewport } from '../hooks/usePhoneViewport.js';
import { isPhoneTabRoute } from './PhoneAppNavBar.js';
import { PhonePageBarEnd, PhonePageBarTitle, useHasPhonePageBar } from './PhonePageBar.js';

import { useState, useEffect, useLayoutEffect, useCallback, useRef, type RefObject } from 'react';
import { useOffline } from '@object-ui/react';
Expand Down Expand Up @@ -463,6 +464,11 @@ export function AppHeader({
// leftmost control is 「‹」 back to the app's home.
const phone = usePhoneViewport();
const phoneTab = isApp && phone && isPhoneTabRoute(location.pathname);
// objectstack#35883 — a page with its own phone top row (the object list:
// its icon and name, then its 「⋮ More」) takes the bar's middle and right:
// no app pill, search, bell, assistant or avatar there.
const hasPhonePageBar = useHasPhonePageBar();
const phonePageBar = isApp && phone && !phoneTab && hasPhonePageBar;
const phoneAppHome = `/apps/${params.appName ?? activeAppName ?? ''}`;
const { isOnline } = useOffline();
// Idempotent, direct open of the ⌘K command palette (ADR-0054 C1). Replaces a
Expand Down Expand Up @@ -1008,7 +1014,8 @@ export function AppHeader({
</>
)}

{isApp && (
{phonePageBar && <PhonePageBarTitle />}
{isApp && !phonePageBar && (
<>
{/* App pill — the app's glyph and name, and its switcher, after
the product mark's `/` rule. At every width: below `sm` it is
Expand Down Expand Up @@ -1104,7 +1111,8 @@ export function AppHeader({

{/* Group 1: Search */}
{/* Only where a palette is mounted (objectui#11912) — see `hasCommandPalette`. */}
{hasCommandPalette && !phoneTab && (
{phonePageBar && <PhonePageBarEnd />}
{hasCommandPalette && !phoneTab && !phonePageBar && (
<div
data-topbar-group
data-topbar-search
Expand All @@ -1128,7 +1136,7 @@ export function AppHeader({
)}

{/* Group 2: Edit app, Inbox (notifications + approvals + activity) & Help */}
<div data-topbar-group className="flex items-center gap-0.5 shrink-0">
<div data-topbar-group className={cn('flex items-center gap-0.5 shrink-0', phonePageBar && 'hidden')}>
{/* Edit app — the app → builder reverse bridge (ADR-0080), at the
left edge of this utility cluster (objectui#12201 item 6).
Admins jump from the running app to its owning package's design
Expand Down Expand Up @@ -1286,7 +1294,7 @@ export function AppHeader({
</div>

{/* Group 3: Account (theme + lang moved into avatar dropdown) */}
<div data-topbar-group className="flex items-center gap-0.5 shrink-0"> {/* User Profile + Organization switcher */}
<div data-topbar-group className={cn('flex items-center gap-0.5 shrink-0', phonePageBar && 'hidden')}> {/* User Profile + Organization switcher */}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
Expand Down
4 changes: 4 additions & 0 deletions ui/packages/app-shell/src/layout/ConsoleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ConsoleNotificationBanners } from './ConsoleNotificationBanners.js';
import { UnifiedSidebar } from './UnifiedSidebar.js';
import { PhoneAppNavBar, isPhoneTabRoute } from './PhoneAppNavBar.js';
import { PhoneAppHomeSlotProvider } from './PhoneAppHome.js';
import { PhonePageBarProvider } from './PhonePageBar.js';
import { useLastApp } from '../context/LastAppProvider.js';
import { useMetadata } from '../providers/MetadataProvider.js';
import { appAddressSegment } from '../utils/appRoute.js';
Expand Down Expand Up @@ -258,6 +259,8 @@ export function ConsoleLayout({
{/* objectstack#35881 — the phone app home's slot, shared by the sidebar
(which draws the menu into it) and the route (which holds it). */}
<PhoneAppHomeSlotProvider>
{/* objectstack#35883 — a page's own phone top row, drawn by the app bar. */}
<PhonePageBarProvider>
<AppShell
sidebar={
docsPage ? undefined : (
Expand Down Expand Up @@ -356,6 +359,7 @@ export function ConsoleLayout({
{/* Under `md` the drawer is a bottom sheet (no room for a rail on a phone). */}
{chatDock.sheet}
</AppShell>
</PhonePageBarProvider>
</PhoneAppHomeSlotProvider>
</CommandPaletteProvider>
</ChatDockControlProvider>
Expand Down
116 changes: 116 additions & 0 deletions ui/packages/app-shell/src/layout/PhonePageBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* PhonePageBar
*
* objectstack#35883 — a page's own top row on a phone. A page that has one (the
* object list: 「‹」, the object's icon and name, 「⋮ More」) publishes it here,
* and the app bar draws it in place of the app pill, the page title, the
* search, the bell and the avatar while the page is on screen: on a phone the
* notifications live in the bottom bar and the avatar on the app's home
* (objectstack#35881, #35882), and the list carries its own search. The bar's
* 「‹」 back to the app's home stays the app bar's own.
*
* A store rather than state in a context value: the page publishes a new
* element on every render, and only the two small views below re-render for
* it, never the app bar or the page.
*
* @module
*/

import * as React from 'react';
import { useLayoutEffect, useState, useSyncExternalStore } from 'react';

export interface PhonePageBar {
/** The page's icon (the object's), drawn before the title. */
icon?: React.ReactNode;
/** The page's name, the row's heading. */
title: string;
/** The row's right end (the list's 「⋮ More」). */
end?: React.ReactNode;
}

interface PhonePageBarStore {
get: () => PhonePageBar | null;
set: (next: PhonePageBar | null) => void;
subscribe: (listener: () => void) => () => void;
}

function createPhonePageBarStore(): PhonePageBarStore {
let current: PhonePageBar | null = null;
const listeners = new Set<() => void>();
return {
get: () => current,
set: (next) => {
if (Object.is(next, current)) return;
current = next;
listeners.forEach((listener) => listener());
},
subscribe: (listener) => {
listeners.add(listener);
return () => listeners.delete(listener);
},
};
}

const PhonePageBarContext = React.createContext<PhonePageBarStore | null>(null);

/** Holds the store the page publishes into and the app bar reads. `ConsoleLayout` mounts it. */
export function PhonePageBarProvider({ children }: { children: React.ReactNode }) {
const [store] = useState(createPhonePageBarStore);
return <PhonePageBarContext.Provider value={store}>{children}</PhonePageBarContext.Provider>;
}

/**
* The page's side: publish `bar` (or `null` for none) while mounted. Called on
* every render with the page's current bar; withdrawn on unmount.
*/
export function usePublishPhonePageBar(bar: PhonePageBar | null): void {
const store = React.useContext(PhonePageBarContext);
useLayoutEffect(() => {
store?.set(bar);
});
useLayoutEffect(() => () => store?.set(null), [store]);
}

const noSubscribe = () => () => {};

/** Does a page publish its own top row now? The app bar's one read of the store. */
export function useHasPhonePageBar(): boolean {
const store = React.useContext(PhonePageBarContext);
return useSyncExternalStore(
store?.subscribe ?? noSubscribe,
() => !!store?.get(),
() => false,
);
}

function usePhonePageBar(): PhonePageBar | null {
const store = React.useContext(PhonePageBarContext);
return useSyncExternalStore(store?.subscribe ?? noSubscribe, () => store?.get() ?? null, () => null);
}

/** The row's middle: the page's icon and name, the page's heading. */
export function PhonePageBarTitle() {
const bar = usePhonePageBar();
if (!bar) return null;
return (
<span className="flex min-w-0 items-center gap-2 px-1" data-testid="phone-page-bar-title">
{bar.icon && (
<span className="flex shrink-0 text-muted-foreground" aria-hidden="true">
{bar.icon}
</span>
)}
<h1 className="min-w-0 truncate text-base font-semibold">{bar.title}</h1>
</span>
);
}

/** The row's right end. */
export function PhonePageBarEnd() {
const bar = usePhonePageBar();
if (!bar?.end) return null;
return (
<div className="flex shrink-0 items-center" data-testid="phone-page-bar-end">
{bar.end}
</div>
);
}
Loading
Loading