@scalewing/react 1.62.1 → 1.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @scalewing/react
2
2
 
3
+ ## 1.64.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0947c59: `DocsLayout`: a docs page's frame on a public site, rendered on the server
8
+ with no script. `navLabel`, `labels.openNav`, `groups` of links (each
9
+ `{ id, label, items }`, its label a muted caption naming its list; an item's
10
+ `current`, `lang` and `hrefLang`), an optional `aside` and the article as
11
+ `children`. Centred at `SiteHeader`'s bar width with its gutters; from `lg`
12
+ the navigation (15rem, sticky below a sticky `SiteHeader`) beside the
13
+ content at the reading width, and from 80rem (an internal width) the
14
+ `aside` (13rem) at the end, not shown below it. Below `lg` the same
15
+ navigation is a native `details` disclosure at the top of the content. The
16
+ current link takes SectionNav `filled`'s quiet fill at label weight; 44 px
17
+ links on a coarse pointer; `LinkText` and a `Highlight` edge in forced
18
+ colours. New classes `sw-docs-layout*`; a blank `navLabel` or
19
+ `labels.openNav`, no groups, an empty group, blank or repeated ids (item ids
20
+ across groups), and blank labels or hrefs throw a `RangeError`. No new
21
+ tokens or dependencies. Request: `docs/requests/futmas-docs-layout.md`.
22
+
23
+ ## 1.63.0
24
+
25
+ ### Minor Changes
26
+
27
+ - 25d86b1: `displayFaceFamilies` (tokens) and `ThemeProvider displayFace` (react): `condensed` sets a page's titles (`hero`, `display`, `headline`, `heading`) in Barlow Condensed, which the app loads, falling back to the platform's narrow sans; `system` (default) keeps the body face. It writes `data-display-face`, which a page without `ThemeProvider` sets itself. Body text, labels and controls keep the system face (FutMas F-024).
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [25d86b1]
32
+ - @scalewing/tokens@1.9.0
33
+
3
34
  ## 1.62.1
4
35
 
5
36
  ### Patch Changes
package/README.md CHANGED
@@ -44,6 +44,7 @@ import {
44
44
  PreviewTiles,
45
45
  SiteFooter,
46
46
  SiteHeader,
47
+ DocsLayout,
47
48
  DescriptionList,
48
49
  DescriptionItem,
49
50
  EmptyState,
@@ -101,6 +102,14 @@ The accent does not keep 4.5:1 on the grey in every palette, so keep links and a
101
102
  </ThemeProvider>
102
103
  ```
103
104
 
105
+ `displayFace="condensed"` (opt-in; `displayFaces`, default `"system"`) sets a page's titles, the `hero`, `display`, `headline` and `heading` text, in the tokens' condensed face (`displayFaceFamilies.condensed`: Barlow Condensed, falling back to the platform's narrow sans) with no negative tracking, for a page that should read like a fixture board or a poster. Body text, labels and controls keep the system face. Scalewing ships no font files: load Barlow Condensed yourself, self-hosted (for example from `@fontsource/barlow-condensed`). It writes `data-display-face="condensed"` on the themed node; a page rendered without `ThemeProvider` sets that attribute on its `data-theme` node itself. Every title under it changes, so `Hero`, a section's `headline` and a `Card` or dialog title in those variants take the face too; a nested `ThemeProvider` cannot turn it back to `system` (that value writes no attribute), so set it once at the page's root. An unknown face throws a `RangeError`.
106
+
107
+ ```tsx
108
+ <ThemeProvider displayFace="condensed" frame="site" colorScheme="system">
109
+ …
110
+ </ThemeProvider>
111
+ ```
112
+
104
113
  ```html
105
114
  <div class="sw-padding-top-4 sw-padding-x-4"></div>
106
115
  ```
@@ -1217,6 +1226,45 @@ When the real screenshot exists, a `PreviewImage` (`src`, `width`, `height`) hol
1217
1226
  />
1218
1227
  ```
1219
1228
 
1229
+ `DocsLayout` is a docs page's frame on a public site: grouped links to the docs' pages at the start, the article in the middle at the reading width, and an optional `aside` at the end, such as an "On this page" `SectionNav`. It renders on the server with no script and needs no hydration. Supply `navLabel` (the navigation landmark's name, such as "Docs"), `labels.openNav` (the disclosure's words below `lg`, such as "Browse the docs"), `groups` and the article as `children`. Each group is `{ id, label, items }`: its label a small muted caption that names the list of links under it. Each item is `{ id, label, href, current?, lang?, hrefLang? }`; `current` is SectionNav's (`page`, `location` or `true` sets `aria-current`) and the current link takes SectionNav `filled`'s quiet fill at label weight, the others in the text colour with no hairline or underline; `lang` and `hrefLang` pass through to the link.
1230
+
1231
+ The frame is centred at `SiteHeader`'s bar width with its gutters, so the navigation lines up with the brand. From `lg` (64rem) it is two columns: the navigation (15rem) and the content. From 80rem (an internal width of the component, not a public breakpoint) a given `aside` is a third column (13rem) at the end; below that width the aside is not shown at all (`display: none`), so keep the same links in the article. The navigation and the aside stick below the window's top, below a sticky `SiteHeader`'s bar when one is on the page, and scroll on their own only when taller than the window. Below `lg` there is no side column: the navigation is a native `details` disclosure at the top of the content, its `summary` a full-width row with `labels.openNav` and a chevron, at least the md control tall (44 px), which opens the same groups as large rows. It opens and closes by touch, click and keyboard with no script. The navigation is drawn twice (the side list and the disclosure's) and CSS displays only one, so only one `nav` named `navLabel` is in the accessibility tree at a time. Links get the 44 px target on a coarse pointer; in forced colours they are `LinkText` and the current one has a `Highlight` edge.
1232
+
1233
+ `DocsLayout` is a plain `div`, not a landmark: put it inside the page's one `main` (give that `main` the skip link's `id`), with the article as its children. No groups, a group with no items, blank or repeated group ids, blank group labels, items with blank ids, labels or hrefs, item ids repeated anywhere in the navigation, or a blank `navLabel` or `labels.openNav` throw a `RangeError`.
1234
+
1235
+ ```tsx
1236
+ <main id="main" tabIndex={-1}>
1237
+ <DocsLayout
1238
+ navLabel="Guide"
1239
+ labels={{ openNav: 'Browse the guide' }}
1240
+ groups={[
1241
+ {
1242
+ id: 'start',
1243
+ label: 'Start here',
1244
+ items: [
1245
+ { id: 'home', label: 'Field guide home', href: '/guide/' },
1246
+ {
1247
+ id: 'first',
1248
+ label: 'Your first count',
1249
+ href: '/guide/first',
1250
+ current: 'page',
1251
+ },
1252
+ ],
1253
+ },
1254
+ ]}
1255
+ aside={
1256
+ <SectionNav
1257
+ aria-label="On this page"
1258
+ items={[{ id: 'before', label: 'Before you go', href: '#before' }]}
1259
+ verticalFrom="md"
1260
+ />
1261
+ }
1262
+ >
1263
+ <article>…</article>
1264
+ </DocsLayout>
1265
+ </main>
1266
+ ```
1267
+
1220
1268
  `DescriptionList` pairs terms with what each says, one `DescriptionItem` per row: a `dl` whose items each group a `dt` (`term`) with its `dd` (`children`). From `md` up the term sits in a start column as wide as the widest term, up to 40% of the list, and the detail beside it; every row aligns to its top, so a term and its detail's first line start level, and a hairline divides the rows, with no space above the first row or below the last. Below `md` each term sits over its detail. The list sets only the layout: pass your own `Text` for the term and the detail. Each child of a term or a detail is its own line with its own line height (a column), as wide as its content unless it sets its own width (a `Progress` fills the detail; a `Field` keeps its input's width): wrap inline content, such as words and a link on one line, in one element such as an `Inline`. Long unbreakable words wrap inside their column. A `dl` has no ARIA role, so name a list with a visible heading, and `aria-labelledby` on the `section` around it, rather than an `aria-label` on the list.
