@clarusjs/theme-docs 0.1.0 → 0.1.2
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 +3 -3
- package/src/callout.tscl +3 -2
- package/src/copy.tscl +1 -1
- package/src/layout.tscl +2 -0
- package/src/learn-status.tscl +3 -2
- package/src/lesson-bar.tscl +7 -5
- package/src/nav.ts +17 -11
- package/src/progress-board.tscl +3 -2
- package/src/progress.ts +1 -1
- package/src/quiz-choices.tscl +1 -1
- package/src/search.d.ts +3 -0
- package/src/search.js +4 -0
- package/src/search.tscl +8 -8
- package/src/theme.css +22 -3
- package/src/view-transitions.tscl +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clarusjs/theme-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A docs theme for clarusjs: layout with header, sidebar, content and on-this-page, design tokens, dark mode, copy buttons and callouts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"clarusjs": "^0.
|
|
19
|
+
"clarusjs": "^0.9.0"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": "^22.12.0 || ^24.0.0 || >=26.0.0"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^26.6.6",
|
|
42
|
-
"clarusjs": "^0.
|
|
42
|
+
"clarusjs": "^0.9.0",
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
44
|
"vitest": "^5.1.1",
|
|
45
45
|
"vite": "^8.3.8"
|
package/src/callout.tscl
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
@
|
|
1
|
+
@type Kind = 'tip' | 'info' | 'warning' | 'danger'
|
|
2
|
+
@input type: Kind = 'info'
|
|
2
3
|
|
|
3
4
|
<aside role="note" class="callout {{ type }}"><p class="callout-title"><slot name="title">{{ type[0].toUpperCase() + type.slice(1) }}</slot></p><slot /></aside>
|
|
4
5
|
|
|
5
|
-
<style>
|
|
6
|
+
<style scoped>
|
|
6
7
|
/* Scoped to this component: :scope is the <aside>; slot content inside it is styled too. */
|
|
7
8
|
:scope {
|
|
8
9
|
border-left: 3px solid var(--accent);
|
package/src/copy.tscl
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
const block = button.closest('.sample, .code-block')?.querySelector('code')
|
|
6
6
|
// Removed diff lines aren't part of the code to copy.
|
|
7
7
|
const clone = block?.cloneNode(true)
|
|
8
|
-
clone
|
|
8
|
+
if (clone instanceof Element) clone.querySelectorAll('.diff.remove').forEach((line) => {
|
|
9
9
|
if (line.nextSibling?.nodeType === 3 && line.nextSibling.textContent === '\n') line.nextSibling.remove() // its newline too
|
|
10
10
|
line.remove()
|
|
11
11
|
})
|
package/src/layout.tscl
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
Slots: sidebar-top, sidebar-bottom, content-top, content-bottom, footer.
|
|
6
6
|
--}}
|
|
7
7
|
@import themeToggle from './theme-toggle.tscl'
|
|
8
|
+
@import pageTransitions from './view-transitions.tscl'
|
|
8
9
|
@import siteSearch from './search.tscl'
|
|
9
10
|
@import pageHead from './page-head.tscl'
|
|
10
11
|
@import learnStatus from './learn-status.tscl'
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
}
|
|
61
62
|
{{-- Kept across fragment navigations: the same element, with its state. --}}
|
|
62
63
|
<span class="persist" data-cl-persist="theme"><themeToggle /></span>
|
|
64
|
+
@if (config.viewTransitions) {<span class="persist" data-cl-persist="view-transitions"><pageTransitions /></span>}
|
|
63
65
|
</div>
|
|
64
66
|
</header>
|
|
65
67
|
@if (sectionKey(config.sections, path)) {
|
package/src/learn-status.tscl
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
xp = s.xp
|
|
17
17
|
ready = true
|
|
18
18
|
for (const link of document.querySelectorAll('.sidebar ul a[href]')) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const href = link.getAttribute('href') ?? ''
|
|
20
|
+
if (!(link instanceof HTMLElement) || !lessons.includes(href)) continue
|
|
21
|
+
const status = s.status(href)
|
|
21
22
|
link.dataset.status = status
|
|
22
23
|
let note = link.querySelector('.status-note')
|
|
23
24
|
if (!note) {
|
package/src/lesson-bar.tscl
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
bar()?.classList.toggle('ok', kind === 'ok')
|
|
32
32
|
bar()?.classList.toggle('bad', kind === 'bad')
|
|
33
33
|
}
|
|
34
|
-
const steps = () => [...document.querySelectorAll('main .step')]
|
|
34
|
+
const steps = () => [...document.querySelectorAll('main .step')].filter((el) => el instanceof HTMLElement)
|
|
35
35
|
function show(i, focus) {
|
|
36
36
|
const all = steps()
|
|
37
37
|
if (!all.length) return
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
all.forEach((step, j) => { step.hidden = j !== current })
|
|
41
41
|
checking = !!all[current].querySelector('[data-quiz]:not([data-answered])')
|
|
42
42
|
verdict('', '', '')
|
|
43
|
-
const id = all[current].getAttribute('aria-labelledby')
|
|
43
|
+
const id = all[current].getAttribute('aria-labelledby') ?? ''
|
|
44
44
|
name = document.getElementById(id)?.textContent?.replace(/#$/, '').trim() ?? ''
|
|
45
45
|
document.querySelectorAll('.segments li').forEach((li, j) => {
|
|
46
46
|
li.className = j < current ? 'done' : j === current ? 'current' : ''
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
if (typeof document !== 'undefined' && steps().length) {
|
|
93
93
|
steps().forEach(split)
|
|
94
94
|
document.body.classList.add('one-step')
|
|
95
|
-
document.querySelector('.lesson-bar')
|
|
95
|
+
const lessonBar = document.querySelector('.lesson-bar')
|
|
96
|
+
if (lessonBar instanceof HTMLElement) lessonBar.hidden = false
|
|
96
97
|
// A #hash opens the step it points into and keeps its target: a step heading takes focus, anything else
|
|
97
98
|
// scrolls into view (Back and Continue go by step headings instead).
|
|
98
99
|
function reveal() {
|
|
@@ -106,10 +107,11 @@
|
|
|
106
107
|
}
|
|
107
108
|
if (!reveal()) show(0, false)
|
|
108
109
|
document.addEventListener('quiz:result', (event) => {
|
|
109
|
-
if (!steps()[current]?.contains(event.target)) return
|
|
110
|
+
if (!(event instanceof CustomEvent) || !(event.target instanceof HTMLElement) || !steps()[current]?.contains(event.target)) return
|
|
110
111
|
const { ok, done, text: detail } = event.detail
|
|
111
112
|
if (!done) return verdict('', 'Pick an answer', detail)
|
|
112
|
-
|
|
113
|
+
const quiz = event.target.dataset.quiz
|
|
114
|
+
record((p) => answer(p, lesson + '#' + quiz, ok))
|
|
113
115
|
checking = !!steps()[current].querySelector('[data-quiz]:not([data-answered])')
|
|
114
116
|
verdict(ok ? 'ok' : 'bad', ok ? 'Correct!' : 'Not quite', detail)
|
|
115
117
|
})
|
package/src/nav.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// The theme's settings and the navigation helpers the layout uses. Server-only: the layout is static HTML.
|
|
1
|
+
// The theme's settings and the navigation helpers the layout uses. Server-only: the layout is static HTML. Lists are
|
|
2
|
+
// readonly, as a template's inputs are: the layout passes its config to these helpers as it gets it.
|
|
2
3
|
|
|
3
4
|
/** A sidebar entry; `order` sorts it within its group (lowest first, then by title). */
|
|
4
5
|
export type Item = { title: string; href: string; order?: number }
|
|
5
|
-
export type Group = { title: string; items: Item[] }
|
|
6
|
+
export type Group = { title: string; items: readonly Item[] }
|
|
6
7
|
/** A top-level part of the docs (Guide, Reference): its own sidebar groups. */
|
|
7
|
-
export type Section = { key: string; title: string; href: string; groups: Group[] }
|
|
8
|
+
export type Section = { key: string; title: string; href: string; groups: readonly Group[] }
|
|
8
9
|
export type Social = { label: string; href: string; icon: 'github' | 'npm' | 'link' }
|
|
9
10
|
/** A heading on the page, for "On this page". */
|
|
10
11
|
export type Heading = { id: string; text: string; level: number }
|
|
@@ -14,16 +15,16 @@ export type ThemeConfig = {
|
|
|
14
15
|
brand: { text: string; accent?: string; logo?: string }
|
|
15
16
|
/** The site's public address, for structured data (no trailing slash). */
|
|
16
17
|
siteUrl?: string
|
|
17
|
-
sections: Section[]
|
|
18
|
+
sections: readonly Section[]
|
|
18
19
|
/** Icon links at the right of the header (GitHub, npm…). */
|
|
19
|
-
social?: Social[]
|
|
20
|
+
social?: readonly Social[]
|
|
20
21
|
/**
|
|
21
22
|
* "Edit this page": a pattern where `:file` is the page's source file under src/pages (`guide/start.md`, found in
|
|
22
23
|
* `pages`), or a function of the route (the page's source route, for dynamic pages). None without it.
|
|
23
24
|
*/
|
|
24
25
|
editLink?: string | ((path: string) => string)
|
|
25
26
|
/** The pages as themeDocs() reads them: source files for `editLink` patterns, and "Last updated" dates. */
|
|
26
|
-
pages?: PageInfo[]
|
|
27
|
+
pages?: readonly PageInfo[]
|
|
27
28
|
/**
|
|
28
29
|
* Learn: the section whose pages are lessons, and its progress page (not a lesson). Progress, XP and badges are
|
|
29
30
|
* kept in the browser (localStorage); an XP chip shows in lesson headers and on the section's pages.
|
|
@@ -31,6 +32,11 @@ export type ThemeConfig = {
|
|
|
31
32
|
learn?: { section: string; progress: string }
|
|
32
33
|
/** A search button (and Ctrl/⌘K, /) in the header; the index comes from the themeDocs() Vite plugin. */
|
|
33
34
|
search?: boolean
|
|
35
|
+
/**
|
|
36
|
+
* Page changes animate as view transitions where the browser has them (a cross-fade; `::view-transition-*` rules in
|
|
37
|
+
* the site's CSS change it). Needs fragment navigation or client routes; no animation with reduced motion.
|
|
38
|
+
*/
|
|
39
|
+
viewTransitions?: boolean
|
|
34
40
|
/** The site footer's text. */
|
|
35
41
|
footer?: string
|
|
36
42
|
}
|
|
@@ -39,24 +45,24 @@ const none: Item = { title: '', href: '' }
|
|
|
39
45
|
const flat = (section: Section) => section.groups.flatMap((g) => g.items)
|
|
40
46
|
|
|
41
47
|
/** The section a page belongs to ('' for pages outside every section, like a home page). */
|
|
42
|
-
export function sectionKey(sections: Section[], path: string): string {
|
|
48
|
+
export function sectionKey(sections: readonly Section[], path: string): string {
|
|
43
49
|
return sections.find((s) => flat(s).some((i) => i.href === path))?.key ?? ''
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/** Sidebar groups for the page's section (none outside the sections). */
|
|
47
|
-
export function groupsOf(sections: Section[], path: string): Group[] {
|
|
53
|
+
export function groupsOf(sections: readonly Section[], path: string): readonly Group[] {
|
|
48
54
|
return sections.find((s) => s.key === sectionKey(sections, path))?.groups ?? []
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
/** "Guide › Templates" */
|
|
52
|
-
export function crumb(sections: Section[], path: string): string {
|
|
58
|
+
export function crumb(sections: readonly Section[], path: string): string {
|
|
53
59
|
const section = sections.find((s) => s.key === sectionKey(sections, path))
|
|
54
60
|
const group = section?.groups.find((g) => g.items.some((i) => i.href === path))
|
|
55
61
|
return section && group ? `${section.title} › ${group.title}` : ''
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/** Previous and next pages in sidebar order; an empty item (href '') when there is none. */
|
|
59
|
-
export function pager(sections: Section[], path: string): { prev: Item; next: Item } {
|
|
65
|
+
export function pager(sections: readonly Section[], path: string): { prev: Item; next: Item } {
|
|
60
66
|
const section = sections.find((s) => s.key === sectionKey(sections, path))
|
|
61
67
|
const items = section ? flat(section) : []
|
|
62
68
|
const i = items.findIndex((item) => item.href === path)
|
|
@@ -74,7 +80,7 @@ export type PageInfo = { href: string; title: string; file: string; group?: stri
|
|
|
74
80
|
* section's title), sorted by `order`, then title. The config wins: its groups come first and its items replace pages
|
|
75
81
|
* with the same href, so it can rename, reorder and add (non-page) entries. An empty section `href` means its first page.
|
|
76
82
|
*/
|
|
77
|
-
export function pagesNav(sections: Section[], pages: PageInfo[]): Section[] {
|
|
83
|
+
export function pagesNav(sections: readonly Section[], pages: readonly PageInfo[]): Section[] {
|
|
78
84
|
return sections.map((section) => {
|
|
79
85
|
const groups = section.groups.map((g) => ({ title: g.title, items: [...g.items] }))
|
|
80
86
|
const listed = new Set(groups.flatMap((g) => g.items.map((i) => i.href)))
|
package/src/progress-board.tscl
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Your progress, read from this browser: XP, lessons done, quiz accuracy, badges and each lesson's state, with Reset.
|
|
3
3
|
Without JavaScript (or with storage blocked) it says so; the lessons are still links.
|
|
4
4
|
--}}
|
|
5
|
-
@
|
|
5
|
+
@interface Lesson { title: string; href: string }
|
|
6
|
+
@input lessons: Lesson[]
|
|
6
7
|
|
|
7
8
|
<script>
|
|
8
9
|
import { load, reset, save, stats } from './progress.ts'
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
let done = state(0)
|
|
11
12
|
let accuracy = state('')
|
|
12
13
|
let badges = state([])
|
|
13
|
-
let statuses = state(
|
|
14
|
+
let statuses = state(Object.create(null)) // lesson href → its status
|
|
14
15
|
let mode = state('waiting')
|
|
15
16
|
let confirming = state(false)
|
|
16
17
|
function refresh() {
|
package/src/progress.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type Stats = {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/** XP (10 a step, 50 a lesson, 20 a quiz right the first time), counts and badges, for the lessons of a path. */
|
|
72
|
-
export function stats(p: Progress, lessons: string[]): Stats {
|
|
72
|
+
export function stats(p: Progress, lessons: readonly string[]): Stats {
|
|
73
73
|
const done = lessons.filter((l) => p.done.includes(l)).length
|
|
74
74
|
const steps = lessons.reduce((n, l) => n + (p.steps[l]?.length ?? 0), 0)
|
|
75
75
|
const answers = Object.values(p.quizzes)
|
package/src/quiz-choices.tscl
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
detail = { ok, done: true, text: ok ? 'Correct.' : 'The answer is: ' + options[answer] + '.' }
|
|
25
25
|
quiz()?.setAttribute('data-answered', ok ? 'right' : 'wrong')
|
|
26
26
|
const details = quiz()?.querySelector('.quiz-answer')
|
|
27
|
-
if (details) details.open = true
|
|
27
|
+
if (details instanceof HTMLDetailsElement) details.open = true
|
|
28
28
|
}
|
|
29
29
|
quiz()?.dispatchEvent(new CustomEvent('quiz:result', { bubbles: true, detail }))
|
|
30
30
|
}
|
package/src/search.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export type Section = {
|
|
|
10
10
|
*/
|
|
11
11
|
/** Sections per `s-<n>.json` file. */
|
|
12
12
|
export declare const CHUNK = 64;
|
|
13
|
+
/** The site's base path ('/' unless Vite's `base` is set), where the search index is fetched from. */
|
|
14
|
+
/** @type {string} */
|
|
15
|
+
export declare const base: string;
|
|
13
16
|
/** @param {string} text @returns {string[]} lowercase words of two or more letters, accents folded */
|
|
14
17
|
export declare function tokens(text: string): string[];
|
|
15
18
|
/** @param {string} word */
|
package/src/search.js
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
/** Sections per `s-<n>.json` file. */
|
|
14
14
|
export const CHUNK = 64
|
|
15
15
|
|
|
16
|
+
/** The site's base path ('/' unless Vite's `base` is set), where the search index is fetched from. */
|
|
17
|
+
/** @type {string} */
|
|
18
|
+
export const base = /** @type {any} */ (import.meta).env?.BASE_URL ?? '/' // Vite's import.meta.env, when there is one
|
|
19
|
+
|
|
16
20
|
/** @param {string} text @returns {string[]} lowercase words of two or more letters, accents folded */
|
|
17
21
|
export function tokens(text) {
|
|
18
22
|
return (text.normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase().match(/[a-z0-9]+/g) ?? []).filter((w) => w.length > 1)
|
package/src/search.tscl
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
themeDocs() writes at build time; a query fetches only the files it needs.
|
|
5
5
|
--}}
|
|
6
6
|
<script>
|
|
7
|
-
import {
|
|
7
|
+
import { navigate } from 'clarusjs/navigation'
|
|
8
|
+
import { base, search } from './search.js'
|
|
8
9
|
let query = state('')
|
|
9
10
|
let results = state([])
|
|
10
11
|
let active = state(0)
|
|
11
12
|
let searched = state(false)
|
|
12
13
|
const status = derived(() => !searched ? '' : results.length === 0 ? 'No results for "' + query + '"' : results.length === 1 ? '1 result' : results.length + ' results')
|
|
13
|
-
const base = import.meta.env?.BASE_URL ?? '/'
|
|
14
14
|
const load = (file) => fetch(base + 'search/' + file).then((r) => (r.ok ? r.json() : {}))
|
|
15
15
|
let latest = 0
|
|
16
16
|
async function run(value) {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
active = 0
|
|
23
23
|
searched = value.trim() !== ''
|
|
24
24
|
}
|
|
25
|
-
const dialog = () => document.querySelector('.search-dialog')
|
|
25
|
+
const dialog = () => { const d = document.querySelector('.search-dialog'); return d instanceof HTMLDialogElement ? d : null }
|
|
26
26
|
function open() {
|
|
27
27
|
const d = dialog()
|
|
28
28
|
if (!d || d.open) return
|
|
29
29
|
d.showModal()
|
|
30
|
-
d.querySelector('input')
|
|
30
|
+
d.querySelector('input')?.select()
|
|
31
31
|
}
|
|
32
32
|
function move(by) {
|
|
33
33
|
if (!results.length) return
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
function key(event) {
|
|
38
38
|
if (event.key === 'ArrowDown') { event.preventDefault(); move(1) }
|
|
39
39
|
else if (event.key === 'ArrowUp') { event.preventDefault(); move(-1) }
|
|
40
|
-
else if (event.key === 'Enter' && results.length) { event.preventDefault();
|
|
40
|
+
else if (event.key === 'Enter' && results.length) { event.preventDefault(); dialog()?.close(); navigate(results[active].u) }
|
|
41
41
|
// One Escape closes (a search field would only clear itself first).
|
|
42
|
-
else if (event.key === 'Escape') { event.preventDefault(); dialog()
|
|
42
|
+
else if (event.key === 'Escape') { event.preventDefault(); dialog()?.close() }
|
|
43
43
|
}
|
|
44
44
|
if (typeof document !== 'undefined') {
|
|
45
45
|
document.addEventListener('keydown', (event) => {
|
|
46
|
-
const typing = event.target.closest
|
|
46
|
+
const typing = event.target instanceof Element && event.target.closest('input, textarea, select, [contenteditable]')
|
|
47
47
|
if ((event.key === 'k' && (event.metaKey || event.ctrlKey)) || (event.key === '/' && !typing)) {
|
|
48
48
|
event.preventDefault()
|
|
49
49
|
open()
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
<kbd aria-hidden="true">⌘K</kbd>
|
|
60
60
|
</button>
|
|
61
61
|
{{-- A click on the backdrop (the dialog itself, outside its box) closes it; so does choosing a result. --}}
|
|
62
|
-
<dialog class="search-dialog" aria-label="Search the docs" (click)="($event.target.matches('dialog') || $event.target.closest('a')) && dialog()
|
|
62
|
+
<dialog class="search-dialog" aria-label="Search the docs" (click)="($event.target.matches('dialog') || $event.target.closest('a')) && dialog()?.close()">
|
|
63
63
|
<div class="search-box">
|
|
64
64
|
<input type="search" role="combobox" aria-label="Search the docs" aria-controls="search-results" aria-autocomplete="list" [aria-expanded]="results.length ? 'true' : 'false'" [aria-activedescendant]="results.length ? 'search-result-' + active : false" placeholder="Search the docs" autocomplete="off" spellcheck="false" (input)="run($event.target.value)" (keydown)="key($event)">
|
|
65
65
|
<p class="search-status" role="status">{{ status }}</p>
|
package/src/theme.css
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* @clarusjs/theme-docs: a quiet reading layout. Every colour, font and size is a custom property on :root (tokens). */
|
|
2
2
|
:root {
|
|
3
3
|
--header-height: 64px;
|
|
4
|
+
--page-width: 1440px; /* the header, sidebar, content and contents columns together */
|
|
4
5
|
--sidebar-width: 260px;
|
|
5
6
|
--toc-width: 220px;
|
|
6
7
|
--bg: #fbfcfc;
|
|
@@ -80,7 +81,10 @@ a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outlin
|
|
|
80
81
|
align-items: center;
|
|
81
82
|
gap: 12px 24px;
|
|
82
83
|
background: var(--bg);
|
|
83
|
-
|
|
84
|
+
/* Its content lines up with the page below (.docs, at most --page-width wide), not the window's edges. */
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
min-height: var(--header-height); /* what the sticky sidebar and contents sit under */
|
|
87
|
+
padding: 0 max(16px, env(safe-area-inset-right, 0px), calc((100% - var(--page-width)) / 2 + 16px)) 0 max(16px, env(safe-area-inset-left, 0px), calc((100% - var(--page-width)) / 2 + 16px));
|
|
84
88
|
border-bottom: 1px solid var(--rule);
|
|
85
89
|
}
|
|
86
90
|
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 650; font-size: 18px; }
|
|
@@ -137,7 +141,7 @@ pre code { background: none; padding: 0; font-size: 14px; line-height: 1.55; }
|
|
|
137
141
|
.site-header nav { align-items: center; }
|
|
138
142
|
|
|
139
143
|
/* Docs pages: sidebar, content and "On this page" (from 1280px a column, below that a box above the content). */
|
|
140
|
-
.docs { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width); max-width:
|
|
144
|
+
.docs { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width); max-width: var(--page-width); margin: 0 auto; }
|
|
141
145
|
.docs .content { margin: 0; max-width: 760px; min-width: 0; }
|
|
142
146
|
.sidebar { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 28px 16px 40px max(16px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--rule); }
|
|
143
147
|
.sidebar .group { margin: 20px 0 6px; font-size: 13px; font-weight: 650; color: var(--fg); }
|
|
@@ -195,7 +199,8 @@ th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rul
|
|
|
195
199
|
.search-text { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
|
196
200
|
|
|
197
201
|
/* The sidebar is a popover (so it can be a drawer on small screens): shown in place from 1024px. */
|
|
198
|
-
|
|
202
|
+
/* inset first: it would reset top. */
|
|
203
|
+
.sidebar[popover] { display: block; position: sticky; inset: auto; top: var(--header-height); width: auto; height: auto; max-height: calc(100vh - var(--header-height)); margin: 0; border: 0; border-right: 1px solid var(--rule); background: transparent; color: inherit; overflow-y: auto; }
|
|
199
204
|
.sidebar-head, .sidebar-links { display: none; }
|
|
200
205
|
|
|
201
206
|
/* On this page */
|
|
@@ -338,3 +343,17 @@ details.custom-block[open] > summary { margin-bottom: 8px; }
|
|
|
338
343
|
.badges em { margin-left: auto; font-style: normal; font-size: 13px; font-weight: 700; }
|
|
339
344
|
.progress-lessons li[data-status="done"] a::after { content: ' ✓'; color: var(--ok); }
|
|
340
345
|
.progress-reset { margin-top: 16px; min-height: 44px; padding: 0 16px; border: 1px solid var(--bad); border-radius: 10px; background: transparent; color: var(--bad); font: inherit; font-weight: 600; cursor: pointer; }
|
|
346
|
+
|
|
347
|
+
/* While a page change runs (fragments or the client router set data-cl-navigating on <html>): a thin bar at the top.
|
|
348
|
+
Shown after a short delay, so fast swaps don't flash it. */
|
|
349
|
+
html[data-cl-navigating]::before {
|
|
350
|
+
content: ''; position: fixed; inset: 0 auto auto 0; z-index: 20; height: 3px; width: 100%; background: var(--accent);
|
|
351
|
+
transform-origin: left; animation: cl-navigating 8s cubic-bezier(0.1, 0.7, 0.2, 1) 150ms both;
|
|
352
|
+
}
|
|
353
|
+
@keyframes cl-navigating { from { transform: scaleX(0); } to { transform: scaleX(0.9); } }
|
|
354
|
+
@media (prefers-reduced-motion: reduce) { html[data-cl-navigating]::before { animation: none; transform: scaleX(1); opacity: 0.6; } }
|
|
355
|
+
|
|
356
|
+
/* View transitions (config.viewTransitions): the default cross-fade, none with reduced motion. */
|
|
357
|
+
@media (prefers-reduced-motion: reduce) {
|
|
358
|
+
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; }
|
|
359
|
+
}
|