@dogsbay/ui 0.2.0-beta.13 → 0.2.0-beta.131
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/package.json +37 -12
- package/src/alert/CollapsibleAlert.astro +33 -7
- package/src/alert/icon.ts +8 -15
- package/src/api-layout/ApiLayout.astro +28 -4
- package/src/api-layout/ExampleBlock.astro +3 -2
- package/src/api-symbol/api-symbol.css +14 -11
- package/src/avatar/Avatar.astro +6 -2
- package/src/badge/Badge.astro +3 -10
- package/src/badge/variants.ts +39 -0
- package/src/code-block/CodeBlock.astro +38 -8
- package/src/code-rich/CodeRich.astro +149 -15
- package/src/code-rich/code-rich.css +54 -2
- package/src/code-rich/markers.ts +66 -0
- package/src/content-renderer/ContentRenderer.astro +47 -6
- package/src/content-renderer/InlineRenderer.astro +24 -1
- package/src/details-sheet/DetailsSheet.astro +28 -0
- package/src/details-sheet/index.ts +1 -0
- package/src/docs-layout/DocsLayout.astro +36 -4
- package/src/endpoint-card/EndpointCard.astro +59 -1
- package/src/files/FileTree.astro +16 -0
- package/src/files/index.ts +2 -0
- package/src/files/markup.ts +34 -0
- package/src/image/Image.astro +23 -2
- package/src/kbd/Kbd.astro +2 -3
- package/src/kbd/variants.ts +3 -0
- package/src/link-card/LinkCard.astro +10 -3
- package/src/property-list/PropertyList.astro +3 -2
- package/src/sidebar/SidebarNavMark.astro +85 -0
- package/src/sidebar/SidebarNavTree.astro +111 -7
- package/src/sidebar/sidebar.ts +2 -2
- package/src/steps/Steps.astro +5 -0
- package/src/steps/SubSteps.astro +5 -0
- package/src/table/Table.astro +16 -2
- package/src/table/TableCell.astro +1 -1
- package/src/table/TableHead.astro +1 -1
- package/src/toc/TableOfContents.astro +10 -10
- package/src/youtube/YouTube.astro +2 -2
|
@@ -51,10 +51,68 @@ const { method, path, baseUrl, summary, description, deprecated = false, class:
|
|
|
51
51
|
|
|
52
52
|
{summary && <p class="text-sm text-muted-foreground">{summary}</p>}
|
|
53
53
|
{description && description !== summary && (
|
|
54
|
-
<div class="text-sm text-muted-foreground" set:html={description} />
|
|
54
|
+
<div class="api-description text-sm text-muted-foreground" set:html={description} />
|
|
55
55
|
)}
|
|
56
56
|
|
|
57
57
|
<div class="space-y-3">
|
|
58
58
|
<slot />
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
61
|
+
|
|
62
|
+
<style is:global>
|
|
63
|
+
/* An operation's description is Markdown rendered to HTML (lists, code,
|
|
64
|
+
paragraphs), placed where the page's prose styles do not reach: without
|
|
65
|
+
these a bulleted field list reads as loose lines. */
|
|
66
|
+
.api-description > * + * {
|
|
67
|
+
margin-top: 0.5rem;
|
|
68
|
+
}
|
|
69
|
+
.api-description ul {
|
|
70
|
+
list-style: disc;
|
|
71
|
+
padding-left: 1.25rem;
|
|
72
|
+
}
|
|
73
|
+
.api-description ol {
|
|
74
|
+
list-style: decimal;
|
|
75
|
+
padding-left: 1.25rem;
|
|
76
|
+
}
|
|
77
|
+
.api-description li + li,
|
|
78
|
+
.api-description li > ul,
|
|
79
|
+
.api-description li > ol {
|
|
80
|
+
margin-top: 0.125rem;
|
|
81
|
+
}
|
|
82
|
+
.api-description ul ul {
|
|
83
|
+
list-style: circle;
|
|
84
|
+
}
|
|
85
|
+
/* Field names (`id`, `scm_type`) stand out in the JSON key colour,
|
|
86
|
+
on a faint tint of it. Override --api-field in the theme to change it; a site
|
|
87
|
+
scaffolded before the token existed gets --api-post, the same blue. */
|
|
88
|
+
.api-description code {
|
|
89
|
+
font-family: var(--font-mono, ui-monospace, monospace);
|
|
90
|
+
font-size: 0.85em;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
color: var(--api-field, var(--api-post, var(--foreground)));
|
|
93
|
+
background-color: color-mix(in oklab, var(--api-field, var(--api-post, var(--foreground))) 8%, transparent);
|
|
94
|
+
border-radius: 0.25rem;
|
|
95
|
+
padding: 0.0625rem 0.3rem;
|
|
96
|
+
}
|
|
97
|
+
/* A code block in a description (a JSON shape, `?order_by=`) is one
|
|
98
|
+
full-width block, as Swagger UI shows it: the chip styling above,
|
|
99
|
+
applied per line, read as a stack of separate highlights. */
|
|
100
|
+
.api-description pre {
|
|
101
|
+
overflow-x: auto;
|
|
102
|
+
border-radius: 0.375rem;
|
|
103
|
+
padding: 0.5rem 0.75rem;
|
|
104
|
+
background-color: var(--code-background, color-mix(in oklab, var(--foreground) 6%, transparent));
|
|
105
|
+
}
|
|
106
|
+
.api-description pre code {
|
|
107
|
+
display: block;
|
|
108
|
+
padding: 0;
|
|
109
|
+
border-radius: 0;
|
|
110
|
+
background: none;
|
|
111
|
+
white-space: pre;
|
|
112
|
+
}
|
|
113
|
+
.api-description a {
|
|
114
|
+
color: var(--primary);
|
|
115
|
+
text-decoration: underline;
|
|
116
|
+
text-underline-offset: 2px;
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FileTree — the `:::files` directive: a nested list shown as folders and files.
|
|
4
|
+
* The markup is fileTreeHtml (markup.ts), shared with dogsbay-ssg.
|
|
5
|
+
*/
|
|
6
|
+
import { fileTreeHtml, type FileTreeItem } from "./markup.js";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
items: FileTreeItem[];
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { items, class: className } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<Fragment set:html={fileTreeHtml(items, className ?? "")} />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `:::files` tree, written once for both pipelines: FileTree.astro renders it,
|
|
3
|
+
* and dogsbay-ssg copies this file (scripts/sync-astro-styles.mjs) and calls it.
|
|
4
|
+
* Each pipeline turns an entry's inline Markdown into `label` HTML itself.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface FileTreeItem {
|
|
8
|
+
/** The entry's label as HTML (already escaped). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** A folder: it has entries, or its name ends in "/". */
|
|
11
|
+
folder: boolean;
|
|
12
|
+
children: FileTreeItem[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const svg = (body: string) =>
|
|
16
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0 text-muted-foreground" aria-hidden="true" focusable="false">${body}</svg>`;
|
|
17
|
+
// Lucide folder and file (ISC licence).
|
|
18
|
+
const FOLDER = svg('<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>');
|
|
19
|
+
const FILE = svg('<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>');
|
|
20
|
+
|
|
21
|
+
function list(items: FileTreeItem[], nested: boolean): string {
|
|
22
|
+
const cls = nested ? "m-0 ml-2 list-none border-l border-border pl-4" : "m-0 list-none p-0";
|
|
23
|
+
return `<ul class="${cls}">${items
|
|
24
|
+
.map(
|
|
25
|
+
(it) =>
|
|
26
|
+
`<li class="my-0.5" data-kind="${it.folder ? "folder" : "file"}"><span class="inline-flex items-center gap-1.5">${it.folder ? FOLDER : FILE}<span>${it.label}</span></span>${it.children.length ? list(it.children, true) : ""}</li>`,
|
|
27
|
+
)
|
|
28
|
+
.join("")}</ul>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The whole tree, in a bordered, monospaced box. */
|
|
32
|
+
export function fileTreeHtml(items: FileTreeItem[], extraClass = ""): string {
|
|
33
|
+
return `<div class="not-prose my-4 overflow-x-auto rounded-lg border bg-card p-3 font-mono text-sm${extraClass ? ` ${extraClass}` : ""}" data-component="files">${list(items, false)}</div>`;
|
|
34
|
+
}
|
package/src/image/Image.astro
CHANGED
|
@@ -47,6 +47,27 @@ const captionText = caption || title;
|
|
|
47
47
|
const w = width || (imageData ? imageData.width : undefined);
|
|
48
48
|
const h = height || (imageData ? imageData.height : undefined);
|
|
49
49
|
|
|
50
|
+
// When `imageData` is unavailable (image not in import.meta.glob —
|
|
51
|
+
// e.g. SVG, PDF, or build-time `imageOptimization: false`), the
|
|
52
|
+
// `<img src={src}>` fallback fires with the raw markdown src. For
|
|
53
|
+
// absolute paths like `/_assets/foo.png`, we need to prefix with
|
|
54
|
+
// Astro's `base` so the URL resolves on subpath-mounted deploys
|
|
55
|
+
// (GH Pages project pages, multi-mount Cloudflare).
|
|
56
|
+
//
|
|
57
|
+
// `<AstroImage>` does this automatically; raw `<img>` does not.
|
|
58
|
+
//
|
|
59
|
+
// Skip prefixing for: external URLs (http/https), data: URIs,
|
|
60
|
+
// and paths that already start with `import.meta.env.BASE_URL`
|
|
61
|
+
// (defensive; shouldn't normally happen).
|
|
62
|
+
const baseUrl = import.meta.env.BASE_URL.replace(/\/$/, "");
|
|
63
|
+
const resolvedSrc =
|
|
64
|
+
baseUrl &&
|
|
65
|
+
src.startsWith("/") &&
|
|
66
|
+
!src.startsWith(`${baseUrl}/`) &&
|
|
67
|
+
!/^(?:[a-z]+:|\/\/)/i.test(src)
|
|
68
|
+
? `${baseUrl}${src}`
|
|
69
|
+
: src;
|
|
70
|
+
|
|
50
71
|
const alignClass = align === "left"
|
|
51
72
|
? "float-left mr-4 mb-2"
|
|
52
73
|
: align === "right"
|
|
@@ -71,7 +92,7 @@ const alignClass = align === "left"
|
|
|
71
92
|
/>
|
|
72
93
|
) : (
|
|
73
94
|
<img
|
|
74
|
-
src={
|
|
95
|
+
src={resolvedSrc}
|
|
75
96
|
alt={alt}
|
|
76
97
|
title={title}
|
|
77
98
|
width={w}
|
|
@@ -102,7 +123,7 @@ const alignClass = align === "left"
|
|
|
102
123
|
/>
|
|
103
124
|
) : (
|
|
104
125
|
<img
|
|
105
|
-
src={
|
|
126
|
+
src={resolvedSrc}
|
|
106
127
|
alt={alt}
|
|
107
128
|
title={title}
|
|
108
129
|
width={w}
|
package/src/kbd/Kbd.astro
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
|
+
import { KBD_CLASS } from "./variants.js";
|
|
3
4
|
|
|
4
|
-
const kbd = tv({
|
|
5
|
-
base: "pointer-events-none inline-flex h-5 items-center justify-center gap-1 rounded border bg-muted px-1.5 font-mono text-xs font-medium text-muted-foreground shadow-[0_1px_0_1px] shadow-muted",
|
|
6
|
-
});
|
|
5
|
+
const kbd = tv({ base: KBD_CLASS });
|
|
7
6
|
|
|
8
7
|
interface Props {
|
|
9
8
|
class?: string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Kbd.astro's classes, shared with dogsbay-ssg (copied by scripts/sync-astro-styles.mjs). */
|
|
2
|
+
export const KBD_CLASS =
|
|
3
|
+
"pointer-events-none inline-flex h-5 items-center justify-center gap-1 rounded border bg-muted px-1.5 font-mono text-xs font-medium text-muted-foreground shadow-[0_1px_0_1px] shadow-muted";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
|
+
import Icon from "../icon/Icon.astro";
|
|
3
4
|
|
|
4
5
|
const linkCard = tv({
|
|
5
|
-
|
|
6
|
+
// not-prose: the page's link underline would otherwise run under every line of the card
|
|
7
|
+
base: "not-prose group flex flex-col gap-1 rounded-lg border bg-card p-4 text-card-foreground no-underline shadow-sm transition-colors hover:bg-accent/50",
|
|
6
8
|
});
|
|
7
9
|
|
|
8
10
|
const linkCardTitle = tv({
|
|
@@ -17,16 +19,21 @@ interface Props {
|
|
|
17
19
|
title: string;
|
|
18
20
|
description?: string;
|
|
19
21
|
href: string;
|
|
22
|
+
/** An icon before the title: a name (`rocket`, `mdi:home`) as the Icon component takes. */
|
|
23
|
+
icon?: string;
|
|
20
24
|
class?: string;
|
|
21
25
|
[key: string]: unknown;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
const { title, description, href, class: className, ...rest } = Astro.props;
|
|
28
|
+
const { title, description, href, icon, class: className, ...rest } = Astro.props;
|
|
25
29
|
---
|
|
26
30
|
|
|
27
31
|
<a href={href} class={linkCard({ class: className })} {...rest}>
|
|
28
32
|
<div class="flex items-center justify-between">
|
|
29
|
-
<span class=
|
|
33
|
+
<span class="flex min-w-0 items-center gap-2">
|
|
34
|
+
{icon && <Icon name={icon} class="size-4 shrink-0 text-muted-foreground" />}
|
|
35
|
+
<span class={linkCardTitle()}>{title}</span>
|
|
36
|
+
</span>
|
|
30
37
|
<svg
|
|
31
38
|
xmlns="http://www.w3.org/2000/svg"
|
|
32
39
|
width="16"
|
|
@@ -47,9 +47,10 @@ const groups = locationOrder
|
|
|
47
47
|
<div class={className}>
|
|
48
48
|
{groups.map((group) => (
|
|
49
49
|
<div class="mb-4 last:mb-0">
|
|
50
|
-
|
|
50
|
+
{/* A label, not a heading: under an embed's tag h2 an h4 skipped a level (axe heading-order). */}
|
|
51
|
+
<p class="mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
|
|
51
52
|
{group.label}
|
|
52
|
-
</
|
|
53
|
+
</p>
|
|
53
54
|
<div class="rounded-lg border bg-card">
|
|
54
55
|
{group.params.map((param) => (
|
|
55
56
|
<PropertyItem
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A nav state marker (changed / new / removed / moved).
|
|
4
|
+
*
|
|
5
|
+
* Accessibility contract — the reason this is a component and not a
|
|
6
|
+
* coloured dot inlined three times:
|
|
7
|
+
*
|
|
8
|
+
* - **Never colour alone** (WCAG 1.4.1): each kind gets a distinct
|
|
9
|
+
* GLYPH (+ • − →), so it is readable in greyscale and by anyone who
|
|
10
|
+
* does not perceive the hue difference. Colour only reinforces.
|
|
11
|
+
* - **Survives forced-colors** (Windows High Contrast strips
|
|
12
|
+
* background-color): the glyph is real text, so it always renders;
|
|
13
|
+
* `currentColor` keeps it visible when the palette is overridden.
|
|
14
|
+
* - **Announced, not implied**: a visually-hidden word rides along, so
|
|
15
|
+
* the row reads "MySQL, changed". `title` alone is not enough — it is
|
|
16
|
+
* unreliable in screen readers and invisible to touch users.
|
|
17
|
+
* - **aria-hidden on the glyph** so it is not announced twice.
|
|
18
|
+
*/
|
|
19
|
+
interface Props {
|
|
20
|
+
kind: "added" | "changed" | "removed" | "moved";
|
|
21
|
+
/** Announced text; defaults to the kind (or "contains X" for a subtree). */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** True when this summarizes DESCENDANTS (a collapsed group). */
|
|
24
|
+
subtree?: boolean;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { kind, label, subtree = false, class: className } = Astro.props;
|
|
29
|
+
|
|
30
|
+
const GLYPH: Record<Props["kind"], string> = {
|
|
31
|
+
added: "+",
|
|
32
|
+
changed: "•",
|
|
33
|
+
removed: "−",
|
|
34
|
+
moved: "→",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const text = label ?? (subtree ? `contains ${kind}` : kind);
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<span
|
|
41
|
+
class:list={["db-nav-mark", className]}
|
|
42
|
+
data-nav-mark={kind}
|
|
43
|
+
data-nav-mark-subtree={subtree ? "" : undefined}
|
|
44
|
+
title={text}
|
|
45
|
+
>
|
|
46
|
+
<span aria-hidden="true">{GLYPH[kind]}</span>
|
|
47
|
+
<span class="sr-only">{text}</span>
|
|
48
|
+
</span>
|
|
49
|
+
|
|
50
|
+
<style is:global>
|
|
51
|
+
.db-nav-mark {
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
width: 1rem;
|
|
57
|
+
height: 1rem;
|
|
58
|
+
margin-left: auto; /* right-aligned: labels stay flush-left and scannable */
|
|
59
|
+
border-radius: 99px;
|
|
60
|
+
font-size: 0.75rem;
|
|
61
|
+
line-height: 1;
|
|
62
|
+
font-weight: 700;
|
|
63
|
+
/* colour REINFORCES the glyph; it never carries the meaning alone */
|
|
64
|
+
color: var(--color-muted-foreground, currentColor);
|
|
65
|
+
}
|
|
66
|
+
.db-nav-mark[data-nav-mark="added"] { color: var(--color-success, oklch(0.72 0.19 150)); }
|
|
67
|
+
.db-nav-mark[data-nav-mark="changed"] { color: var(--color-warning, oklch(0.8 0.16 85)); }
|
|
68
|
+
.db-nav-mark[data-nav-mark="removed"] { color: var(--color-destructive, oklch(0.64 0.21 25)); }
|
|
69
|
+
.db-nav-mark[data-nav-mark="moved"] { color: var(--color-info, oklch(0.7 0.14 240)); }
|
|
70
|
+
/* A subtree marker is a hint, not a claim about this row — mute it. */
|
|
71
|
+
.db-nav-mark[data-nav-mark-subtree] { opacity: 0.55; }
|
|
72
|
+
|
|
73
|
+
/* Removed pages get a second non-colour signal — but ONLY a page that
|
|
74
|
+
is itself removed. A subtree aggregate is a claim about descendants;
|
|
75
|
+
striking through a surviving group would tell the reader the whole
|
|
76
|
+
section was deleted. */
|
|
77
|
+
[data-nav-mark-row="removed"]:not([data-nav-mark-subtree]) {
|
|
78
|
+
text-decoration: line-through;
|
|
79
|
+
opacity: 0.7;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (forced-colors: active) {
|
|
83
|
+
.db-nav-mark { color: CanvasText; }
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import SidebarNavMark from "./SidebarNavMark.astro";
|
|
2
3
|
/**
|
|
3
4
|
* Recursive sidebar navigation tree.
|
|
4
5
|
* Renders a data-driven tree with native <details>/<summary> for zero-JS expand/collapse.
|
|
@@ -8,11 +9,18 @@
|
|
|
8
9
|
* <SidebarNavTree items={navItems} currentPath={Astro.url.pathname} />
|
|
9
10
|
*/
|
|
10
11
|
|
|
12
|
+
interface NavMark {
|
|
13
|
+
kind: "added" | "changed" | "removed" | "moved";
|
|
14
|
+
label?: string;
|
|
15
|
+
subtree?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
interface NavItem {
|
|
12
19
|
label: string;
|
|
13
20
|
href?: string;
|
|
14
21
|
icon?: string; // Raw SVG string (rendered via set:html)
|
|
15
22
|
children?: NavItem[];
|
|
23
|
+
mark?: NavMark;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
interface Props {
|
|
@@ -24,6 +32,13 @@ interface Props {
|
|
|
24
32
|
|
|
25
33
|
const { items, currentPath, level = 0, class: className } = Astro.props;
|
|
26
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Markers are rendered by SidebarNavMark, which owns the accessibility
|
|
37
|
+
* contract (distinct glyph so colour is never the sole channel,
|
|
38
|
+
* visually-hidden text so the row announces "MySQL, changed",
|
|
39
|
+
* forced-colors survival). See that component.
|
|
40
|
+
*/
|
|
41
|
+
|
|
27
42
|
const normalizedPath = currentPath.replace(/\/$/, "") || "/";
|
|
28
43
|
|
|
29
44
|
function isActive(href: string) {
|
|
@@ -54,24 +69,78 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
54
69
|
const active = item.href ? isActive(item.href) : false;
|
|
55
70
|
const hasChildren = item.children && item.children.length > 0;
|
|
56
71
|
const shouldOpen = hasChildren && hasActiveDescendant(item);
|
|
72
|
+
const open = shouldOpen || active;
|
|
73
|
+
// A branch that is ALSO a page (has an href) is a section landing
|
|
74
|
+
// page; it uses the button-driven disclosure below and needs a
|
|
75
|
+
// stable id linking its toggle button to its submenu.
|
|
76
|
+
const submenuId = item.href
|
|
77
|
+
? `nav-sub-${item.href.replace(/[^a-z0-9]+/gi, "-")}-${level}`
|
|
78
|
+
: undefined;
|
|
57
79
|
|
|
58
80
|
return (
|
|
59
81
|
<li data-sidebar="nav-tree-item">
|
|
60
|
-
{hasChildren ? (
|
|
82
|
+
{hasChildren && item.href ? (
|
|
83
|
+
/*
|
|
84
|
+
Section landing page: APG "disclosure navigation" pattern — a
|
|
85
|
+
real link (navigates) + a SEPARATE toggle <button> (expands),
|
|
86
|
+
as siblings. Nesting a focusable <a> inside the interactive
|
|
87
|
+
<summary> is an axe `nested-interactive` violation, and native
|
|
88
|
+
<details> can't show a header link when collapsed without that
|
|
89
|
+
nesting. Progressive enhancement: the submenu's server state
|
|
90
|
+
(hidden unless open) is correct with no JS — the link still
|
|
91
|
+
works and the active section is expanded — and the inline
|
|
92
|
+
script wires the toggle button when JS is available.
|
|
93
|
+
*/
|
|
94
|
+
<Fragment>
|
|
95
|
+
<div
|
|
96
|
+
class:list={[
|
|
97
|
+
"flex w-full min-w-0 items-center gap-2 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
98
|
+
level === 0 ? "h-8" : "h-7",
|
|
99
|
+
active && "bg-sidebar-accent font-medium text-sidebar-accent-foreground",
|
|
100
|
+
]}
|
|
101
|
+
style={`padding-left: ${paddingLeft};`}
|
|
102
|
+
>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
data-nav-toggle
|
|
106
|
+
aria-controls={submenuId}
|
|
107
|
+
aria-expanded={open ? "true" : "false"}
|
|
108
|
+
aria-label={`Toggle ${item.label} section`}
|
|
109
|
+
class="shrink-0 rounded outline-none ring-sidebar-ring focus-visible:ring-2"
|
|
110
|
+
>
|
|
111
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0 transition-transform duration-200" data-chevron aria-hidden="true"><polyline points="9 18 15 12 9 6" /></svg>
|
|
112
|
+
</button>
|
|
113
|
+
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
114
|
+
<a
|
|
115
|
+
href={item.href}
|
|
116
|
+
class="min-w-0 flex-1 truncate text-inherit no-underline outline-none ring-sidebar-ring focus-visible:ring-2"
|
|
117
|
+
data-nav-href={item.href}
|
|
118
|
+
data-active={active || undefined}
|
|
119
|
+
data-nav-mark-row={item.mark?.subtree ? undefined : item.mark?.kind}
|
|
120
|
+
>{item.label}</a>
|
|
121
|
+
{item.mark && (
|
|
122
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
<div id={submenuId} data-nav-submenu hidden={!open}>
|
|
126
|
+
<Astro.self items={item.children!} currentPath={currentPath} level={level + 1} />
|
|
127
|
+
</div>
|
|
128
|
+
</Fragment>
|
|
129
|
+
) : hasChildren ? (
|
|
61
130
|
<details open={shouldOpen || active}>
|
|
62
131
|
<summary
|
|
63
132
|
class:list={[
|
|
64
133
|
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md text-sm text-sidebar-foreground outline-none [list-style:none] ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&::-webkit-details-marker]:hidden",
|
|
65
134
|
level === 0 ? "h-8" : "h-7",
|
|
66
|
-
active && "bg-sidebar-accent font-medium text-sidebar-accent-foreground",
|
|
67
135
|
]}
|
|
68
136
|
style={`padding-left: ${paddingLeft};`}
|
|
69
|
-
data-nav-href={item.href || undefined}
|
|
70
|
-
data-active={active || undefined}
|
|
71
137
|
>
|
|
72
138
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0 transition-transform duration-200" data-chevron aria-hidden="true"><polyline points="9 18 15 12 9 6" /></svg>
|
|
73
139
|
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
74
|
-
<span class="truncate">{item.label}</span>
|
|
140
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
141
|
+
{item.mark && (
|
|
142
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
143
|
+
)}
|
|
75
144
|
</summary>
|
|
76
145
|
<Astro.self items={item.children!} currentPath={currentPath} level={level + 1} />
|
|
77
146
|
</details>
|
|
@@ -86,12 +155,22 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
86
155
|
style={`padding-left: ${paddingLeft};`}
|
|
87
156
|
data-active={active || undefined}
|
|
88
157
|
data-nav-href={item.href}
|
|
158
|
+
{/*
|
|
159
|
+
A SUBTREE mark is a claim about descendants, never about
|
|
160
|
+
this row — striking through a surviving group because one
|
|
161
|
+
child was deleted tells the reader the whole section is
|
|
162
|
+
gone (code review, 2026-07-13).
|
|
163
|
+
*/}
|
|
164
|
+
data-nav-mark-row={item.mark?.subtree ? undefined : item.mark?.kind}
|
|
89
165
|
>
|
|
90
166
|
{/* Spacer to align with chevron in branch items */}
|
|
91
167
|
<span class="size-4 shrink-0" />
|
|
92
168
|
{/* Icon (level 0 only) */}
|
|
93
169
|
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
94
|
-
<span class="truncate">{item.label}</span>
|
|
170
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
171
|
+
{item.mark && (
|
|
172
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
173
|
+
)}
|
|
95
174
|
</a>
|
|
96
175
|
)}
|
|
97
176
|
</li>
|
|
@@ -100,7 +179,32 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
100
179
|
</ul>
|
|
101
180
|
|
|
102
181
|
<style is:global>
|
|
103
|
-
details[open] > summary [data-chevron]
|
|
182
|
+
details[open] > summary [data-chevron],
|
|
183
|
+
[data-nav-toggle][aria-expanded="true"] [data-chevron] {
|
|
104
184
|
transform: rotate(90deg);
|
|
105
185
|
}
|
|
106
186
|
</style>
|
|
187
|
+
|
|
188
|
+
<script>
|
|
189
|
+
// Wire the section-landing disclosure toggles (APG disclosure-nav).
|
|
190
|
+
// The link navigates on its own; this button just expands/collapses
|
|
191
|
+
// the sibling submenu. Server-rendered state is already correct, so
|
|
192
|
+
// with no JS the link still works and the active section is open.
|
|
193
|
+
// Idempotent + re-run after view transitions.
|
|
194
|
+
function wireNavToggles() {
|
|
195
|
+
document
|
|
196
|
+
.querySelectorAll<HTMLButtonElement>("[data-nav-toggle]:not([data-wired])")
|
|
197
|
+
.forEach((btn) => {
|
|
198
|
+
btn.dataset.wired = "1";
|
|
199
|
+
const id = btn.getAttribute("aria-controls");
|
|
200
|
+
const submenu = id ? document.getElementById(id) : null;
|
|
201
|
+
btn.addEventListener("click", () => {
|
|
202
|
+
const isOpen = btn.getAttribute("aria-expanded") === "true";
|
|
203
|
+
btn.setAttribute("aria-expanded", String(!isOpen));
|
|
204
|
+
if (submenu) submenu.hidden = isOpen;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
wireNavToggles();
|
|
209
|
+
document.addEventListener("astro:page-load", wireNavToggles);
|
|
210
|
+
</script>
|
package/src/sidebar/sidebar.ts
CHANGED
|
@@ -202,7 +202,7 @@ function openMobile(provider: HTMLElement) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// Lock scroll
|
|
205
|
-
ScrollLock.
|
|
205
|
+
ScrollLock.activate();
|
|
206
206
|
|
|
207
207
|
// Focus first focusable element in sidebar
|
|
208
208
|
requestAnimationFrame(() => {
|
|
@@ -237,7 +237,7 @@ function closeMobile(provider: HTMLElement) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// Unlock scroll
|
|
240
|
-
ScrollLock.
|
|
240
|
+
ScrollLock.deactivate();
|
|
241
241
|
|
|
242
242
|
// Return focus to trigger
|
|
243
243
|
const trigger = instance.provider.querySelector(
|
package/src/steps/Steps.astro
CHANGED
|
@@ -119,4 +119,9 @@ const { class: className, ...rest } = Astro.props;
|
|
|
119
119
|
background: var(--color-border);
|
|
120
120
|
opacity: 0.6;
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
/* A step's title on its own line, above its detail (format-astro and render-html mark it) */
|
|
124
|
+
.steps-list > :global(li) > :global(.step-title) {
|
|
125
|
+
display: block;
|
|
126
|
+
}
|
|
122
127
|
</style>
|
package/src/steps/SubSteps.astro
CHANGED
|
@@ -70,4 +70,9 @@ const { class: className, ...rest } = Astro.props;
|
|
|
70
70
|
background: var(--color-border);
|
|
71
71
|
opacity: 0.6;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
/* A step's title on its own line, above its detail (format-astro and render-html mark it) */
|
|
75
|
+
.sub-steps-list > :global(li) > :global(.step-title) {
|
|
76
|
+
display: block;
|
|
77
|
+
}
|
|
73
78
|
</style>
|
package/src/table/Table.astro
CHANGED
|
@@ -6,19 +6,33 @@ const tableContainer = tv({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
const table = tv({
|
|
9
|
-
base: "w-full caption-
|
|
9
|
+
base: "w-full caption-top text-sm",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
class?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional table caption, rendered as a `<caption>`: the table's title,
|
|
16
|
+
* above it and left-aligned.
|
|
17
|
+
* For a caption with markup, use the `caption` slot instead.
|
|
18
|
+
*/
|
|
19
|
+
caption?: string;
|
|
14
20
|
[key: string]: unknown;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
const { class: className, ...rest } = Astro.props;
|
|
23
|
+
const { class: className, caption, ...rest } = Astro.props;
|
|
24
|
+
|
|
25
|
+
// A table's caption is its title: above the table, left-aligned, in the body color
|
|
26
|
+
const captionClass = "mb-2 text-left text-sm font-medium text-foreground";
|
|
18
27
|
---
|
|
19
28
|
|
|
20
29
|
<div class={tableContainer()}>
|
|
21
30
|
<table class={table({ class: className })} {...rest}>
|
|
31
|
+
{Astro.slots.has("caption") ? (
|
|
32
|
+
<caption class={captionClass}><slot name="caption" /></caption>
|
|
33
|
+
) : (
|
|
34
|
+
caption && <caption class={captionClass}>{caption}</caption>
|
|
35
|
+
)}
|
|
22
36
|
<slot />
|
|
23
37
|
</table>
|
|
24
38
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
3
|
|
|
4
4
|
const tableHead = tv({
|
|
5
|
-
base: "
|
|
5
|
+
base: "px-2 py-2 text-left align-bottom font-semibold text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
@@ -99,40 +99,40 @@ const filtered = headings.filter(
|
|
|
99
99
|
line-height: 1.4;
|
|
100
100
|
}
|
|
101
101
|
.toc-kind-class {
|
|
102
|
-
background-color: oklch(0.
|
|
103
|
-
color: oklch(0.
|
|
102
|
+
background-color: oklch(0.44 0.18 265 / 0.15);
|
|
103
|
+
color: oklch(0.44 0.18 265);
|
|
104
104
|
}
|
|
105
105
|
:global(.dark) .toc-kind-class {
|
|
106
106
|
background-color: oklch(0.7 0.15 265 / 0.2);
|
|
107
107
|
color: oklch(0.7 0.15 265);
|
|
108
108
|
}
|
|
109
109
|
.toc-kind-meth {
|
|
110
|
-
background-color: oklch(0.
|
|
111
|
-
color: oklch(0.
|
|
110
|
+
background-color: oklch(0.44 0.15 155 / 0.15);
|
|
111
|
+
color: oklch(0.44 0.15 155);
|
|
112
112
|
}
|
|
113
113
|
:global(.dark) .toc-kind-meth {
|
|
114
114
|
background-color: oklch(0.7 0.15 155 / 0.2);
|
|
115
115
|
color: oklch(0.7 0.15 155);
|
|
116
116
|
}
|
|
117
117
|
.toc-kind-attr {
|
|
118
|
-
background-color: oklch(0.
|
|
119
|
-
color: oklch(0.
|
|
118
|
+
background-color: oklch(0.44 0.15 55 / 0.15);
|
|
119
|
+
color: oklch(0.44 0.15 55);
|
|
120
120
|
}
|
|
121
121
|
:global(.dark) .toc-kind-attr {
|
|
122
122
|
background-color: oklch(0.75 0.15 55 / 0.2);
|
|
123
123
|
color: oklch(0.75 0.15 55);
|
|
124
124
|
}
|
|
125
125
|
.toc-kind-func {
|
|
126
|
-
background-color: oklch(0.
|
|
127
|
-
color: oklch(0.
|
|
126
|
+
background-color: oklch(0.44 0.18 330 / 0.15);
|
|
127
|
+
color: oklch(0.44 0.18 330);
|
|
128
128
|
}
|
|
129
129
|
:global(.dark) .toc-kind-func {
|
|
130
130
|
background-color: oklch(0.7 0.15 330 / 0.2);
|
|
131
131
|
color: oklch(0.7 0.15 330);
|
|
132
132
|
}
|
|
133
133
|
.toc-kind-module {
|
|
134
|
-
background-color: oklch(0.
|
|
135
|
-
color: oklch(0.
|
|
134
|
+
background-color: oklch(0.44 0.12 200 / 0.15);
|
|
135
|
+
color: oklch(0.44 0.12 200);
|
|
136
136
|
}
|
|
137
137
|
:global(.dark) .toc-kind-module {
|
|
138
138
|
background-color: oklch(0.65 0.12 200 / 0.2);
|