1221
1269
 
1222
1270
  `layout="spread"` (opt-in; the default is `columns`) sets each row on its own two columns at every width, for a short box of facts such as a side panel's details: the term at the row's start, as wide as its words up to half the row, and the detail at the row's end, its lines end-aligned. The hairlines, padding and top alignment are the same, and a phone keeps each term beside its detail. An unknown `layout` throws a `RangeError`; `descriptionListLayouts` lists the layouts.
@@ -0,0 +1,14 @@
1
+ import { type DocsLayoutProps } from './docs-layout/types.js';
2
+ export type { DocsLayoutGroup, DocsLayoutItem, DocsLayoutLabels, DocsLayoutProps, } from './docs-layout/types.js';
3
+ /**
4
+ * A docs page's frame, centred on the site header's bar: from `lg` a side
5
+ * navigation of grouped links at the start (sticky below a sticky
6
+ * SiteHeader) beside the content column at the reading width, and on a
7
+ * wide window an optional `aside` column at the end, such as "On this
8
+ * page". Below `lg` the same navigation is a native `details` disclosure at
9
+ * the top of the content, so it opens with no script. The navigation is
10
+ * drawn twice and only one copy is ever displayed. It is a plain wrapper:
11
+ * put it inside the page's one `main`. Invalid groups, items or words throw
12
+ * a `RangeError`.
13
+ */
14
+ export declare function DocsLayout({ aside, children, groups, labels, navLabel, }: DocsLayoutProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../class-names.js';
3
+ import { DocsLayoutNav } from './docs-layout/DocsLayoutNav.js';
4
+ import { assertDocsLayoutProps } from './docs-layout/validate.js';
5
+ /**
6
+ * A docs page's frame, centred on the site header's bar: from `lg` a side
7
+ * navigation of grouped links at the start (sticky below a sticky
8
+ * SiteHeader) beside the content column at the reading width, and on a
9
+ * wide window an optional `aside` column at the end, such as "On this
10
+ * page". Below `lg` the same navigation is a native `details` disclosure at
11
+ * the top of the content, so it opens with no script. The navigation is
12
+ * drawn twice and only one copy is ever displayed. It is a plain wrapper:
13
+ * put it inside the page's one `main`. Invalid groups, items or words throw
14
+ * a `RangeError`.
15
+ */
16
+ export function DocsLayout({ aside, children, groups, labels, navLabel, }) {
17
+ assertDocsLayoutProps({ groups, labels, navLabel });
18
+ const hasAside = aside !== undefined && aside !== null && aside !== false;
19
+ return (_jsxs("div", { className: cx('sw-docs-layout', hasAside && 'sw-docs-layout-with-aside'), children: [_jsx("div", { className: "sw-docs-layout-side", children: _jsx(DocsLayoutNav, { className: "sw-docs-layout-nav", groups: groups, navLabel: navLabel }) }), _jsxs("div", { className: "sw-docs-layout-content", children: [_jsxs("details", { className: "sw-docs-layout-disclosure", children: [_jsxs("summary", { className: "sw-docs-layout-summary", children: [_jsx("span", { className: "sw-docs-layout-summary-label", children: labels.openNav }), _jsx("span", { "aria-hidden": "true", className: "sw-docs-layout-marker" })] }), _jsx(DocsLayoutNav, { className: "sw-docs-layout-nav sw-docs-layout-nav-compact", groups: groups, navLabel: navLabel })] }), _jsx("div", { className: "sw-docs-layout-body", children: children })] }), hasAside ? _jsx("div", { className: "sw-docs-layout-aside", children: aside }) : null] }));
20
+ }
@@ -0,0 +1,11 @@
1
+ import { type DocsLayoutGroup } from './types.js';
2
+ /**
3
+ * The docs navigation as a labelled `nav`: each group a muted caption
4
+ * naming the list of links under it. DocsLayout draws it twice, in the
5
+ * side column and in the disclosure, and CSS shows one at a time.
6
+ */
7
+ export declare function DocsLayoutNav({ className, groups, navLabel, }: {
8
+ className: string;
9
+ groups: readonly DocsLayoutGroup[];
10
+ navLabel: string;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import { tabStop } from '../../tab-stop.js';
4
+ import { navItemAriaCurrent } from '../nav-items.js';
5
+ /**
6
+ * The docs navigation as a labelled `nav`: each group a muted caption
7
+ * naming the list of links under it. DocsLayout draws it twice, in the
8
+ * side column and in the disclosure, and CSS shows one at a time.
9
+ */
10
+ export function DocsLayoutNav({ className, groups, navLabel, }) {
11
+ const idPrefix = useId();
12
+ return (_jsx("nav", { "aria-label": navLabel, className: className, children: groups.map((group) => {
13
+ const labelId = `${idPrefix}-${group.id}`;
14
+ return (_jsxs("div", { className: "sw-docs-layout-group", children: [_jsx("p", { className: "sw-docs-layout-group-label", id: labelId, children: group.label }), _jsx("ul", { "aria-labelledby": labelId, className: "sw-docs-layout-list", children: group.items.map((item) => (_jsx("li", { children: _jsx("a", { "aria-current": navItemAriaCurrent(item.current), className: "sw-docs-layout-link", href: item.href, hrefLang: item.hrefLang, lang: item.lang, tabIndex: tabStop, children: item.label }) }, item.id))) })] }, group.id));
15
+ }) }));
16
+ }
@@ -0,0 +1,43 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type NavItemCurrent } from '../nav-items.js';
3
+ /** One page in the docs navigation. */
4
+ export type DocsLayoutItem = {
5
+ id: string;
6
+ label: string;
7
+ href: string;
8
+ /**
9
+ * `page` (or `true`) for the page shown, `location` for a page inside the
10
+ * item's part of the docs: `aria-current`, as SectionNav marks it.
11
+ */
12
+ current?: NavItemCurrent;
13
+ /** The language of the link's words, when they differ from the page's. */
14
+ lang?: string;
15
+ /** The language of the page it opens. */
16
+ hrefLang?: string;
17
+ };
18
+ /** A group of pages under a small muted caption, such as "Start here". */
19
+ export type DocsLayoutGroup = {
20
+ id: string;
21
+ label: string;
22
+ items: readonly DocsLayoutItem[];
23
+ };
24
+ /** The layout's words, in the consumer's language. */
25
+ export type DocsLayoutLabels = {
26
+ /** The disclosure's words below `lg`, such as "Browse the docs". */
27
+ openNav: string;
28
+ };
29
+ export type DocsLayoutProps = {
30
+ /** The docs navigation's name, such as "Docs". */
31
+ navLabel: string;
32
+ /** One or more groups of pages; item ids are unique across groups. */
33
+ groups: readonly DocsLayoutGroup[];
34
+ labels: DocsLayoutLabels;
35
+ /**
36
+ * The column at the end on a wide window, such as an "On this page"
37
+ * SectionNav. Not shown below that width, so keep the same links in the
38
+ * article.
39
+ */
40
+ aside?: ReactNode;
41
+ /** The article, in the content column at the reading width. */
42
+ children: ReactNode;
43
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type DocsLayoutProps } from './types.js';
2
+ /**
3
+ * Fails closed on the layout's words and navigation: a blank navigation
4
+ * name or disclosure label, no groups, a group with no items, blank or
5
+ * repeated group ids, blank group labels, and items with blank ids, labels
6
+ * or hrefs or ids repeated anywhere in the navigation.
7
+ */
8
+ export declare function assertDocsLayoutProps({ groups, labels, navLabel, }: Pick<DocsLayoutProps, 'groups' | 'labels' | 'navLabel'>): void;
@@ -0,0 +1,27 @@
1
+ import { assertNavItems } from '../nav-items.js';
2
+ const blank = (value) => !value.trim();
3
+ /**
4
+ * Fails closed on the layout's words and navigation: a blank navigation
5
+ * name or disclosure label, no groups, a group with no items, blank or
6
+ * repeated group ids, blank group labels, and items with blank ids, labels
7
+ * or hrefs or ids repeated anywhere in the navigation.
8
+ */
9
+ export function assertDocsLayoutProps({ groups, labels, navLabel, }) {
10
+ if (blank(navLabel))
11
+ throw new RangeError('DocsLayout needs a nonempty navLabel');
12
+ if (blank(labels.openNav))
13
+ throw new RangeError('DocsLayout labels need a nonempty openNav');
14
+ if (groups.length === 0)
15
+ throw new RangeError('DocsLayout needs at least one group');
16
+ if (groups.some((group) => blank(group.id) || blank(group.label)))
17
+ throw new RangeError('DocsLayout groups need nonempty ids and labels');
18
+ if (new Set(groups.map((group) => group.id)).size !== groups.length)
19
+ throw new RangeError('DocsLayout groups need unique ids');
20
+ const empty = groups.find((group) => group.items.length === 0);
21
+ if (empty)
22
+ throw new RangeError(`DocsLayout group ${empty.id} needs an item`);
23
+ const items = groups.flatMap((group) => group.items);
24
+ assertNavItems('DocsLayout', items);
25
+ if (items.some((item) => blank(item.href)))
26
+ throw new RangeError('DocsLayout items need nonempty hrefs');
27
+ }
@@ -60,6 +60,7 @@ import { cssHeroClasses } from './css-hero.js';
60
60
  import { cssPageHeaderClasses } from './css-page-header.js';
61
61
  import { cssSiteFooterClasses } from './css-site-footer.js';
62
62
  import { cssSiteHeaderClasses } from './css-site-header.js';
63
+ import { cssDocsLayoutClasses } from './css-docs-layout.js';
63
64
  import { cssStatTileClasses } from './css-stat-tile.js';
64
65
  import { cssDescriptionListClasses } from './css-description-list.js';
65
66
  import { cssTabsClasses } from './css-tabs.js';
@@ -223,6 +224,8 @@ ${cssSiteFooterClasses()}
223
224
 
224
225
  ${cssSiteHeaderClasses()}
225
226
 
227
+ ${cssDocsLayoutClasses()}
228
+
226
229
  ${cssAppShellClasses()}
227
230
 
228
231
  ${cssDialogClasses()}
@@ -0,0 +1,12 @@
1
+ import { type DisplayFace } from '@scalewing/tokens';
2
+ /**
3
+ * The face a page's titles take: `system` (default) keeps the body face;
4
+ * `condensed` sets `hero`, `display`, `headline` and `heading` text in the
5
+ * tokens' condensed face, which the consumer loads.
6
+ */
7
+ export declare const displayFaces: DisplayFace[];
8
+ export type { DisplayFace };
9
+ export declare function assertDisplayFace(face: unknown): asserts face is DisplayFace;
10
+ /** The Text variants a display face reaches: a page's titles, never its body. */
11
+ export declare const displayFaceVariants: readonly ["hero", "display", "headline", "heading"];
12
+ export declare function cssDisplayFaceRules(): string;
@@ -0,0 +1,34 @@
1
+ import { displayFaceFamilies } from '@scalewing/tokens';
2
+ /**
3
+ * The face a page's titles take: `system` (default) keeps the body face;
4
+ * `condensed` sets `hero`, `display`, `headline` and `heading` text in the
5
+ * tokens' condensed face, which the consumer loads.
6
+ */
7
+ export const displayFaces = Object.keys(displayFaceFamilies);
8
+ export function assertDisplayFace(face) {
9
+ if (!displayFaces.includes(face))
10
+ throw new RangeError(`Unknown display face: ${String(face)}`);
11
+ }
12
+ /** The Text variants a display face reaches: a page's titles, never its body. */
13
+ export const displayFaceVariants = [
14
+ 'hero',
15
+ 'display',
16
+ 'headline',
17
+ 'heading',
18
+ ];
19
+ /*
20
+ * `data-display-face` on the themed node (or any node above the titles)
21
+ * switches the titles' family. A condensed face is already narrow, so it
22
+ * drops the system face's negative tracking. Two classes outrank a variant's
23
+ * one, so the compact sizes below `md` keep their size and lose only the
24
+ * tracking.
25
+ */
26
+ export function cssDisplayFaceRules() {
27
+ const titles = displayFaceVariants
28
+ .map((variant) => `.sw-text-${variant}`)
29
+ .join(', ');
30
+ return `[data-display-face='condensed'] :is(${titles}) {
31
+ font-family: ${displayFaceFamilies.condensed};
32
+ letter-spacing: 0;
33
+ }`;
34
+ }
@@ -0,0 +1 @@
1
+ export declare function cssDocsLayoutNavRules(): string;
@@ -0,0 +1,109 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { coarsePointerQuery, touchTarget } from './touch-target.js';
3
+ const body = typographyVariants.body;
4
+ const caption = typographyVariants.caption;
5
+ const label = typographyVariants.label;
6
+ /*
7
+ * The docs navigation, in the side column and the disclosure alike: each
8
+ * group a muted caption at weight 600 (sentence case, never uppercase) over
9
+ * its list of links. Links are in the text colour with no hairline and no
10
+ * underline; the current one takes SectionNav \`filled\`'s quiet muted fill
11
+ * at the label weight, a hovered one a lighter fill. A 2 px transparent
12
+ * border keeps room for forced colours, where links read as LinkText and
13
+ * the current one's border turns Highlight. The link rules start at the
14
+ * canvas (\`[data-theme]\`) to outrank its accent links.
15
+ *
16
+ * In the side column links are label size and the sm control (32; the
17
+ * 44 px target on a coarse pointer). In the disclosure they are large
18
+ * rows: body size, at least the 44 px target at every pointer.
19
+ */
20
+ export function cssDocsLayoutNavRules() {
21
+ return `.sw-docs-layout-nav {
22
+ display: flex;
23
+ flex-direction: column;
24
+ font-family: var(--sw-font-sans);
25
+ gap: var(--sw-space-5);
26
+ }
27
+
28
+ .sw-docs-layout-group {
29
+ display: flex;
30
+ flex-direction: column;
31
+ gap: var(--sw-space-1);
32
+ }
33
+
34
+ .sw-docs-layout-group-label {
35
+ color: var(--sw-color-muted);
36
+ font-size: ${caption.fontSize}px;
37
+ font-weight: 600;
38
+ letter-spacing: ${caption.letterSpacing}px;
39
+ line-height: ${caption.lineHeight}px;
40
+ margin: 0;
41
+ padding-inline: calc(var(--sw-space-2) + 2px);
42
+ }
43
+
44
+ .sw-docs-layout-list {
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: var(--sw-space-1);
48
+ list-style: none;
49
+ margin: 0;
50
+ padding: 0;
51
+ }
52
+
53
+ [data-theme] .sw-docs-layout-link {
54
+ align-items: center;
55
+ border: 2px solid transparent;
56
+ border-radius: var(--sw-radius-sm);
57
+ box-sizing: border-box;
58
+ color: var(--sw-color-text);
59
+ display: flex;
60
+ font-size: ${label.fontSize}px;
61
+ font-weight: 400;
62
+ letter-spacing: ${label.letterSpacing}px;
63
+ line-height: ${label.lineHeight}px;
64
+ min-height: var(--sw-control-sm-min-height);
65
+ overflow-wrap: anywhere;
66
+ padding: var(--sw-space-1) var(--sw-space-2);
67
+ text-decoration: none;
68
+ }
69
+
70
+ [data-theme] .sw-docs-layout-link:hover {
71
+ background: color-mix(in srgb, var(--sw-color-muted) 12%, transparent);
72
+ color: var(--sw-color-text);
73
+ }
74
+
75
+ [data-theme] .sw-docs-layout-link[aria-current] {
76
+ background: color-mix(in srgb, var(--sw-color-muted) 18%, transparent);
77
+ font-weight: ${label.fontWeight};
78
+ }
79
+
80
+ [data-theme] .sw-docs-layout-link:focus-visible {
81
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
82
+ outline-offset: calc(-1 * var(--sw-focus-ring-width));
83
+ }
84
+
85
+ .sw-docs-layout-nav-compact {
86
+ padding-top: var(--sw-space-4);
87
+ }
88
+
89
+ [data-theme] .sw-docs-layout-nav-compact .sw-docs-layout-link {
90
+ font-size: ${body.fontSize}px;
91
+ letter-spacing: ${body.letterSpacing}px;
92
+ line-height: ${body.lineHeight}px;
93
+ min-height: ${touchTarget};
94
+ padding-inline: var(--sw-space-3);
95
+ }
96
+
97
+ .sw-docs-layout-nav-compact .sw-docs-layout-group-label {
98
+ padding-inline: calc(var(--sw-space-3) + 2px);
99
+ }
100
+
101
+ @media ${coarsePointerQuery} {
102
+ [data-theme] .sw-docs-layout-link { min-height: ${touchTarget}; }
103
+ }
104
+
105
+ @media (forced-colors: active) {
106
+ [data-theme] .sw-docs-layout-link { color: LinkText; }
107
+ [data-theme] .sw-docs-layout-link[aria-current] { border-color: Highlight; }
108
+ }`;
109
+ }
@@ -0,0 +1,2 @@
1
+ export declare function cssDocsLayoutClasses(): string;
2
+ export declare function docsLayoutClassCatalog(): string[];
@@ -0,0 +1,193 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { breakpointQuery } from './breakpoints.js';
3
+ import { chevronStroke } from './chevron.js';
4
+ import { cssDocsLayoutNavRules } from './css-docs-layout-nav.js';
5
+ import { quietFill } from './quiet-fill.js';
6
+ import { siteHeaderBarMaxWidth, siteHeaderGutter, siteHeaderGutterQuery, siteHeaderWideHeight, } from './site-header-geometry.js';
7
+ const label = typographyVariants.label;
8
+ /** From `lg` the navigation is a side column. */
9
+ const fromLg = breakpointQuery('from', 'lg');
10
+ /*
11
+ * The width from which the `aside` column shows: an internal media query
12
+ * of the component (as AppShell's 75rem), not a public breakpoint.
13
+ */
14
+ const docsLayoutWideQuery = '(min-width: 80rem)';
15
+ /* The side column's and the aside column's widths, geometry of this frame. */
16
+ const sideWidth = '15rem';
17
+ const asideWidth = '13rem';
18
+ /*
19
+ * The frame: centred at the site header bar's width with its gutters, so
20
+ * the navigation's start lines up with the brand. Below \`lg\` one column;
21
+ * from \`lg\` the side navigation and the content (its article at most the
22
+ * reading width); from 80rem, when an aside is given, a third column at
23
+ * the end. The side and aside columns stick below the window's top, below a
24
+ * sticky SiteHeader's wide bar and hairline when one is on the page
25
+ * (\`html:has(.sw-site-header-sticky)\`, as its scroll padding does), and
26
+ * scroll themselves only when taller than the window.
27
+ */
28
+ function frameRules() {
29
+ return `.sw-docs-layout {
30
+ --sw-docs-layout-top: var(--sw-space-5);
31
+ box-sizing: border-box;
32
+ margin-inline: auto;
33
+ max-width: ${siteHeaderBarMaxWidth};
34
+ padding-block: var(--sw-space-5);
35
+ padding-inline: ${siteHeaderGutter.compact};
36
+ width: 100%;
37
+ }
38
+
39
+ html:has(.sw-site-header-sticky) .sw-docs-layout {
40
+ --sw-docs-layout-top: calc(${siteHeaderWideHeight} + 1px + var(--sw-space-5));
41
+ }
42
+
43
+ .sw-docs-layout-content {
44
+ min-width: 0;
45
+ }
46
+
47
+ .sw-docs-layout-body {
48
+ max-width: var(--sw-reading-max);
49
+ }
50
+
51
+ .sw-docs-layout-side,
52
+ .sw-docs-layout-aside {
53
+ display: none;
54
+ }
55
+
56
+ @media ${siteHeaderGutterQuery} {
57
+ .sw-docs-layout { padding-inline: ${siteHeaderGutter.wide}; }
58
+ }
59
+
60
+ @media ${fromLg} {
61
+ .sw-docs-layout {
62
+ align-items: start;
63
+ column-gap: var(--sw-space-8);
64
+ display: grid;
65
+ grid-template-columns: ${sideWidth} minmax(0, 1fr);
66
+ padding-block: var(--sw-space-6);
67
+ }
68
+
69
+ .sw-docs-layout-side {
70
+ display: block;
71
+ }
72
+
73
+ .sw-docs-layout-side,
74
+ .sw-docs-layout-aside {
75
+ box-sizing: border-box;
76
+ max-height: calc(100dvh - var(--sw-docs-layout-top) - var(--sw-space-5));
77
+ overflow-y: auto;
78
+ overscroll-behavior: contain;
79
+ position: sticky;
80
+ top: var(--sw-docs-layout-top);
81
+ }
82
+
83
+ .sw-docs-layout-disclosure {
84
+ display: none;
85
+ }
86
+ }
87
+
88
+ @media ${docsLayoutWideQuery} {
89
+ .sw-docs-layout-with-aside {
90
+ column-gap: var(--sw-space-6);
91
+ grid-template-columns: ${sideWidth} minmax(0, 1fr) ${asideWidth};
92
+ }
93
+
94
+ .sw-docs-layout-aside {
95
+ display: block;
96
+ }
97
+ }`;
98
+ }
99
+ /*
100
+ * Below \`lg\` the navigation is a native \`details\` at the top of the
101
+ * content: its \`summary\` a full-width row on the surface with a hairline,
102
+ * the consumer's words at the start and a chevron at the end (down while
103
+ * closed, up while open), at least the md control tall. Opening it shows
104
+ * the navigation's large rows under it in the page flow.
105
+ */
106
+ function disclosureRules() {
107
+ return `.sw-docs-layout-disclosure {
108
+ margin-bottom: var(--sw-space-5);
109
+ }
110
+
111
+ .sw-docs-layout-summary {
112
+ align-items: center;
113
+ background: var(--sw-color-surface);
114
+ border: 1px solid var(--sw-color-border);
115
+ border-radius: var(--sw-radius-md);
116
+ box-sizing: border-box;
117
+ color: var(--sw-color-text);
118
+ cursor: pointer;
119
+ display: flex;
120
+ font-family: var(--sw-font-sans);
121
+ font-size: ${label.fontSize}px;
122
+ font-weight: ${label.fontWeight};
123
+ gap: var(--sw-space-3);
124
+ justify-content: space-between;
125
+ letter-spacing: ${label.letterSpacing}px;
126
+ line-height: ${label.lineHeight}px;
127
+ list-style: none;
128
+ min-height: var(--sw-control-md-min-height);
129
+ padding: var(--sw-space-2) var(--sw-space-4);
130
+ }
131
+
132
+ .sw-docs-layout-summary::-webkit-details-marker {
133
+ display: none;
134
+ }
135
+
136
+ .sw-docs-layout-summary:hover {
137
+ background: ${quietFill};
138
+ }
139
+
140
+ .sw-docs-layout-summary:focus-visible {
141
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
142
+ outline-offset: var(--sw-focus-ring-offset);
143
+ }
144
+
145
+ .sw-docs-layout-marker {
146
+ ${chevronStroke}
147
+ flex: none;
148
+ margin-block-end: var(--sw-space-1);
149
+ transform: rotate(45deg);
150
+ transition: transform var(--sw-motion-default) var(--sw-motion-easing);
151
+ }
152
+
153
+ .sw-docs-layout-disclosure[open] .sw-docs-layout-marker {
154
+ margin-block: var(--sw-space-1) 0;
155
+ transform: rotate(-135deg);
156
+ }
157
+
158
+ @media (prefers-reduced-motion: reduce) {
159
+ .sw-docs-layout-marker { transition: none; }
160
+ }
161
+
162
+ @media (forced-colors: active) {
163
+ .sw-docs-layout-summary { border-color: ButtonText; }
164
+ .sw-docs-layout-marker { border-color: CanvasText; }
165
+ }`;
166
+ }
167
+ export function cssDocsLayoutClasses() {
168
+ return `${frameRules()}
169
+
170
+ ${disclosureRules()}
171
+
172
+ ${cssDocsLayoutNavRules()}`;
173
+ }
174
+ export function docsLayoutClassCatalog() {
175
+ return [
176
+ 'sw-docs-layout',
177
+ 'sw-docs-layout-with-aside',
178
+ 'sw-docs-layout-side',
179
+ 'sw-docs-layout-content',
180
+ 'sw-docs-layout-body',
181
+ 'sw-docs-layout-aside',
182
+ 'sw-docs-layout-disclosure',
183
+ 'sw-docs-layout-summary',
184
+ 'sw-docs-layout-summary-label',
185
+ 'sw-docs-layout-marker',
186
+ 'sw-docs-layout-nav',
187
+ 'sw-docs-layout-nav-compact',
188
+ 'sw-docs-layout-group',
189
+ 'sw-docs-layout-group-label',
190
+ 'sw-docs-layout-list',
191
+ 'sw-docs-layout-link',
192
+ ];
193
+ }
@@ -1,6 +1,7 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
2
  import { cssBoxLinkClasses } from './css-box-link.js';
3
3
  import { cssCanvasGroupedRules } from './css-canvas-grouped.js';
4
+ import { cssDisplayFaceRules } from './css-display-face.js';
4
5
  import { cssThemeFrameRules } from './css-theme-frame.js';
5
6
  const body = typographyVariants.body;
6
7
  /** The native controls that take typed text: the canvas's text controls. */
@@ -90,6 +91,8 @@ ${cssCanvasGroupedRules()}
90
91
 
91
92
  ${cssThemeFrameRules()}
92
93
 
94
+ ${cssDisplayFaceRules()}
95
+
93
96
  [data-theme] a {
94
97
  color: var(--sw-color-accent);
95
98
  text-decoration: none;
@@ -35,6 +35,7 @@ import { heroClassCatalog } from './css-hero.js';
35
35
  import { pageHeaderClassCatalog } from './css-page-header.js';
36
36
  import { siteFooterClassCatalog } from './css-site-footer.js';
37
37
  import { siteHeaderClassCatalog } from './css-site-header.js';
38
+ import { docsLayoutClassCatalog } from './css-docs-layout.js';
38
39
  import { statTileClassCatalog } from './css-stat-tile.js';
39
40
  import { descriptionListClassCatalog } from './css-description-list.js';
40
41
  import { tabsClassCatalog } from './css-tabs.js';
@@ -158,6 +159,7 @@ export function utilityClassCatalog() {
158
159
  ...pageHeaderClassCatalog(),
159
160
  ...siteFooterClassCatalog(),
160
161
  ...siteHeaderClassCatalog(),
162
+ ...docsLayoutClassCatalog(),
161
163
  ...statTileClassCatalog(),
162
164
  ...descriptionListClassCatalog(),
163
165
  ...tabsClassCatalog(),
package/dist/index.d.ts CHANGED
@@ -80,6 +80,7 @@ export { Text, textFonts, textMaxLines, type TextAlign, type TextElement, type T
80
80
  export { ThemeProvider, useTheme, type ThemeProviderProps, } from './theme/ThemeProvider.js';
81
81
  export { themeCanvases, type ThemeCanvas } from './css/css-canvas-grouped.js';
82
82
  export { themeFrames, type ThemeFrame } from './css/css-theme-frame.js';
83
+ export { displayFaces, type DisplayFace } from './css/css-display-face.js';
83
84
  export { themeDensities, type ThemeDensity } from './css/css-density.js';
84
85
  export { utilityClassCatalog } from './css/stylesheet.js';
85
86
  export type { VisibilityProps } from './visibility-classes.js';
@@ -88,6 +89,8 @@ export { breakpointQuery } from './css/breakpoints.js';
88
89
  export { Band, bandElements, bandTones, bandWidths, } from './components/Band.js';
89
90
  export type { BandElement, BandProps, BandTone, BandWidth, } from './components/Band.js';
90
91
  export { SiteHeader } from './components/SiteHeader.js';
92
+ export { DocsLayout } from './components/DocsLayout.js';
93
+ export type { DocsLayoutGroup, DocsLayoutItem, DocsLayoutLabels, DocsLayoutProps, } from './components/DocsLayout.js';
91
94
  export type { SiteHeaderItem, SiteHeaderLabels, SiteHeaderProps, SiteHeaderSkipLink, } from './components/SiteHeader.js';
92
95
  export { ScreenPreview, screenPreviewFrames, } from './components/ScreenPreview.js';
93
96
  export type { ScreenPreviewFrame, ScreenPreviewProps, } from './components/ScreenPreview.js';
package/dist/index.js CHANGED
@@ -76,11 +76,13 @@ export { Text, textFonts, textMaxLines, } from './components/Text.js';
76
76
  export { ThemeProvider, useTheme, } from './theme/ThemeProvider.js';
77
77
  export { themeCanvases } from './css/css-canvas-grouped.js';
78
78
  export { themeFrames } from './css/css-theme-frame.js';
79
+ export { displayFaces } from './css/css-display-face.js';
79
80
  export { themeDensities } from './css/css-density.js';
80
81
  export { utilityClassCatalog } from './css/stylesheet.js';
81
82
  export { breakpointQuery } from './css/breakpoints.js';
82
83
  export { Band, bandElements, bandTones, bandWidths, } from './components/Band.js';
83
84
  export { SiteHeader } from './components/SiteHeader.js';
85
+ export { DocsLayout } from './components/DocsLayout.js';
84
86
  export { ScreenPreview, screenPreviewFrames, } from './components/ScreenPreview.js';
85
87
  export { PreviewGroup } from './components/screen-preview/PreviewGroup.js';
86
88
  export { PreviewImage } from './components/screen-preview/PreviewImage.js';
package/dist/styles.css CHANGED
@@ -641,6 +641,11 @@ body {
641
641
  margin-top: auto;
642
642
  }
643
643
 
644
+ [data-display-face='condensed'] :is(.sw-text-hero, .sw-text-display, .sw-text-headline, .sw-text-heading) {
645
+ font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
646
+ letter-spacing: 0;
647
+ }
648
+
644
649
  [data-theme] a {
645
650
  color: var(--sw-color-accent);
646
651
  text-decoration: none;
@@ -6039,6 +6044,229 @@ html:has(.sw-site-header-sticky) {
6039
6044
  }
6040
6045
  }
6041
6046
 
6047
+ .sw-docs-layout {
6048
+ --sw-docs-layout-top: var(--sw-space-5);
6049
+ box-sizing: border-box;
6050
+ margin-inline: auto;
6051
+ max-width: calc(var(--sw-container-max) + 2 * var(--sw-space-5));
6052
+ padding-block: var(--sw-space-5);
6053
+ padding-inline: var(--sw-space-4);
6054
+ width: 100%;
6055
+ }
6056
+
6057
+ html:has(.sw-site-header-sticky) .sw-docs-layout {
6058
+ --sw-docs-layout-top: calc(calc(var(--sw-control-md-min-height) + var(--sw-space-5) + var(--sw-space-1)) + 1px + var(--sw-space-5));
6059
+ }
6060
+
6061
+ .sw-docs-layout-content {
6062
+ min-width: 0;
6063
+ }
6064
+
6065
+ .sw-docs-layout-body {
6066
+ max-width: var(--sw-reading-max);
6067
+ }
6068
+
6069
+ .sw-docs-layout-side,
6070
+ .sw-docs-layout-aside {
6071
+ display: none;
6072
+ }
6073
+
6074
+ @media (min-width: 48rem) {
6075
+ .sw-docs-layout { padding-inline: var(--sw-space-5); }
6076
+ }
6077
+
6078
+ @media (min-width: 64rem) {
6079
+ .sw-docs-layout {
6080
+ align-items: start;
6081
+ column-gap: var(--sw-space-8);
6082
+ display: grid;
6083
+ grid-template-columns: 15rem minmax(0, 1fr);
6084
+ padding-block: var(--sw-space-6);
6085
+ }
6086
+
6087
+ .sw-docs-layout-side {
6088
+ display: block;
6089
+ }
6090
+
6091
+ .sw-docs-layout-side,
6092
+ .sw-docs-layout-aside {
6093
+ box-sizing: border-box;
6094
+ max-height: calc(100dvh - var(--sw-docs-layout-top) - var(--sw-space-5));
6095
+ overflow-y: auto;
6096
+ overscroll-behavior: contain;
6097
+ position: sticky;
6098
+ top: var(--sw-docs-layout-top);
6099
+ }
6100
+
6101
+ .sw-docs-layout-disclosure {
6102
+ display: none;
6103
+ }
6104
+ }
6105
+
6106
+ @media (min-width: 80rem) {
6107
+ .sw-docs-layout-with-aside {
6108
+ column-gap: var(--sw-space-6);
6109
+ grid-template-columns: 15rem minmax(0, 1fr) 13rem;
6110
+ }
6111
+
6112
+ .sw-docs-layout-aside {
6113
+ display: block;
6114
+ }
6115
+ }
6116
+
6117
+ .sw-docs-layout-disclosure {
6118
+ margin-bottom: var(--sw-space-5);
6119
+ }
6120
+
6121
+ .sw-docs-layout-summary {
6122
+ align-items: center;
6123
+ background: var(--sw-color-surface);
6124
+ border: 1px solid var(--sw-color-border);
6125
+ border-radius: var(--sw-radius-md);
6126
+ box-sizing: border-box;
6127
+ color: var(--sw-color-text);
6128
+ cursor: pointer;
6129
+ display: flex;
6130
+ font-family: var(--sw-font-sans);
6131
+ font-size: 15px;
6132
+ font-weight: 600;
6133
+ gap: var(--sw-space-3);
6134
+ justify-content: space-between;
6135
+ letter-spacing: -0.2px;
6136
+ line-height: 20px;
6137
+ list-style: none;
6138
+ min-height: var(--sw-control-md-min-height);
6139
+ padding: var(--sw-space-2) var(--sw-space-4);
6140
+ }
6141
+
6142
+ .sw-docs-layout-summary::-webkit-details-marker {
6143
+ display: none;
6144
+ }
6145
+
6146
+ .sw-docs-layout-summary:hover {
6147
+ background: color-mix(in srgb, var(--sw-color-muted) 16%, transparent);
6148
+ }
6149
+
6150
+ .sw-docs-layout-summary:focus-visible {
6151
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
6152
+ outline-offset: var(--sw-focus-ring-offset);
6153
+ }
6154
+
6155
+ .sw-docs-layout-marker {
6156
+ border-bottom: 2px solid var(--sw-color-muted);
6157
+ border-right: 2px solid var(--sw-color-muted);
6158
+ box-sizing: border-box;
6159
+ height: var(--sw-space-2);
6160
+ width: var(--sw-space-2);
6161
+ flex: none;
6162
+ margin-block-end: var(--sw-space-1);
6163
+ transform: rotate(45deg);
6164
+ transition: transform var(--sw-motion-default) var(--sw-motion-easing);
6165
+ }
6166
+
6167
+ .sw-docs-layout-disclosure[open] .sw-docs-layout-marker {
6168
+ margin-block: var(--sw-space-1) 0;
6169
+ transform: rotate(-135deg);
6170
+ }
6171
+
6172
+ @media (prefers-reduced-motion: reduce) {
6173
+ .sw-docs-layout-marker { transition: none; }
6174
+ }
6175
+
6176
+ @media (forced-colors: active) {
6177
+ .sw-docs-layout-summary { border-color: ButtonText; }
6178
+ .sw-docs-layout-marker { border-color: CanvasText; }
6179
+ }
6180
+
6181
+ .sw-docs-layout-nav {
6182
+ display: flex;
6183
+ flex-direction: column;
6184
+ font-family: var(--sw-font-sans);
6185
+ gap: var(--sw-space-5);
6186
+ }
6187
+
6188
+ .sw-docs-layout-group {
6189
+ display: flex;
6190
+ flex-direction: column;
6191
+ gap: var(--sw-space-1);
6192
+ }
6193
+
6194
+ .sw-docs-layout-group-label {
6195
+ color: var(--sw-color-muted);
6196
+ font-size: 13px;
6197
+ font-weight: 600;
6198
+ letter-spacing: -0.08px;
6199
+ line-height: 18px;
6200
+ margin: 0;
6201
+ padding-inline: calc(var(--sw-space-2) + 2px);
6202
+ }
6203
+
6204
+ .sw-docs-layout-list {
6205
+ display: flex;
6206
+ flex-direction: column;
6207
+ gap: var(--sw-space-1);
6208
+ list-style: none;
6209
+ margin: 0;
6210
+ padding: 0;
6211
+ }
6212
+
6213
+ [data-theme] .sw-docs-layout-link {
6214
+ align-items: center;
6215
+ border: 2px solid transparent;
6216
+ border-radius: var(--sw-radius-sm);
6217
+ box-sizing: border-box;
6218
+ color: var(--sw-color-text);
6219
+ display: flex;
6220
+ font-size: 15px;
6221
+ font-weight: 400;
6222
+ letter-spacing: -0.2px;
6223
+ line-height: 20px;
6224
+ min-height: var(--sw-control-sm-min-height);
6225
+ overflow-wrap: anywhere;
6226
+ padding: var(--sw-space-1) var(--sw-space-2);
6227
+ text-decoration: none;
6228
+ }
6229
+
6230
+ [data-theme] .sw-docs-layout-link:hover {
6231
+ background: color-mix(in srgb, var(--sw-color-muted) 12%, transparent);
6232
+ color: var(--sw-color-text);
6233
+ }
6234
+
6235
+ [data-theme] .sw-docs-layout-link[aria-current] {
6236
+ background: color-mix(in srgb, var(--sw-color-muted) 18%, transparent);
6237
+ font-weight: 600;
6238
+ }
6239
+
6240
+ [data-theme] .sw-docs-layout-link:focus-visible {
6241
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
6242
+ outline-offset: calc(-1 * var(--sw-focus-ring-width));
6243
+ }
6244
+
6245
+ .sw-docs-layout-nav-compact {
6246
+ padding-top: var(--sw-space-4);
6247
+ }
6248
+
6249
+ [data-theme] .sw-docs-layout-nav-compact .sw-docs-layout-link {
6250
+ font-size: 17px;
6251
+ letter-spacing: -0.2px;
6252
+ line-height: 25px;
6253
+ min-height: var(--sw-control-md-min-height);
6254
+ padding-inline: var(--sw-space-3);
6255
+ }
6256
+
6257
+ .sw-docs-layout-nav-compact .sw-docs-layout-group-label {
6258
+ padding-inline: calc(var(--sw-space-3) + 2px);
6259
+ }
6260
+
6261
+ @media (pointer: coarse) {
6262
+ [data-theme] .sw-docs-layout-link { min-height: var(--sw-control-md-min-height); }
6263
+ }
6264
+
6265
+ @media (forced-colors: active) {
6266
+ [data-theme] .sw-docs-layout-link { color: LinkText; }
6267
+ [data-theme] .sw-docs-layout-link[aria-current] { border-color: Highlight; }
6268
+ }
6269
+
6042
6270
  .sw-app-shell {
6043
6271
  min-height: 100vh;
6044
6272
  min-height: 100dvh;
@@ -3,6 +3,7 @@ import { type ColorScheme, type PaletteId, type Theme, type ThemeColors } from '
3
3
  import { type ThemeCanvas } from '../css/css-canvas-grouped.js';
4
4
  import { type ThemeDensity } from '../css/css-density.js';
5
5
  import { type ThemeFrame } from '../css/css-theme-frame.js';
6
+ import { type DisplayFace } from '../css/css-display-face.js';
6
7
  export type ThemeProviderProps = {
7
8
  colorScheme?: ColorScheme | 'system';
8
9
  palette?: PaletteId;
@@ -24,6 +25,15 @@ export type ThemeProviderProps = {
24
25
  * a `RangeError`.
25
26
  */
26
27
  frame?: ThemeFrame;
28
+ /**
29
+ * `system` (default) sets titles in the body face; `condensed` (opt-in)
30
+ * sets `hero`, `display`, `headline` and `heading` text in the tokens'
31
+ * condensed face (Barlow Condensed, which the app loads). It writes
32
+ * `data-display-face` on the themed node, which every title inside
33
+ * inherits; a nested provider's `system` cannot undo it, so set it once at
34
+ * the page's root. An unknown value throws a `RangeError`.
35
+ */
36
+ displayFace?: DisplayFace;
27
37
  /**
28
38
  * `comfortable` (default) draws today's touch-sized controls. `compact`
29
39
  * (opt-in) is a desktop data tool's scale, on a fine pointer only (a touch
@@ -37,5 +47,5 @@ export type ThemeProviderProps = {
37
47
  density?: ThemeDensity;
38
48
  children: ReactNode;
39
49
  };
40
- export declare function ThemeProvider({ colorScheme, palette, colors, canvas, frame, density, children, }: ThemeProviderProps): import("react").JSX.Element;
50
+ export declare function ThemeProvider({ colorScheme, palette, colors, canvas, frame, displayFace, density, children, }: ThemeProviderProps): import("react").JSX.Element;
41
51
  export declare function useTheme(): Theme;
@@ -4,6 +4,7 @@ import { createTheme, secondaryActionBorder, semanticColorKeys, } from '@scalewi
4
4
  import { assertThemeCanvas, } from '../css/css-canvas-grouped.js';
5
5
  import { assertThemeDensity } from '../css/css-density.js';
6
6
  import { assertThemeFrame } from '../css/css-theme-frame.js';
7
+ import { assertDisplayFace, } from '../css/css-display-face.js';
7
8
  const ThemeContext = createContext(null);
8
9
  /** The density of the ThemeProvider around this one. */
9
10
  const DensityContext = createContext('comfortable');
@@ -29,9 +30,10 @@ function themeCssVars(theme) {
29
30
  vars['--sw-glass-specular'] = theme.glass.specular;
30
31
  return vars;
31
32
  }
32
- export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas = 'default', frame = 'none', density = 'comfortable', children, }) {
33
+ export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas = 'default', frame = 'none', displayFace = 'system', density = 'comfortable', children, }) {
33
34
  assertThemeCanvas(canvas);
34
35
  assertThemeFrame(frame);
36
+ assertDisplayFace(displayFace);
35
37
  assertThemeDensity(density);
36
38
  const resolvedDensity = useContext(DensityContext) === 'compact' ? 'compact' : density;
37
39
  const [systemScheme, setSystemScheme] = useState(schemeFromMedia);
@@ -49,7 +51,7 @@ export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas
49
51
  }, [colorScheme]);
50
52
  const resolvedScheme = colorScheme === 'system' ? systemScheme : colorScheme;
51
53
  const theme = useMemo(() => createTheme({ colorScheme: resolvedScheme, palette, colors }), [colors, palette, resolvedScheme]);
52
- return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(DensityContext.Provider, { value: resolvedDensity, children: _jsx("div", { "data-canvas": canvas === 'default' ? undefined : canvas, "data-density": resolvedDensity === 'compact' ? 'compact' : undefined, "data-frame": frame === 'none' ? undefined : frame, "data-palette": palette, "data-theme": theme.colorScheme, style: themeCssVars(theme), children: children }) }) }));
54
+ return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(DensityContext.Provider, { value: resolvedDensity, children: _jsx("div", { "data-canvas": canvas === 'default' ? undefined : canvas, "data-density": resolvedDensity === 'compact' ? 'compact' : undefined, "data-display-face": displayFace === 'system' ? undefined : displayFace, "data-frame": frame === 'none' ? undefined : frame, "data-palette": palette, "data-theme": theme.colorScheme, style: themeCssVars(theme), children: children }) }) }));
53
55
  }
54
56
  export function useTheme() {
55
57
  const theme = useContext(ThemeContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalewing/react",
3
- "version": "1.62.1",
3
+ "version": "1.64.0",
4
4
  "description": "Scalewing DOM components and package-owned CSS utilities.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "markdown-it": "14.3.2",
47
47
  "pdfjs-dist": "6.4.299",
48
- "@scalewing/tokens": "^1.8.0"
48
+ "@scalewing/tokens": "^1.9.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^19.0.0",