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
16 changes: 16 additions & 0 deletions .changeset/37150-docs-pages-in-app-shell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
'@objectstack/console': patch
---

feat(console): an app's documentation pages draw in the app shell from 768 px up

Clause-②: no
Metadata-protocol: none

From 768 px up every app page lost the top bar and keeps the app menu, search, notifications and account in the sidebar. An app's documentation pages (`/apps/APP/docs`, a book, a flat doc link, an article) were the one exception: they kept the top bar at every width and mounted no sidebar. They now draw like every other app page there: no top bar, the resident sidebar with its usual head (the app-name menu, collapse, search, notifications) and foot (the account), and the page header's button group (assistant and help) at the top right.

The documentation still has one navigation, its own: the sidebar's body carries the docs column (「← Back to APP」, every book of the app with the current one open, a title filter and 「All documentation」) in place of the app's menu. The reader no longer draws that column inside the page there. The app's other docs pages (its docs index, a book with no articles, a book or doc that is not found) carry the same column in the sidebar instead of a back link above the page.

Unchanged: every docs address resolves to the same page as before, and a phone keeps its app bar, no sidebar and the in-page column. The `/docs` portal is not changed by this release. Nothing to migrate.
39 changes: 20 additions & 19 deletions ui/apps/console/src/pages/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link, Navigate, useHref, useLocation, useNavigate, useParams } from 'react-router-dom';
import { AlertCircle, ChevronDown, ChevronRight, FileQuestion, Layers, Loader2, Menu } from 'lucide-react';
import { useAdapter } from '@object-ui/app-shell';
import { useAdapter, useSidebarDocsNavSlot } from '@object-ui/app-shell';
import { MarkdownRenderer, MermaidEnlargeContext, extractToc } from '@object-ui/plugin-markdown';
import { useObjectTranslation } from '@object-ui/i18n';
import { rewriteDocLinks } from './doc-links';
import { conflictCandidates, readsByNameAfter } from './doc-address';
import { DocShell } from './DocShell';
import { useAppDocsBackTo } from './useAppDocsBackTo';
import { DocsNav, type DocsNavBook } from './DocsNav';
import { DocsNav, usePackageDocsNavBooks } from './DocsNav';
import { DocRefusal } from './BookPage';
import { useBookData } from './use-book-data';
import { useActiveHeading } from './useActiveHeading';
Expand Down Expand Up @@ -249,17 +249,14 @@ export default function DocPage() {
const docHref = useCallback((docName: string) => `${base}/${slug}/${docName}`, [base, slug]);
// objectstack#35424 — the docs column lists every book of the package the
// reader is in: the current book's package, else the route's app package.
const packageBooks = useMemo<DocsNavBook[]>(() => {
const readerPackage = useMemo(() => {
const current = books.find((b) => bookSlug(b) === slug);
const pkg = current ? pkgOfBook(current) : appName;
if (!pkg) return [];
return books
.filter((b) => pkgOfBook(b) === pkg)
.map((b) => ({
slug: bookSlug(b),
book: labelUncategorized(resolveBookTree(b, allDocs, undefined, authoredBooks), uncategorizedLabel),
}));
}, [books, authoredBooks, allDocs, slug, appName, uncategorizedLabel]);
return current ? pkgOfBook(current) : appName;
}, [books, slug, appName]);
const packageBooks = usePackageDocsNavBooks(readerPackage);
// objectstack#37150 — inside an app from 768 px up the shell sidebar carries
// the column (`DocShell` draws it there); elsewhere the page draws it.
const sidebarNav = useSidebarDocsNavSlot() !== null;
const neighbours = useMemo(
() => (resolvedBook ? articleNeighbours(resolvedBook, name) : { previous: null, next: null }),
[resolvedBook, name],
Expand Down Expand Up @@ -397,31 +394,35 @@ export default function DocPage() {
) : null;
const docsLabel = t('help.documentation', { defaultValue: 'Documentation' });

const pageNav = sidebarNav ? null : docsNav;

return (
<DocShell backLink={!docsNav}>
<DocShell backLink={!docsNav} nav={docsNav ?? undefined}>
{/* objectstack#35424 — the docs column is the page's one navigation.
* Inside an app it sits where the app menu would, full height beside
* the article; on narrow screens it folds into a disclosure above it. */}
* Inside an app from 768 px up it is the shell sidebar's body, where the
* app menu would be (objectstack#37150); elsewhere it sits full height
* beside the article, and on narrow screens it folds into a disclosure
* above it. */}
<div className="flex min-h-full" data-testid="doc-reader">
{docsNav ? (
{pageNav ? (
<aside className="hidden w-72 shrink-0 border-r lg:block">
<nav
aria-label={t('help.docsNavigation', { defaultValue: 'Documentation navigation' })}
className={`sticky overflow-auto px-4 py-6 ${appName ? 'top-0 max-h-[calc(100svh-3rem)]' : 'top-12 max-h-[calc(100svh-3rem)]'}`}
>
{docsNav}
{pageNav}
</nav>
</aside>
) : null}
<div className="min-w-0 flex-1">
{docsNav ? (
{pageNav ? (
<details className="group mx-4 mt-4 sm:mx-6 lg:hidden">
<summary className="flex cursor-pointer list-none items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm font-medium [&::-webkit-details-marker]:hidden">
<Menu className="h-4 w-4 text-muted-foreground" />
<span className="truncate">{resolvedBook?.label ?? docsLabel}</span>
<ChevronDown className="ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180" />
</summary>
<div className="mt-2 rounded-md border p-3">{docsNav}</div>
<div className="mt-2 rounded-md border p-3">{pageNav}</div>
</details>
) : null}
<div className="mx-auto flex max-w-[1080px] justify-center gap-10 px-4 py-6 sm:px-8 lg:py-8">
Expand Down
49 changes: 40 additions & 9 deletions ui/apps/console/src/pages/DocShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,66 @@

import type { ReactNode } from 'react';
import { useParams } from 'react-router-dom';
import {
SidebarDocsNav,
useShellPageActionsSlot,
useShellSidebarExpandSlot,
useSidebarDocsNavSlot,
} from '@object-ui/app-shell';
import { AppDocsBackLink } from './AppDocsBackLink';
import { AppDocsNav, DocsNavLandmark } from './DocsNav';
import { useAppDocsBackTo } from './useAppDocsBackTo';

/**
* The frame of the package-documentation pages (ADR-0046), inside the
* console's own top bar. It draws no bar of its own (objectstack#35424):
* The frame of the package-documentation pages (ADR-0046). It draws no bar of
* its own (objectstack#35424):
*
* - Under an app (`/apps/:appName/docs/...`, ADR-0048) the app bar above reads
* 「APP / Documentation」, and the reader names its book and article above
* the article. An app's docs routes draw no app menu either, so the bar's
* place holds 「← Back to APP」 (`AppDocsBackLink`) on every page but the
* reader, which carries it in its docs column and passes `backLink={false}`.
* - Under an app (`/apps/:appName/docs/...`, ADR-0048), from 768 px up, the
* page is drawn in the app shell like every other app page
* (objectstack#37150, ruling 7142354097 on objectstack#36107): no top bar,
* the resident sidebar, and the page header's button group and expand
* button, which this frame draws at the page's top. The docs' one
* navigation column (the app's books, 「← Back to APP」 and all
* documentation) is the sidebar's body: the page hands it `nav`, the
* reader's own, else every book of the app (`AppDocsNav`).
* - Under an app on a phone the console's app bar is above the page, and the
* page carries 「← Back to APP」 itself: at the top here, on every page but
* the reader, which carries it in its in-page column and passes
* `backLink={false}`.
* - The portal (`/docs/...`) is drawn in Home's frame, whose bar reads
* 「PRODUCT / Documentation」 and links to the portal's index (`App.tsx`,
* the `docs` variant of `AppHeader`).
*/
export function DocShell({
backLink = true,
nav,
children,
}: {
/** Inside an app: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */
/** Without the shell sidebar: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */
backLink?: boolean;
/** The page's own docs column, for the shell sidebar (the reader's); else every book of the app. */
nav?: ReactNode;
children: ReactNode;
}) {
const { appName } = useParams<{ appName?: string }>();
const backTo = useAppDocsBackTo();
const sidebarNav = useSidebarDocsNavSlot() !== null;
const renderActions = useShellPageActionsSlot();
const renderExpand = useShellSidebarExpandSlot();
return (
<div className="min-h-full">
{appName && backLink && backTo ? (
{sidebarNav ? (
<SidebarDocsNav>
<DocsNavLandmark>{nav ?? <AppDocsNav />}</DocsNavLandmark>
</SidebarDocsNav>
) : null}
{renderActions || renderExpand ? (
<div className="flex items-center gap-2 px-4 pt-3 sm:px-6" data-testid="docs-page-header">
{renderExpand?.()}
<div className="ml-auto">{renderActions?.({})}</div>
</div>
) : null}
{appName && backLink && backTo && !sidebarNav ? (
<div className="mx-auto flex max-w-3xl px-4 pt-4 sm:px-6" data-testid="docs-back-bar">
<AppDocsBackLink backTo={backTo} />
</div>
Expand Down
61 changes: 57 additions & 4 deletions ui/apps/console/src/pages/DocsNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
* LICENSE file in the root directory of this source tree.
*/

import { useId, useState } from 'react';
import { Link } from 'react-router-dom';
import { useCallback, useId, useMemo, useState, type ReactNode } from 'react';
import { Link, useParams } from 'react-router-dom';
import { ArrowRight, ChevronDown, ChevronRight, Search } from 'lucide-react';
import { useObjectTranslation } from '@object-ui/i18n';
import { AppDocsBackLink } from './AppDocsBackLink';
import type { AppDocsBackTo } from './useAppDocsBackTo';
import { useAppDocsBackTo, type AppDocsBackTo } from './useAppDocsBackTo';
import { BookSidebar } from './BookSidebar';
import { bookArticles, filterBookArticles } from './docs-reading';
import type { ResolvedBook } from './book-nav';
import { bookSlug, labelUncategorized, pkgOfBook, resolveBookTree, type ResolvedBook } from './book-nav';
import { useBookData } from './use-book-data';

/** One book of the column: its resolved spine and its URL segment. */
export interface DocsNavBook {
Expand Down Expand Up @@ -128,3 +129,55 @@ export function DocsNav({
</div>
);
}

/**
* Every book of package `pkg`, resolved for the column (objectstack#35424):
* the reader's books, and those of an app's other docs pages. Empty with no
* package.
*/
export function usePackageDocsNavBooks(pkg: string | undefined): DocsNavBook[] {
const { t } = useObjectTranslation();
const { books, authoredBooks, docs } = useBookData();
const uncategorizedLabel = t('help.uncategorized', { defaultValue: 'Uncategorized' });
return useMemo(() => {
if (!pkg) return [];
return books
.filter((b) => pkgOfBook(b) === pkg)
.map((b) => ({
slug: bookSlug(b),
book: labelUncategorized(resolveBookTree(b, docs, undefined, authoredBooks), uncategorizedLabel),
}));
}, [books, authoredBooks, docs, pkg, uncategorizedLabel]);
}

/**
* The column as the shell sidebar carries it (objectstack#37150): the same
* column, under its own navigation landmark.
*/
export function DocsNavLandmark({ children }: { children: ReactNode }) {
const { t } = useObjectTranslation();
return (
<nav aria-label={t('help.docsNavigation', { defaultValue: 'Documentation navigation' })} className="pt-2">
{children}
</nav>
);
}

/**
* The column of an app's docs page other than the reader (the app's docs
* index, a book with no articles, a book or doc not found): the app's books,
* the way back to the app and all documentation. The reader builds its own,
* from the book its article is in.
*/
export function AppDocsNav() {
const { appName, slug } = useParams<{ appName?: string; slug?: string }>();
const books = usePackageDocsNavBooks(appName);
const backTo = useAppDocsBackTo();
const docHref = useCallback(
(bookSegment: string, doc: string) => `/apps/${appName}/docs/${bookSegment}/${doc}`,
[appName],
);
return (
<DocsNav books={books} currentSlug={slug} docHref={docHref} backTo={backTo} allDocsHref="/docs" />
);
}
Loading
Loading