1A module: a file tree and code pane, followed by the system's index
2navigation. An optional section heading and footer complete the module.
3
4Use it when a page needs to present a collection of files with named
5entry points. Navigation is part of the module, not an optional variant.
6
7For one standalone file or command example, use the Code Snippet
8component instead. That has no tree, section wrapper or index.
9
10## API and navigation
11
12Pass `files` and `entries`. Each entry has a `label`, `description`,
13and `path` naming the tree row it selects, usually a top-level folder
14or file such as `agents` or `factory.yaml`.
15
16Each index option shows its headline above its description, using the
17same mono-label and body-copy typography as the interactive media player.
18Static two-digit ordinals (01, 02, …) sit beside the headlines in the
19media player's marker column. They never turn into play/pause controls.
20Descriptions align with the headlines, and items have no divider rules.
21Labels also supply accessible button names, with descriptions associated
22for screen readers.
23The visible index title is omitted; navigationTitle is its accessible
24name. This omits only the overall index heading, not each option's label.
25
26Inactive numbers, labels and descriptions are dimmed. The active number and headline use
27full ink and its description uses body ink. Hover does not fill,
28brighten or select an option. Click or keyboard activation
29changes selection, and keyboard focus retains an outline. The index
30sits 8px below the code panel, without an intervening heading.
31
32Entry order is independent of file order. Do not map by array index.
33Tree clicks and the index share one selection, and an entry and its
34tree row behave identically. Selecting a directory keeps that folder
35selected and shows its first file, which gets a light accent tint.
36An entry stays current while anything inside its folder is selected.
37
38`headline` and `lead` add the section head; `id` supplies its anchor.
39`headerAction` places a TextButton with that heading and lead, above
40the code panel. Use it for the section CTA, not `footer`.
41`navigationTitle` names the index for assistive technology.
42`footer` accepts page-specific notes without another section wrapper.
43
44## Homepage example
45
46`/brand-workshop/home` uses the module for Factory configuration.
47All eight navigation entries use the real walkthrough's titles and
48descriptions, and select the same top-level folder or file as the
49`/factories/configuration` tabs. The homepage explicitly enables
50the optional line-group annotations described below; plain panels
51remain the default elsewhere.
52
53## Optional line annotations
54
55Set `annotations` on CodePanel to enable each file's authored
56`annotations` array. The catalogue's Context control switches between
57Plain and Annotated. No annotation metadata means ordinary code.
58
59Each annotation has a stable `id`, one-based inclusive `startLine`
60and `endLine`, a `description`, optional `label`, and optional `href`
61for documentation. Ranges must not overlap. Invalid ranges are ignored
62without dropping or duplicating source lines.
63
64For a file whose first two lines are a secrets section:
65
66```ts
67annotations: [{
68 id: 'secrets',
69 startLine: 1,
70 endLine: 2,
71 label: 'Secrets',
72 description: 'Credentials are injected only during runs.',
73 href: 'https://docs.warp.dev/factories/factory-as-code/#secrets',
74}]
75```
76
77Attach that metadata to the file and pass `annotations` on CodePanel
78or CodeSnippet. Line ranges count blank lines too.
79
80Hover or keyboard focus highlights the whole range and shows its
81context. Escape, blur, scrolling or changing files dismisses it.
82Callouts are hoverable and use the browser's popover top layer where
83available, retaining tokens without being clipped by the code pane.
84A docs-backed range is a native link that opens a new tab; the callout
85has the matching external arrow.
86
87On narrow or coarse-pointer layouts, a range becomes a disclosure:
88tap or activate it to expand the explanation and its docs link inline.
89Do not make important context depend exclusively on mouse hover.
90
91Line numbers and copying still use the original code lines. Annotation
92prose, icons and disclosure controls never enter the copied text.
93Source rendering is language-agnostic; any key highlighting is authored
94by the caller. The homepage adapter preserves the live walkthrough's
95text and hints, while styling them with workshop tokens.
96
97## Shared rendering
98
99Code Panel, Code Snippet and Fig Frame source views share the internal
100CodeBrowser renderer. Do not use that internal renderer directly on a
101page to bypass the module's navigation.
102
103A line is a string, or a `{ key, text }` pair where the key renders in
104the accent. Enough for config formats, and no lexer to keep current.
105
106## The grid stops at the frame
107
108Turn the alignment overlay on and the panel's outer edges sit on the
109columns, but the divider between tree and pane does not. That is
110deliberate. The panel is a bordered object with an interior of its own,
111and running a 32px page gutter through the middle of a window would
112break the window to satisfy a rule about the page — see the exception
113named in R-11.
114
115The interior is still divided by the same number: three parts tree to
116nine parts pane. It replaced a 1 : 2.2 ratio that had been picked by
117eye.
118
119
120Long lines wrap rather than scroll. A horizontal scrollbar inside the
121pane breaks the drawing.