Add the pane layout component

Plan step 35: <x-pane>, a content region with M3's margins (16px below
medium, 24px from it) drawn once however panes and layouts nest, a width
cap, and an optional pane app bar - <x-app-bar> as a direct child of the
pane with title, subtitle, actions, a back link or action, a leading
slot, and the section navigation under it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-14 14:51:04 +02:00
co-authored by Claude Opus 5
parent e99c5993d8
commit b4f1e005de
7 changed files with 300 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
/*
* <x-pane>: a content region, with M3's margins and, optionally, a top app bar of its own.
*
* M3 puts all content in panes (docs/reference/m3/foundations.md § Layout → Scaffold, "all content
* must live in a pane") and lets each carry its own app bar. The margin is the space between the
* window's edge and what is inside: 16px below medium and 24px from it (600px), from the
* per-breakpoint table in docs/reference/m3/foundations-supplement.md § Breakpoints, as
* `--md-sys-measurement-space200` and `space300`.
*
* The margin sits on the pane's body and its section navigation, not on the pane: the app bar is a
* direct child of the pane, so it spans the pane from edge to edge and its `position: sticky` holds
* for the pane's whole height (a sticky element never leaves its parent). A margin is drawn once:
* a region that already keeps its content off the window's edge — a pane's body, the canonical
* layouts, the scaffold's content region — sets `--md-layout-margin` to 0px for what is inside it,
* and a pane there draws none of its own, until an <x-surface> gives it a new edge to keep off.
*
* `data-md-width` caps the pane and centres it: `narrow` 40rem, M3's 4060 characters a line
* (§ Layout → Breakpoints, "keep text to 4060 characters per line"), in rem because it is a measure
* of text; `medium` 60rem and `wide` 80rem are the package's steps above it; `full` (the default)
* fills the room it has, M3's flexible pane. The back button of `data-md-pane-back` points the
* way it goes, so it mirrors in a right-to-left document (§ Layout → Bidirectionality / RTL).
*
* In `material.layout`; `hide-below`/`hide-from` come from visibility.css.
*/
@layer material.reset, material.tokens, material.base, material.layout, material.components, material.text, material.visibility;
@import './visibility.css';
@layer material.layout {
[data-md-pane] {
display: flex;
flex-direction: column;
inline-size: 100%;
min-inline-size: 0;
margin-inline: auto;
}
[data-md-pane][data-md-width='narrow'] {
max-inline-size: 40rem;
}
[data-md-pane][data-md-width='medium'] {
max-inline-size: 60rem;
}
[data-md-pane][data-md-width='wide'] {
max-inline-size: 80rem;
}
[data-md-pane-navigation],
[data-md-pane-body] {
padding-inline: var(--md-layout-margin, var(--md-sys-measurement-space200));
@media (width >= 600px) {
padding-inline: var(--md-layout-margin, var(--md-sys-measurement-space300));
}
}
[data-md-pane-body] {
flex: 1 1 auto;
min-inline-size: 0;
}
[data-md-pane-body] > * {
--md-layout-margin: 0px;
}
[data-md-pane-back] [data-md-icon]:dir(rtl) {
transform: scaleX(-1);
}
}