App frame
An application stands in one frame, edge to edge in the window. A bar two squares high runs along the top with the app’s name, what the app puts after it (a breadcrumb, tabs, a search) and its actions at the end. Under it the navigation, the work and an inspector stand side by side, each scrolling on its own, with a hairline between them. On desktop, the navigation starts directly below the bar. In the Docs example, its divider continues through the bar. The navigation and the inspector are resized by dragging the line between them and the work, in whole squares, and the widths are remembered for the app. Open the full-window example and resize the window to see it hold.
Try it
Section titled “Try it”The bar, the navigation, the work and an inspector. Drag a line beside a pane, or focus it and use the arrow keys: the pane moves in whole squares.
<code data-source="html"><ds-app name="Docs" home="#" resize-key="example-app" grid-anchor="bottom" nav-width="8" aside-width="8" fixed-scale>
<span slot="bar">Workspace / Spring survey</span>
<div slot="actions"><ds-button secondary>Share</ds-button></div>
<ds-sidebar slot="nav" label="Notebooks"></ds-sidebar>
<ds-row slot="header" fill><ds-text literal strong>Spring survey</ds-text><ds-button primary>New note</ds-button></ds-row>
<ds-list>
<ds-row fill><ds-text literal>Heron by the north pond</ds-text><ds-text literal tone="muted">Today</ds-text></ds-row>
<ds-row fill><ds-text literal>Willows coming into leaf</ds-text><ds-text literal tone="muted">Monday</ds-text></ds-row>
<ds-row fill><ds-text literal>Frogspawn in the ditch</ds-text><ds-text literal tone="muted">Sunday</ds-text></ds-row>
</ds-list>
<ds-list slot="aside" aria-label="Properties">
<ds-row fill><ds-text literal tone="muted">Notes</ds-text><ds-text literal>3</ds-text></ds-row>
<ds-row fill><ds-text literal tone="muted">Started</ds-text><ds-text literal>12 April</ds-text></ds-row>
</ds-list>
</ds-app></code> Use it
Section titled “Use it”<code><span class="line"><span style="color:var(--docs-code-ink)"><</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-keyword)"> name</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Notes"</span><span style="color:var(--docs-code-keyword)"> home</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"/"</span><span style="color:var(--docs-code-keyword)"> resize-key</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"notes"</span><span style="color:var(--docs-code-keyword)"> grid-anchor</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"top"</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">nav</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"bar"</span><span style="color:var(--docs-code-keyword)"> aria-label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Breadcrumb"</span><span style="color:var(--docs-code-ink)">>Workspace / Meeting notes</</span><span style="color:var(--docs-code-tag)">nav</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">div</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"actions"</span><span style="color:var(--docs-code-ink)">><</span><span style="color:var(--docs-code-tag)">ds-button</span><span style="color:var(--docs-code-ink)">>Share</</span><span style="color:var(--docs-code-tag)">ds-button</span><span style="color:var(--docs-code-ink)">></</span><span style="color:var(--docs-code-tag)">div</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"nav"</span><span style="color:var(--docs-code-keyword)"> label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Notebooks"</span><span style="color:var(--docs-code-ink)">></</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">article</span><span style="color:var(--docs-code-ink)">>…the work…</</span><span style="color:var(--docs-code-tag)">article</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">section</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"aside"</span><span style="color:var(--docs-code-keyword)"> aria-label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Properties"</span><span style="color:var(--docs-code-ink)">>…</</span><span style="color:var(--docs-code-tag)">section</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"></</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-ink)">></span></span></code>
Start the scale first, in the page’s first module, before anything else draws, so the first paint is already on whole squares. ds-app starts it too, but an app that starts it itself never draws a frame at another scale first:
<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)"> { startAppScale } </span><span style="color:var(--docs-code-keyword)">from</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/4-page/app-scale"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-tag)">startAppScale</span><span style="color:var(--docs-code-ink)">({ anchor: </span><span style="color:var(--docs-code-string)">"top"</span><span style="color:var(--docs-code-ink)"> });</span></span></code>From the package
Section titled “From the package”The package exports its source, ds1/*, as written: modules are imported without their .ts ending, so a Vite app resolves the folder itself and TypeScript finds it the same way, and the package stays out of Vite’s prebundling so the frame’s styles load as the components ask for them:
<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)"> { fileURLToPath } </span><span style="color:var(--docs-code-keyword)">from</span><span style="color:var(--docs-code-string)"> "node:url"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-keyword)">export</span><span style="color:var(--docs-code-keyword)"> default</span><span style="color:var(--docs-code-ink)"> {</span></span><span class="line"><span style="color:var(--docs-code-ink)"> resolve: { alias: [{ find: </span><span style="color:var(--docs-code-string)">"@0001-labs/design-system-1/DS1"</span><span style="color:var(--docs-code-ink)">, replacement: </span><span style="color:var(--docs-code-tag)">fileURLToPath</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-keyword)">new</span><span style="color:var(--docs-code-tag)"> URL</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-string)">"./node_modules/@0001-labs/design-system-1/DS1"</span><span style="color:var(--docs-code-ink)">, </span><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)">.meta.url)) }] },</span></span><span class="line"><span style="color:var(--docs-code-ink)"> optimizeDeps: { exclude: [</span><span style="color:var(--docs-code-string)">"@0001-labs/design-system-1"</span><span style="color:var(--docs-code-ink)">] },</span></span><span class="line"><span style="color:var(--docs-code-ink)">};</span></span></code><code><span class="line"><span style="color:var(--docs-code-comment)">// tsconfig.json, under compilerOptions</span></span><span class="line"><span style="color:var(--docs-code-string)">"paths"</span><span style="color:var(--docs-code-ink)">: { </span><span style="color:var(--docs-code-keyword)">"@0001-labs/design-system-1/ds1/*"</span><span style="color:var(--docs-code-ink)">: [</span><span style="color:var(--docs-code-string)">"./node_modules/@0001-labs/design-system-1/ds1/*"</span><span style="color:var(--docs-code-ink)">] }</span></span></code>Before it is ready
Section titled “Before it is ready”one.css (through grid.css) draws the frame before its script has run: the window, the bar’s paper and hairline, and what it holds out of sight, so the first paint is already the frame. await app.updateComplete settles once the frame and the page under its bar have both drawn, when everything slotted stands in its place and can be measured.
The frame is a Page in the inspector layout under a bar, so its areas are the page’s five and the bar’s three. An area with nothing in it takes no room: an app without navigation or an inspector gives the work the window.
| Area | Put it there with | Holds |
|---|---|---|
| Brand | slot="brand" | The app’s mark or name, a link home. Without it, name is drawn as a link to home. |
| Bar | slot="bar" | What follows the name: a breadcrumb, tabs or a search. |
| Actions | slot="actions" | Buttons and the account, at the bar’s end; on a phone, in the drawer under the navigation. |
| Navigation | slot="nav" | The app’s places, usually one Sidebar, which takes the pane’s width. |
| Header | slot="header" | The work’s title and its own actions, above it. |
| Work | No slot | The work itself, the document’s main landmark unless it is given a <main>. |
| Inspector | slot="aside" | Properties or settings of what is selected. |
| Footer | slot="footer" | Closing actions, below the work. |
On the scaled desktop
Section titled “On the scaled desktop”The frame stands on Desktop aligned: on a computer the scale moves slightly so the window is a whole number of squares wide, and the first row starts at the top edge. The bar takes two whole squares. Any partial row falls at the bottom. The shared components follow the same scale, so controls, panes and type grow and shrink together. A phone keeps its fourteen squares across. Set grid-anchor="bottom" to put the partial row at the top instead. Set the same anchor in the early startup call when the page starts the scale before the frame connects.
Two scales must not run at once. Remove a page’s own startScaling() when it moves into the frame, and any pin such as --ds-sf: 1 that holds the components at another scale. The root carries data-ds-scaling-managed, so the device module reads the frame’s scale instead of putting its own. fixed-scale leaves the scale to the page altogether, for a frame drawn inside something that sets its own.
Resizable panes
Section titled “Resizable panes”The navigation and the inspector are twelve squares wide by default, and four to twenty-four squares as they are resized, always leaving ten squares for the work. Drag the line beside a pane: the pane follows the pointer and snaps to a whole square on release. Each divider is a slider for the keyboard: the arrow keys move it one square, five with Shift, Home and End to either limit, and Enter or a double press goes back to the default. Escape cancels a drag. ds-page-resize reports the new widths in detail.navWidth and detail.asideWidth.
A width is what stands in the pane: a twelve-square navigation holds a sidebar exactly twelve squares wide. The pane’s own box reaches half the gap further, to the hairline in the middle of the two squares between it and the work, so measured from the outside it is one square wider than its width.
Widths are remembered in this browser under resize-key, or ds-app: and the app’s name when there is none, so every page of an app opens with the panes as they were left. Storage is optional: resizing works without it.
On a phone
Section titled “On a phone”Below thirty squares of width the frame is one document scrolling under the bar. The navigation and the actions fold away, so the bar keeps only the name, what follows it and a menu button in its last square, and nothing in it is ever cut off. The menu button opens them over the screen, the actions under the navigation, the screen overlay with its close button where the menu button stood and the navigation from the square under the bar. Focus stays inside it, and Escape, the close button, a link or the window widening close it. The inspector stands under the work. openDrawer() and closeDrawer() work the drawer from code, and ds-page-drawer reports it opening and closing in detail.open.
Work edge to edge
Section titled “Work edge to edge”With flush, the work leaves out the square of room around it and runs to the hairlines beside it, the bar above and the window’s bottom edge (or to the window’s sides where there is no pane). The navigation and the inspector keep their square of room and their widths, and a header or footer keeps its distance from the work.
Pages that scroll with the window
Section titled “Pages that scroll with the window”With flow, the page is the document: the window scrolls it, and the bar stays at the top with its hairline on the grid. Use it for a site, or for an app whose pages already scroll with the window, where the scroll position, the browser’s scroll restoration and anything that reads window.scrollY must keep working. The panes then take their content’s height instead of the window’s, and scrollToStart() scrolls the window. Before its script runs, a flowing frame draws its page at once under the bar’s room, so the first paint is the content and nothing jumps.
Moving between places
Section titled “Moving between places”An app that changes its work in place, as a router does, calls scrollToStart() when a new place opens: the work goes back to its top, its own pane on a computer and the page on a phone.
Overlays, menus and toasts open in the browser’s top layer, above the frame, as they do on any page.
Between apps
Section titled “Between apps”A family of apps that should lead to one another gives each frame the same apps: a list of { name, href }, as a property or a JSON attribute. Hovering the name, focusing it with the keyboard or tapping it on a phone opens the list under the bar, hanging from its hairline, with the app that is open marked; leaving it or pressing Escape closes it. The name still leads home with a click. The list is the family’s own, kept in one place they all import; the frame holds no names of its own.
<code><span class="line"><span style="color:var(--docs-code-ink)">document.</span><span style="color:var(--docs-code-tag)">querySelector</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-string)">'ds-app'</span><span style="color:var(--docs-code-ink)">).apps </span><span style="color:var(--docs-code-keyword)">=</span><span style="color:var(--docs-code-ink)"> [</span></span><span class="line"><span style="color:var(--docs-code-ink)"> { name: </span><span style="color:var(--docs-code-string)">'Notes'</span><span style="color:var(--docs-code-ink)">, href: </span><span style="color:var(--docs-code-string)">'https://notes.example.com/'</span><span style="color:var(--docs-code-ink)"> },</span></span><span class="line"><span style="color:var(--docs-code-ink)"> { name: </span><span style="color:var(--docs-code-string)">'Photos'</span><span style="color:var(--docs-code-ink)">, href: </span><span style="color:var(--docs-code-string)">'https://photos.example.com/'</span><span style="color:var(--docs-code-ink)"> },</span></span><span class="line"><span style="color:var(--docs-code-ink)">];</span></span></code>Attributes
Section titled “Attributes”| Attribute | Default | What it does |
|---|---|---|
name | — | The app’s name, drawn at the bar’s start when there is no brand. |
home | / | Where the name leads. |
layout | inspector | The page’s layout under the bar; inspector holds navigation, work and inspector, each optional. |
nav-width | 12 | The navigation’s width in whole squares, 4 to 24. |
aside-width | 12 | The inspector’s width in whole squares, 4 to 24. |
resize-key | ds-app: and the name | Where the widths are remembered. |
drawer-label | Menu | The menu button’s and drawer’s name, a translation key. |
grid-anchor | top | The edge where the desktop grid starts. bottom moves the partial row above the frame. |
fixed-scale | false | Leaves the scale to the page: the frame starts no scale of its own. |
flush | false | The work runs to its pane’s edges, for a wall of pictures or a canvas; the navigation and the inspector keep their room. |
flow | false | The page is the document: the window scrolls it under a bar that stays at the top. |
apps | none | The apps the name leads to, { name, href }[]; see Between apps. |
| Part | What it is |
|---|---|
bar | The top bar. |
brand | The name’s link. |
switch | The name and its apps, with apps. |
apps | The list of apps under the name. |
actions | The actions’ place at the bar’s end, on a computer. |
menu | The phone’s menu button at the bar’s end. |
page | The page under the bar, a ds-page. |
The page’s own parts are passed on under the same names: nav, header, main, aside, footer, drawer, resize and resize-aside, so ds-app::part(main) reaches the work’s pane.
page on the element is that ds-page, for its widths and its drawer.
Methods and events
Section titled “Methods and events”| Name | What it does |
|---|---|
openDrawer(), closeDrawer() | Open or close the navigation’s drawer on a phone. |
scrollToStart() | Takes the work back to its top. |
updateComplete | Settles when the frame and its page have drawn. |
ds-page-resize | A divider moved: detail.navWidth, detail.asideWidth. |
ds-page-drawer | The drawer opened or closed: detail.open. |
An area whose content is all hidden takes no room, so an inspector opens and closes by toggling hidden on it. Enter or a double press on a divider goes back to the width the frame was given (nav-width, aside-width), not to a remembered one.
In React
Section titled “In React”React uses the element directly. Import 4-page/ds-app once in the browser entry; ds-sidebar and other components register through their own imports.
<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/4-page/ds-app"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/3-unit/ds-sidebar"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"></span><span class="line"><span style="color:var(--docs-code-ink)"><</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-keyword)"> name=</span><span style="color:var(--docs-code-string)">"Notes"</span><span style="color:var(--docs-code-keyword)"> resize-key=</span><span style="color:var(--docs-code-string)">"notes"</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-keyword)"> slot=</span><span style="color:var(--docs-code-string)">"nav"</span><span style="color:var(--docs-code-keyword)"> label=</span><span style="color:var(--docs-code-string)">"Notebooks"</span><span style="color:var(--docs-code-keyword)"> items=</span><span style="color:var(--docs-code-ink)">{notebooks} /></span></span><span class="line"><span style="color:var(--docs-code-ink)"> <</span><span style="color:var(--docs-code-tag)">Editor</span><span style="color:var(--docs-code-ink)"> /></span></span><span class="line"><span style="color:var(--docs-code-ink)"></</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-ink)">></span></span></code>