@scalewing/react 1.63.0 → 1.65.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 +41 -0
- package/README.md +56 -1
- package/dist/components/DocsLayout.d.ts +14 -0
- package/dist/components/DocsLayout.js +20 -0
- package/dist/components/SiteHeader.d.ts +8 -4
- package/dist/components/SiteHeader.js +10 -5
- package/dist/components/docs-layout/DocsLayoutNav.d.ts +11 -0
- package/dist/components/docs-layout/DocsLayoutNav.js +16 -0
- package/dist/components/docs-layout/types.d.ts +43 -0
- package/dist/components/docs-layout/types.js +1 -0
- package/dist/components/docs-layout/validate.d.ts +8 -0
- package/dist/components/docs-layout/validate.js +27 -0
- package/dist/components/site-header/SiteHeaderSearch.d.ts +16 -0
- package/dist/components/site-header/SiteHeaderSearch.js +19 -0
- package/dist/components/site-header/types.d.ts +24 -0
- package/dist/components/site-header/validate.d.ts +1 -1
- package/dist/components/site-header/validate.js +22 -1
- package/dist/css/css-components.js +3 -0
- package/dist/css/css-docs-layout-nav.d.ts +1 -0
- package/dist/css/css-docs-layout-nav.js +109 -0
- package/dist/css/css-docs-layout.d.ts +2 -0
- package/dist/css/css-docs-layout.js +193 -0
- package/dist/css/css-site-header-search.d.ts +2 -0
- package/dist/css/css-site-header-search.js +336 -0
- package/dist/css/css-site-header.js +6 -1
- package/dist/css/stylesheet.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/styles.css +508 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.65.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3cfbc90: `SiteHeader search`: the site's search in the header, rendered on the server
|
|
8
|
+
with no script. `search` (`SiteHeaderSearchOptions`: `{ action, name?, label,
|
|
9
|
+
placeholder, labels: { open, close }, icon }`) is one GET form drawn once:
|
|
10
|
+
from `lg` an sm search field in the bar after the destinations, pushed to the
|
|
11
|
+
end with the actions; below `lg` a 44 px search button before the compact
|
|
12
|
+
actions that opens the same form over the whole window as a native popover
|
|
13
|
+
(the field at the body size so an iPhone does not zoom in, a close button
|
|
14
|
+
drawn with `closeIcon`, the results under it). Opening, Escape, closing and
|
|
15
|
+
submitting need no script (the consumer's script focuses the field on
|
|
16
|
+
`toggle`), and the form submits to `action` as `name` (default `q`). An
|
|
17
|
+
empty `hidden` results panel with a polite status, a list and a row
|
|
18
|
+
`template` is the consumer's script to fill: from `lg` it drops down under
|
|
19
|
+
the field as a raised panel, below `lg` it fills the window. New classes
|
|
20
|
+
`sw-site-header-search*`; blank words, a `name` that is not a plain
|
|
21
|
+
parameter name, or no `icon` throw a `RangeError`. No new tokens or
|
|
22
|
+
dependencies. Request: `docs/requests/futmas-site-header-search.md`.
|
|
23
|
+
|
|
24
|
+
## 1.64.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 0947c59: `DocsLayout`: a docs page's frame on a public site, rendered on the server
|
|
29
|
+
with no script. `navLabel`, `labels.openNav`, `groups` of links (each
|
|
30
|
+
`{ id, label, items }`, its label a muted caption naming its list; an item's
|
|
31
|
+
`current`, `lang` and `hrefLang`), an optional `aside` and the article as
|
|
32
|
+
`children`. Centred at `SiteHeader`'s bar width with its gutters; from `lg`
|
|
33
|
+
the navigation (15rem, sticky below a sticky `SiteHeader`) beside the
|
|
34
|
+
content at the reading width, and from 80rem (an internal width) the
|
|
35
|
+
`aside` (13rem) at the end, not shown below it. Below `lg` the same
|
|
36
|
+
navigation is a native `details` disclosure at the top of the content. The
|
|
37
|
+
current link takes SectionNav `filled`'s quiet fill at label weight; 44 px
|
|
38
|
+
links on a coarse pointer; `LinkText` and a `Highlight` edge in forced
|
|
39
|
+
colours. New classes `sw-docs-layout*`; a blank `navLabel` or
|
|
40
|
+
`labels.openNav`, no groups, an empty group, blank or repeated ids (item ids
|
|
41
|
+
across groups), and blank labels or hrefs throw a `RangeError`. No new
|
|
42
|
+
tokens or dependencies. Request: `docs/requests/futmas-docs-layout.md`.
|
|
43
|
+
|
|
3
44
|
## 1.63.0
|
|
4
45
|
|
|
5
46
|
### Minor 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,
|
|
@@ -1147,7 +1148,7 @@ const { headings, omissions } = inspectMarkdown(page.body, {
|
|
|
1147
1148
|
</Band>
|
|
1148
1149
|
```
|
|
1149
1150
|
|
|
1150
|
-
`SiteHeader` is a public site's header. Supply `brand` (such as a logo linked to the home page), `navLabel` and `items` (`{ id, label, href, current? }`, `current` as SectionNav's: `page`, `location` or `true` sets `aria-current`), `labels` (`openMenu`, `closeMenu`) and the decorative `menuIcon` and `closeIcon` glyphs. From `lg` the bar shows the brand, the destinations as a row of links (the current one at label weight over a bar in the words' colour, a thick underline in forced colours) and `actions` at its end, such as a language switch, Sign in (`Box as="a" link="quiet"`) and a `ButtonLink`. Below `lg` it shows the brand, `compactActions` and a menu button that opens, under the bar over the rest of the window, the destinations as large rows (the current one in the accent) and `menuActions` at the panel's foot, such as full-width `ButtonLink`s. The menu is a native `details`, so it opens and closes by touch, click and keyboard with no script, as a page rendered on the server needs; its `summary` is the button, named `openMenu` or `closeMenu` by its state. Script adds Escape (focus back on the button), and closes it when a link in it is chosen, focus leaves it, a press lands outside it, or the window widens to `lg`; nothing traps focus. A page rendered on the server has the no-script menu until it hydrates; a site that never hydrates keeps it, which still opens and closes. While the menu is open the bar's `compactActions` step aside (the menu holds its own `menuActions`), so the bar shows only the brand and the close button. The bar is 56 px tall below `lg` and 72 px from it, on the solid surface with a hairline under it; `sticky` (default `true`) keeps it at the window's top. While a sticky header is on the page the document's `scroll-padding-top` clears the bar, its hairline and a small gap, so a `#fragment` link, `:target` and `scrollIntoView` land below the bar instead of under it; a header with `sticky={false}` leaves the scroll padding alone. An optional `skipLink` (`{ label, href }`, such as `{ label: 'Skip to content', href: '#main' }`) is the header's first focusable element: visually hidden until it has focus, then a pill on the surface with the focus ring over the bar's start. Give the target (usually `main`) the matching `id`, and `tabIndex={-1}` so every browser moves focus there with the jump. No items, blank or repeated ids, blank labels or hrefs, a blank `navLabel` or menu label, or a skip link with a blank label or an `href` that is not a `#fragment` throw a `RangeError`.
|
|
1151
|
+
`SiteHeader` is a public site's header. Supply `brand` (such as a logo linked to the home page), `navLabel` and `items` (`{ id, label, href, current? }`, `current` as SectionNav's: `page`, `location` or `true` sets `aria-current`), `labels` (`openMenu`, `closeMenu`) and the decorative `menuIcon` and `closeIcon` glyphs. From `lg` the bar shows the brand, the destinations as a row of links (the current one at label weight over a bar in the words' colour, a thick underline in forced colours) and `actions` at its end, such as a language switch, Sign in (`Box as="a" link="quiet"`) and a `ButtonLink`. Below `lg` it shows the brand, `compactActions` and a menu button that opens, under the bar over the rest of the window, the destinations as large rows (the current one in the accent) and `menuActions` at the panel's foot, such as full-width `ButtonLink`s. The menu is a native `details`, so it opens and closes by touch, click and keyboard with no script, as a page rendered on the server needs; its `summary` is the button, named `openMenu` or `closeMenu` by its state. Script adds Escape (focus back on the button), and closes it when a link in it is chosen, focus leaves it, a press lands outside it, or the window widens to `lg`; nothing traps focus. A page rendered on the server has the no-script menu until it hydrates; a site that never hydrates keeps it, which still opens and closes. While the menu is open the bar's `compactActions` step aside (the menu holds its own `menuActions`), as does a `search` button, so the bar shows only the brand and the close button. The bar is 56 px tall below `lg` and 72 px from it, on the solid surface with a hairline under it; `sticky` (default `true`) keeps it at the window's top. While a sticky header is on the page the document's `scroll-padding-top` clears the bar, its hairline and a small gap, so a `#fragment` link, `:target` and `scrollIntoView` land below the bar instead of under it; a header with `sticky={false}` leaves the scroll padding alone. An optional `skipLink` (`{ label, href }`, such as `{ label: 'Skip to content', href: '#main' }`) is the header's first focusable element: visually hidden until it has focus, then a pill on the surface with the focus ring over the bar's start. Give the target (usually `main`) the matching `id`, and `tabIndex={-1}` so every browser moves focus there with the jump. No items, blank or repeated ids, blank labels or hrefs, a blank `navLabel` or menu label, or a skip link with a blank label or an `href` that is not a `#fragment` throw a `RangeError`.
|
|
1151
1152
|
|
|
1152
1153
|
```tsx
|
|
1153
1154
|
<SiteHeader
|
|
@@ -1172,6 +1173,21 @@ const { headings, omissions } = inspectMarkdown(page.body, {
|
|
|
1172
1173
|
/>
|
|
1173
1174
|
```
|
|
1174
1175
|
|
|
1176
|
+
An optional `search` (`SiteHeaderSearchOptions`: `{ action, name?, label, placeholder, labels: { open, close }, icon }`) adds the site's search. It is one GET form drawn once: from `lg` a search field in the bar (an sm pill with a hairline and the decorative `icon`, named `label`, showing `placeholder`), after the destinations and pushed to the bar's end with the `actions`; below `lg` a round search button (named `labels.open`, 44 px on touch) before the compact actions that opens the same form over the whole window as a native popover on the top layer, with the filled field at the top (the body size, so an iPhone does not zoom in), a close button beside it (named `labels.close`, drawn with `closeIcon`) and the results under it. Opening, closing (Escape or the close button) and submitting need no script: the form sends the query to `action` as `name` (default `q`), the site's results page. The popover is not modal and the browser moves no focus into it, so the site's script should focus the field on the popover's `toggle` event; with no script the reader taps the field. It needs Popover support (Safari 17, Firefox 125, Chrome 114); without it only the field from `lg` is drawn. An open search stays a full-window overlay if the window widens past `lg` until it is closed. The results are the consumer's: Scalewing draws an empty, `hidden` panel (`.sw-site-header-search-results`, which the field's `aria-controls` names) holding a polite status line (`.sw-site-header-search-status`), a list (`.sw-site-header-search-list`) and a row `template` (`.sw-site-header-search-row`: an `li` holding an `a.sw-site-header-search-result` with a `-title` and a `-text` span); a site's script fills them as the reader types and un-hides the panel. The status is a polite live region inside the panel, so write its final words after un-hiding it, in a later task (after the search resolves), or the first announcement may be missed. From `lg` the panel drops down under the field's end as a raised panel over the page, each result a row that takes the quiet fill on hover; below `lg` the results fill the window under the field, each a row with a hairline. A server render puts the row in the template's `content`; a client render leaves it as the template's child. A blank `action`, `label`, `placeholder` or button name, a `name` that is not a plain parameter name, or no `icon` throws a `RangeError`.
|
|
1177
|
+
|
|
1178
|
+
```tsx
|
|
1179
|
+
<SiteHeader
|
|
1180
|
+
…
|
|
1181
|
+
search={{
|
|
1182
|
+
action: '/docs/search/',
|
|
1183
|
+
label: 'Search the docs',
|
|
1184
|
+
placeholder: 'Search the docs',
|
|
1185
|
+
labels: { open: 'Search', close: 'Close search' },
|
|
1186
|
+
icon: <SearchIcon />,
|
|
1187
|
+
}}
|
|
1188
|
+
/>
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1175
1191
|
`Hero` is a public page's opening, a `section` named by its title: an optional `eyebrow` (muted label words), the `title` (the page's one `h1`, in the `hero` size), an optional `lead` (the `lead` size) and `actions` (links or buttons in a wrapping row, stacked to the full width below `md`), with an optional `media` picture. From `md` the picture keeps its own width at the row's end and the words take the rest; below `md` it sits centred under the words. With no picture the words keep the reading width (`--sw-reading-max`). Put it in the page's column (`sw-container`); it sets no gutter or fill of its own. The title always names the section (`aria-labelledby` is not a prop). Leave out `actions` or `media` rather than passing an empty fragment, which keeps its row or column. A blank `title` throws a `RangeError`.
|
|
1176
1192
|
|
|
1177
1193
|
```tsx
|
|
@@ -1225,6 +1241,45 @@ When the real screenshot exists, a `PreviewImage` (`src`, `width`, `height`) hol
|
|
|
1225
1241
|
/>
|
|
1226
1242
|
```
|
|
1227
1243
|
|
|
1244
|
+
`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.
|
|
1245
|
+
|
|
1246
|
+
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.
|
|
1247
|
+
|
|
1248
|
+
`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`.
|
|
1249
|
+
|
|
1250
|
+
```tsx
|
|
1251
|
+
<main id="main" tabIndex={-1}>
|
|
1252
|
+
<DocsLayout
|
|
1253
|
+
navLabel="Guide"
|
|
1254
|
+
labels={{ openNav: 'Browse the guide' }}
|
|
1255
|
+
groups={[
|
|
1256
|
+
{
|
|
1257
|
+
id: 'start',
|
|
1258
|
+
label: 'Start here',
|
|
1259
|
+
items: [
|
|
1260
|
+
{ id: 'home', label: 'Field guide home', href: '/guide/' },
|
|
1261
|
+
{
|
|
1262
|
+
id: 'first',
|
|
1263
|
+
label: 'Your first count',
|
|
1264
|
+
href: '/guide/first',
|
|
1265
|
+
current: 'page',
|
|
1266
|
+
},
|
|
1267
|
+
],
|
|
1268
|
+
},
|
|
1269
|
+
]}
|
|
1270
|
+
aside={
|
|
1271
|
+
<SectionNav
|
|
1272
|
+
aria-label="On this page"
|
|
1273
|
+
items={[{ id: 'before', label: 'Before you go', href: '#before' }]}
|
|
1274
|
+
verticalFrom="md"
|
|
1275
|
+
/>
|
|
1276
|
+
}
|
|
1277
|
+
>
|
|
1278
|
+
<article>…</article>
|
|
1279
|
+
</DocsLayout>
|
|
1280
|
+
</main>
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1228
1283
|
`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.
|
|
1229
1284
|
|
|
1230
1285
|
`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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SiteHeaderProps } from './site-header/types.js';
|
|
2
|
-
export type { SiteHeaderItem, SiteHeaderLabels, SiteHeaderProps, SiteHeaderSkipLink, } from './site-header/types.js';
|
|
2
|
+
export type { SiteHeaderItem, SiteHeaderLabels, SiteHeaderProps, SiteHeaderSearchOptions, SiteHeaderSkipLink, } from './site-header/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* A public site's header: the brand at the start; from `lg` the main
|
|
5
5
|
* destinations as a row of links (the current one marked by weight and a
|
|
@@ -10,8 +10,12 @@ export type { SiteHeaderItem, SiteHeaderLabels, SiteHeaderProps, SiteHeaderSkipL
|
|
|
10
10
|
* page rendered on the server needs; script adds Escape (focus back on the
|
|
11
11
|
* button) and closes it when a link is chosen or focus leaves it. It traps
|
|
12
12
|
* no focus. While the menu is open the compact actions step aside, so the
|
|
13
|
-
* bar shows only the brand and the close button
|
|
14
|
-
*
|
|
13
|
+
* bar shows only the brand and the close button (the search button
|
|
14
|
+
* steps aside too). An optional skip link
|
|
15
|
+
* comes first, hidden until it has focus. An optional `search` is a field
|
|
16
|
+
* in the bar from `lg` and a search button below it that opens the same
|
|
17
|
+
* form over the window as a native popover (no script); its results panel
|
|
18
|
+
* is the consumer script's to fill. Invalid items or words throw a
|
|
15
19
|
* `RangeError`.
|
|
16
20
|
*/
|
|
17
|
-
export declare function SiteHeader({ actions, brand, closeIcon, compactActions, items, labels, menuActions, menuIcon, navLabel, skipLink, sticky, }: SiteHeaderProps): import("react").JSX.Element;
|
|
21
|
+
export declare function SiteHeader({ actions, brand, closeIcon, compactActions, items, labels, menuActions, menuIcon, navLabel, search, skipLink, sticky, }: SiteHeaderProps): import("react").JSX.Element;
|
|
@@ -4,6 +4,7 @@ import { useRef } from 'react';
|
|
|
4
4
|
import { cx } from '../class-names.js';
|
|
5
5
|
import { tabStop } from '../tab-stop.js';
|
|
6
6
|
import { SiteHeaderLinks } from './site-header/SiteHeaderLinks.js';
|
|
7
|
+
import { SiteHeaderSearch } from './site-header/SiteHeaderSearch.js';
|
|
7
8
|
import { useMenuDismiss } from './site-header/use-menu-dismiss.js';
|
|
8
9
|
import { assertSiteHeaderProps } from './site-header/validate.js';
|
|
9
10
|
/**
|
|
@@ -16,13 +17,17 @@ import { assertSiteHeaderProps } from './site-header/validate.js';
|
|
|
16
17
|
* page rendered on the server needs; script adds Escape (focus back on the
|
|
17
18
|
* button) and closes it when a link is chosen or focus leaves it. It traps
|
|
18
19
|
* no focus. While the menu is open the compact actions step aside, so the
|
|
19
|
-
* bar shows only the brand and the close button
|
|
20
|
-
*
|
|
20
|
+
* bar shows only the brand and the close button (the search button
|
|
21
|
+
* steps aside too). An optional skip link
|
|
22
|
+
* comes first, hidden until it has focus. An optional `search` is a field
|
|
23
|
+
* in the bar from `lg` and a search button below it that opens the same
|
|
24
|
+
* form over the window as a native popover (no script); its results panel
|
|
25
|
+
* is the consumer script's to fill. Invalid items or words throw a
|
|
21
26
|
* `RangeError`.
|
|
22
27
|
*/
|
|
23
|
-
export function SiteHeader({ actions, brand, closeIcon, compactActions, items, labels, menuActions, menuIcon, navLabel, skipLink, sticky = true, }) {
|
|
24
|
-
assertSiteHeaderProps({ items, labels, navLabel, skipLink });
|
|
28
|
+
export function SiteHeader({ actions, brand, closeIcon, compactActions, items, labels, menuActions, menuIcon, navLabel, search, skipLink, sticky = true, }) {
|
|
29
|
+
assertSiteHeaderProps({ items, labels, navLabel, search, skipLink });
|
|
25
30
|
const menuRef = useRef(null);
|
|
26
31
|
useMenuDismiss(menuRef);
|
|
27
|
-
return (_jsxs("header", { className: cx('sw-site-header', sticky && 'sw-site-header-sticky'), children: [skipLink ? (_jsx("a", { className: "sw-site-header-skip-link", href: skipLink.href, tabIndex: tabStop, children: skipLink.label })) : null, _jsxs("div", { className: "sw-site-header-bar", children: [_jsx("div", { className: "sw-site-header-brand", children: brand }), _jsx(SiteHeaderLinks, { className: "sw-site-header-nav", items: items, navLabel: navLabel }), actions ? (_jsx("div", { className: "sw-site-header-actions", children: actions })) : null, _jsxs("div", { className: "sw-site-header-compact", children: [compactActions ? (_jsx("div", { className: "sw-site-header-compact-actions", children: compactActions })) : null, _jsxs("details", { className: "sw-site-header-menu", ref: menuRef, children: [_jsxs("summary", { className: "sw-site-header-menu-button", children: [_jsxs("span", { className: "sw-site-header-menu-open", children: [_jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: menuIcon }), _jsx("span", { className: "sw-sr-only", children: labels.openMenu })] }), _jsxs("span", { className: "sw-site-header-menu-close", children: [_jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: closeIcon }), _jsx("span", { className: "sw-sr-only", children: labels.closeMenu })] })] }), _jsxs("div", { className: "sw-site-header-panel", children: [_jsx(SiteHeaderLinks, { className: "sw-site-header-menu-nav", items: items, navLabel: navLabel }), menuActions ? (_jsx("div", { className: "sw-site-header-menu-actions", children: menuActions })) : null] })] })] })] })] }));
|
|
32
|
+
return (_jsxs("header", { className: cx('sw-site-header', sticky && 'sw-site-header-sticky'), children: [skipLink ? (_jsx("a", { className: "sw-site-header-skip-link", href: skipLink.href, tabIndex: tabStop, children: skipLink.label })) : null, _jsxs("div", { className: "sw-site-header-bar", children: [_jsx("div", { className: "sw-site-header-brand", children: brand }), _jsx(SiteHeaderLinks, { className: "sw-site-header-nav", items: items, navLabel: navLabel }), search ? (_jsx(SiteHeaderSearch, { closeIcon: closeIcon, search: search })) : null, actions ? (_jsx("div", { className: "sw-site-header-actions", children: actions })) : null, _jsxs("div", { className: "sw-site-header-compact", children: [compactActions ? (_jsx("div", { className: "sw-site-header-compact-actions", children: compactActions })) : null, _jsxs("details", { className: "sw-site-header-menu", ref: menuRef, children: [_jsxs("summary", { className: "sw-site-header-menu-button", children: [_jsxs("span", { className: "sw-site-header-menu-open", children: [_jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: menuIcon }), _jsx("span", { className: "sw-sr-only", children: labels.openMenu })] }), _jsxs("span", { className: "sw-site-header-menu-close", children: [_jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: closeIcon }), _jsx("span", { className: "sw-sr-only", children: labels.closeMenu })] })] }), _jsxs("div", { className: "sw-site-header-panel", children: [_jsx(SiteHeaderLinks, { className: "sw-site-header-menu-nav", items: items, navLabel: navLabel }), menuActions ? (_jsx("div", { className: "sw-site-header-menu-actions", children: menuActions })) : null] })] })] })] })] }));
|
|
28
33
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type SiteHeaderSearchOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The header's search: one form drawn once. From `lg` it sits in the bar as
|
|
5
|
+
* a search field; below `lg` it is a native popover that the search button
|
|
6
|
+
* opens over the whole window, with the field at the top, a close button
|
|
7
|
+
* beside it and the results under it, so it opens, closes on Escape and
|
|
8
|
+
* closes from its button with no script. Submitting sends the query to
|
|
9
|
+
* `action` as `name` (a results page). The results panel and its row
|
|
10
|
+
* template are empty until the consumer's script fills them; with no
|
|
11
|
+
* script the form still works.
|
|
12
|
+
*/
|
|
13
|
+
export declare function SiteHeaderSearch({ search, closeIcon, }: {
|
|
14
|
+
search: SiteHeaderSearchOptions;
|
|
15
|
+
closeIcon: ReactNode;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { tabStop } from '../../tab-stop.js';
|
|
4
|
+
/**
|
|
5
|
+
* The header's search: one form drawn once. From `lg` it sits in the bar as
|
|
6
|
+
* a search field; below `lg` it is a native popover that the search button
|
|
7
|
+
* opens over the whole window, with the field at the top, a close button
|
|
8
|
+
* beside it and the results under it, so it opens, closes on Escape and
|
|
9
|
+
* closes from its button with no script. Submitting sends the query to
|
|
10
|
+
* `action` as `name` (a results page). The results panel and its row
|
|
11
|
+
* template are empty until the consumer's script fills them; with no
|
|
12
|
+
* script the form still works.
|
|
13
|
+
*/
|
|
14
|
+
export function SiteHeaderSearch({ search, closeIcon, }) {
|
|
15
|
+
const id = useId();
|
|
16
|
+
const panelId = `${id}search`;
|
|
17
|
+
const resultsId = `${id}results`;
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": search.labels.open, className: "sw-site-header-search-button", popoverTarget: panelId, popoverTargetAction: "show", tabIndex: tabStop, type: "button", children: _jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: search.icon }) }), _jsxs("div", { className: "sw-site-header-search", id: panelId, popover: "auto", children: [_jsxs("form", { action: search.action, className: "sw-site-header-search-form", method: "get", role: "search", children: [_jsxs("div", { className: "sw-site-header-search-field", children: [_jsx("span", { "aria-hidden": "true", className: "sw-site-header-search-icon", children: search.icon }), _jsx("input", { "aria-controls": resultsId, "aria-label": search.label, autoComplete: "off", className: "sw-site-header-search-input", enterKeyHint: "search", name: search.name ?? 'q', placeholder: search.placeholder, tabIndex: tabStop, type: "search" })] }), _jsx("button", { "aria-label": search.labels.close, className: "sw-site-header-search-close", popoverTarget: panelId, popoverTargetAction: "hide", tabIndex: tabStop, type: "button", children: _jsx("span", { "aria-hidden": "true", className: "sw-site-header-glyph", children: closeIcon }) })] }), _jsxs("div", { className: "sw-site-header-search-results", hidden: true, id: resultsId, children: [_jsx("p", { "aria-live": "polite", className: "sw-site-header-search-status" }), _jsx("ul", { className: "sw-site-header-search-list" }), _jsx("template", { className: "sw-site-header-search-row", children: _jsx("li", { children: _jsxs("a", { className: "sw-site-header-search-result", href: "/", children: [_jsx("span", { className: "sw-site-header-search-result-title" }), _jsx("span", { className: "sw-site-header-search-result-text" })] }) }) })] })] })] }));
|
|
19
|
+
}
|
|
@@ -25,6 +25,28 @@ export type SiteHeaderSkipLink = {
|
|
|
25
25
|
/** The main content's fragment, such as `#main`. */
|
|
26
26
|
href: string;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* The header's search form: a field in the bar from `lg`, a search button
|
|
30
|
+
* opening a full-window search below it. Submitting goes to `action` (the
|
|
31
|
+
* site's results page) with the query as `name`.
|
|
32
|
+
*/
|
|
33
|
+
export type SiteHeaderSearchOptions = {
|
|
34
|
+
/** The results page the form submits to with GET, such as `/docs/search/`. */
|
|
35
|
+
action: string;
|
|
36
|
+
/** The query's parameter name (default `q`). */
|
|
37
|
+
name?: string;
|
|
38
|
+
/** The field's accessible name, such as "Search the docs". */
|
|
39
|
+
label: string;
|
|
40
|
+
/** The empty field's hint, such as "Search the docs". */
|
|
41
|
+
placeholder: string;
|
|
42
|
+
/** The button names: `open` below `lg` ("Search"), `close` in the open search ("Close search"). */
|
|
43
|
+
labels: {
|
|
44
|
+
open: string;
|
|
45
|
+
close: string;
|
|
46
|
+
};
|
|
47
|
+
/** The magnifier glyph, decorative, in the button and the field. */
|
|
48
|
+
icon: ReactNode;
|
|
49
|
+
};
|
|
28
50
|
export type SiteHeaderProps = {
|
|
29
51
|
/** The site's mark at the start, such as a logo linked to the home page. */
|
|
30
52
|
brand: ReactNode;
|
|
@@ -50,4 +72,6 @@ export type SiteHeaderProps = {
|
|
|
50
72
|
sticky?: boolean;
|
|
51
73
|
/** A "skip to content" link before everything else in the header. */
|
|
52
74
|
skipLink?: SiteHeaderSkipLink;
|
|
75
|
+
/** A search field in the bar from `lg`; a search button below it. */
|
|
76
|
+
search?: SiteHeaderSearchOptions;
|
|
53
77
|
};
|
|
@@ -5,4 +5,4 @@ import { type SiteHeaderProps } from './types.js';
|
|
|
5
5
|
* button name, and a skip link with blank words or an address that is not
|
|
6
6
|
* a fragment on the page.
|
|
7
7
|
*/
|
|
8
|
-
export declare function assertSiteHeaderProps({ items, labels, navLabel, skipLink, }: Pick<SiteHeaderProps, 'items' | 'labels' | 'navLabel' | 'skipLink'>): void;
|
|
8
|
+
export declare function assertSiteHeaderProps({ items, labels, navLabel, search, skipLink, }: Pick<SiteHeaderProps, 'items' | 'labels' | 'navLabel' | 'search' | 'skipLink'>): void;
|
|
@@ -5,7 +5,7 @@ import { assertNavItems } from '../nav-items.js';
|
|
|
5
5
|
* button name, and a skip link with blank words or an address that is not
|
|
6
6
|
* a fragment on the page.
|
|
7
7
|
*/
|
|
8
|
-
export function assertSiteHeaderProps({ items, labels, navLabel, skipLink, }) {
|
|
8
|
+
export function assertSiteHeaderProps({ items, labels, navLabel, search, skipLink, }) {
|
|
9
9
|
if (items.length === 0)
|
|
10
10
|
throw new RangeError('SiteHeader needs at least one item');
|
|
11
11
|
assertNavItems('SiteHeader', items);
|
|
@@ -17,6 +17,27 @@ export function assertSiteHeaderProps({ items, labels, navLabel, skipLink, }) {
|
|
|
17
17
|
throw new RangeError('SiteHeader labels need nonempty openMenu and closeMenu');
|
|
18
18
|
if (skipLink)
|
|
19
19
|
assertSkipLink(skipLink);
|
|
20
|
+
if (search)
|
|
21
|
+
assertSearch(search);
|
|
22
|
+
}
|
|
23
|
+
function assertSearch(search) {
|
|
24
|
+
if (typeof search.labels !== 'object' || search.labels === null)
|
|
25
|
+
throw new RangeError('SiteHeader search needs a nonempty action, label, placeholder and open and close labels');
|
|
26
|
+
const words = [
|
|
27
|
+
search.action,
|
|
28
|
+
search.label,
|
|
29
|
+
search.placeholder,
|
|
30
|
+
search.labels.open,
|
|
31
|
+
search.labels.close,
|
|
32
|
+
];
|
|
33
|
+
if (words.some((word) => !word.trim()))
|
|
34
|
+
throw new RangeError('SiteHeader search needs a nonempty action, label, placeholder and open and close labels');
|
|
35
|
+
if (search.name !== undefined && !/^[\w-]+$/.test(search.name))
|
|
36
|
+
throw new RangeError('SiteHeader search name must be a plain parameter name');
|
|
37
|
+
if (search.icon === null ||
|
|
38
|
+
search.icon === undefined ||
|
|
39
|
+
search.icon === false)
|
|
40
|
+
throw new RangeError('SiteHeader search needs an icon');
|
|
20
41
|
}
|
|
21
42
|
function assertSkipLink({ href, label }) {
|
|
22
43
|
if (!label.trim())
|
|
@@ -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 @@
|
|
|
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
|
+
}
|