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
15 changes: 15 additions & 0 deletions .changeset/35424-docs-reader-one-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/console': patch
'@object-ui/app-shell': patch
'@object-ui/plugin-markdown': patch
'@object-ui/i18n': patch
---

feat(console): an app's docs page has one navigation — the docs column — with the path to its book and the previous and next article

Clause-②: yes (widening) — @object-ui/plugin-markdown exports MermaidEnlargeContext and MermaidEnlargeText; @object-ui/i18n adds 12 help.* keys; nothing removed
Metadata-protocol: none

Inside an app, the documentation pages (`/apps/<app>/docs/…`) no longer draw the app menu beside the docs: the left column is the docs' own, with 「← Back to <app>」 at its top, a title filter, every book of the app's package (the current book open, the others folded, each with its article count; long titles wrap instead of truncating) and 「All documentation →」 at its foot. Every other docs page inside an app (the app's docs index, a book with no articles, a book or doc not found) carries the same 「← Back to <app>」 at its top. The app bar stays, and reads 「<app> / Documentation」; the separate 「Documentation / <title>」 bar under it is gone, and the path above the article names the book (Documentation › <book>). 「On this page」 marks the section being read as the page scrolls, and the article ends with its book's previous and next article. The article column is 720 px wide at 15 px, and a diagram carries an 「Enlarge」 control that opens it full size.

`@object-ui/plugin-markdown` adds `MermaidEnlargeContext`: a host that provides its words gets the enlarge control on every rendered diagram; with no provider a diagram renders exactly as before. `@object-ui/app-shell` exports `matchAppBySegment` and `useServedAppLabel`, and `isAppDocsPath` beside `isRecordPagePath` from its `ConsoleLayout` module. New `help.*` keys in every shipped locale. No doc content, doc metadata, route or API changes.
32 changes: 32 additions & 0 deletions ui/apps/console/src/pages/AppDocsBackLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* ObjectUI
* Copyright (c) 2024-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Link } from 'react-router-dom';
import { ArrowLeft } from 'lucide-react';
import { useObjectTranslation } from '@object-ui/i18n';
import type { AppDocsBackTo } from './useAppDocsBackTo';

/**
* 「← Back to APP」 (objectstack#35424). An app's docs routes draw no app
* menu, so every docs page inside an app carries this link: the reader in
* its docs column, every other page (the app's docs index, a book with no
* articles, a book or doc not found) at the top, through `DocShell`.
*/
export function AppDocsBackLink({ backTo }: { backTo: AppDocsBackTo }) {
const { t } = useObjectTranslation();
return (
<Link
to={backTo.to}
data-testid="docs-nav-back"
className="inline-flex items-center gap-1.5 self-start rounded px-2 py-1 text-sm font-medium text-primary hover:bg-muted/50"
>
<ArrowLeft className="h-4 w-4 shrink-0" aria-hidden />
<span>{t('help.backToApp', { defaultValue: 'Back to {{app}}', app: backTo.label })}</span>
</Link>
);
}
28 changes: 20 additions & 8 deletions ui/apps/console/src/pages/BookSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import type { ResolvedBook } from './book-nav';
* alongside the single-doc reader so a reader can move within the book
* without losing their place.
*
* A long title wraps rather than truncating, so every entry is readable in
* full (objectstack#35424).
*
* Routing is delegated: the parent supplies `docHref` so the same sidebar
* works under the top-level `/docs/:name` route and the package-scoped
* `/apps/:appName/docs/:name` route.
Expand All @@ -24,22 +27,31 @@ export function BookSidebar({
book,
activeDoc,
docHref,
showLabel = true,
groupHeadings = 'always',
}: {
book: ResolvedBook;
activeDoc?: string;
docHref: (docName: string) => string;
/** Draw the book's label above its groups; off where a parent already names the book (the docs column). */
showLabel?: boolean;
/** `multi`: a book of one group lists its entries under no heading, the book's name being the heading. */
groupHeadings?: 'always' | 'multi';
}) {
const headings = groupHeadings === 'always' || book.groups.length > 1;
return (
<nav aria-label={book.label ?? book.name} className="text-sm">
{book.label ? (
{showLabel && book.label ? (
<div className="mb-3 px-2 text-sm font-semibold text-foreground">{book.label}</div>
) : null}
<div className="space-y-5">
<div className={headings ? 'space-y-5' : undefined}>
{book.groups.map((group) => (
<div key={group.key}>
<div className="mb-1 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
{group.label}
</div>
{headings ? (
<div className="mb-1 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
{group.label}
</div>
) : null}
<ul className="space-y-0.5">
{group.entries.map((entry, i) => {
if (entry.separator) {
Expand All @@ -54,7 +66,7 @@ export function BookSidebar({
rel="noreferrer"
className="flex items-center gap-1.5 rounded px-2 py-1 text-muted-foreground hover:bg-muted/50 hover:text-foreground"
>
<span className="truncate">{entry.label ?? entry.href}</span>
<span className="break-words">{entry.label ?? entry.href}</span>
<ExternalLink className="h-3 w-3 shrink-0 opacity-60" />
</a>
</li>
Expand All @@ -67,9 +79,9 @@ export function BookSidebar({
<Link
to={docHref(entry.doc)}
aria-current={active ? 'page' : undefined}
className={`block truncate rounded px-2 py-1 transition ${
className={`block break-words rounded px-2 py-1.5 leading-snug transition ${
active
? 'bg-primary/10 font-medium text-foreground'
? 'bg-primary/10 font-medium text-primary'
: 'text-muted-foreground hover:bg-muted/50 hover:text-foreground'
}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ describe("a doc-to-doc link in an app's doc stays in that app's docs route (obje
it('CONTROL: outside an app the header home link is still the portal', async () => {
renderDoc('/_console');
await screen.findByRole('link', { name: 'index' });
expect(screen.getByRole('link', { name: 'Documentation' }).getAttribute('href')).toBe('/_console/docs');
// The portal header's home link, and the path above the article
// (objectstack#35424): both name the portal.
const links = screen.getAllByRole('link', { name: 'Documentation' });
expect(links.map((l) => l.getAttribute('href'))).toEqual(links.map(() => '/_console/docs'));
});
});
Loading
Loading