@abreen/tada 1.6.0 → 1.6.4
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/build/bundle.ts +11 -1
- package/build/external-links-plugin.ts +181 -22
- package/build/utils/derive-theme.ts +8 -0
- package/build/utils/markdown.ts +41 -12
- package/build/utils/render.ts +15 -0
- package/init/content/markdown.md +11 -3
- package/package.json +1 -1
- package/src/_alerts.scss +11 -6
- package/src/_base.scss +7 -10
- package/src/_layout.scss +23 -1
- package/src/_mixins.scss +41 -0
- package/src/anchor/style.scss +17 -24
- package/src/header/_base.scss +8 -0
- package/src/header/index.ts +12 -0
- package/src/header/style.scss +1 -18
- package/src/index.ts +12 -0
- package/src/navigate/index.ts +47 -29
- package/src/print/style.scss +1 -1
- package/src/style.scss +44 -50
- package/src/toc/index.ts +1 -1
- package/src/toc/style.scss +4 -33
- package/src/top/index.ts +6 -2
- package/templates/_theme.scss +11 -24
- package/templates/_top.html +2 -0
package/src/anchor/style.scss
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
@use '../mixins' as *;
|
|
2
|
+
|
|
3
|
+
a.heading-anchor {
|
|
2
4
|
position: relative;
|
|
3
5
|
display: inline-block;
|
|
4
|
-
|
|
5
|
-
text-decoration: none;
|
|
6
|
+
@include subdued-link;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
.heading-anchor::after {
|
|
9
|
-
content:
|
|
9
|
+
a.heading-anchor::after {
|
|
10
|
+
content: '';
|
|
10
11
|
display: inline-block;
|
|
11
|
-
height:
|
|
12
|
-
width:
|
|
12
|
+
height: 1em;
|
|
13
|
+
width: 1em;
|
|
13
14
|
margin-left: 4px;
|
|
15
|
+
vertical-align: middle;
|
|
14
16
|
opacity: 0;
|
|
17
|
+
@include contained-mask(var(--icon-anchor));
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
.heading-anchor:focus::after
|
|
18
|
-
.heading-anchor:focus-visible::after {
|
|
20
|
+
a.heading-anchor:focus-visible::after {
|
|
19
21
|
opacity: 1;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@media (hover: hover) {
|
|
23
|
-
h1:hover .heading-anchor::after,
|
|
24
|
-
h2:hover .heading-anchor::after,
|
|
25
|
-
h3:hover .heading-anchor::after,
|
|
26
|
-
h4:hover .heading-anchor::after,
|
|
27
|
-
h5:hover .heading-anchor::after,
|
|
28
|
-
h6:hover .heading-anchor::after {
|
|
25
|
+
h1:hover a.heading-anchor::after,
|
|
26
|
+
h2:hover a.heading-anchor::after,
|
|
27
|
+
h3:hover a.heading-anchor::after,
|
|
28
|
+
h4:hover a.heading-anchor::after,
|
|
29
|
+
h5:hover a.heading-anchor::after,
|
|
30
|
+
h6:hover a.heading-anchor::after {
|
|
29
31
|
opacity: 1;
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
h1:hover .heading-anchor,
|
|
33
|
-
h2:hover .heading-anchor,
|
|
34
|
-
h3:hover .heading-anchor,
|
|
35
|
-
h4:hover .heading-anchor,
|
|
36
|
-
h5:hover .heading-anchor,
|
|
37
|
-
h6:hover .heading-anchor {
|
|
38
|
-
color: var(--fg-color);
|
|
39
|
-
}
|
|
40
33
|
}
|
package/src/header/_base.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use '../mixins' as *;
|
|
2
|
+
|
|
1
3
|
:root {
|
|
2
4
|
--header-collapsed-height: 45px;
|
|
3
5
|
}
|
|
@@ -31,6 +33,12 @@ header details summary {
|
|
|
31
33
|
@media (hover: hover) {
|
|
32
34
|
&:hover {
|
|
33
35
|
color: inherit;
|
|
36
|
+
text-decoration-line: none;
|
|
37
|
+
background: var(--bg2-color);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:hover .site-title {
|
|
41
|
+
@include link-underline;
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
|
package/src/header/index.ts
CHANGED
|
@@ -35,9 +35,21 @@ export default (window: Window) => {
|
|
|
35
35
|
}
|
|
36
36
|
window.addEventListener('keydown', handleWindowKeyDown);
|
|
37
37
|
|
|
38
|
+
function handleDetailsFocusOut(e: FocusEvent) {
|
|
39
|
+
if (!details.open) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const next = e.relatedTarget as Node | null;
|
|
43
|
+
if (!next || !details.contains(next)) {
|
|
44
|
+
close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
details.addEventListener('focusout', handleDetailsFocusOut);
|
|
48
|
+
|
|
38
49
|
return () => {
|
|
39
50
|
window.removeEventListener('keydown', handleWindowKeyDown);
|
|
40
51
|
window.removeEventListener('click', handleWindowClick);
|
|
41
52
|
details.removeEventListener('click', handleDetailsClick);
|
|
53
|
+
details.removeEventListener('focusout', handleDetailsFocusOut);
|
|
42
54
|
};
|
|
43
55
|
};
|
package/src/header/style.scss
CHANGED
|
@@ -26,20 +26,7 @@ header nav ul li {
|
|
|
26
26
|
header nav a {
|
|
27
27
|
border: none;
|
|
28
28
|
display: inline;
|
|
29
|
-
|
|
30
|
-
text-decoration: none;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@media (hover: hover) {
|
|
34
|
-
header nav a {
|
|
35
|
-
&:hover {
|
|
36
|
-
color: var(--fg2-color);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:active {
|
|
40
|
-
color: var(--link-active-color);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
29
|
+
@include subdued-link;
|
|
43
30
|
}
|
|
44
31
|
|
|
45
32
|
header nav a.external {
|
|
@@ -60,10 +47,6 @@ header nav div > p {
|
|
|
60
47
|
}
|
|
61
48
|
|
|
62
49
|
@media (hover: hover) {
|
|
63
|
-
header details summary:hover {
|
|
64
|
-
background: var(--bg2-color);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
50
|
header:has(details[open]):hover {
|
|
68
51
|
background: var(--bg-color-translucent);
|
|
69
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -59,6 +59,18 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
59
59
|
// Mount per-page components
|
|
60
60
|
await mountPerPageComponents(window);
|
|
61
61
|
|
|
62
|
+
// On reload with manual scrollRestoration, browsers skip the initial
|
|
63
|
+
// fragment scroll. Do it ourselves once per-page components have
|
|
64
|
+
// finished mutating the DOM. On a fresh cold load the browser already
|
|
65
|
+
// scrolled, so this is a harmless re-align.
|
|
66
|
+
if (window.location.hash) {
|
|
67
|
+
const id = window.location.hash.slice(1);
|
|
68
|
+
const el = window.document.getElementById(id);
|
|
69
|
+
if (el) {
|
|
70
|
+
el.scrollIntoView();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
for (const [name, reason] of Object.entries(failed)) {
|
|
63
75
|
console.error(`Failed to mount ${name} component:`, reason);
|
|
64
76
|
}
|
package/src/navigate/index.ts
CHANGED
|
@@ -5,6 +5,11 @@ let currentAbortController: AbortController | null = null;
|
|
|
5
5
|
let historyIndex = 0;
|
|
6
6
|
let currentPath = '';
|
|
7
7
|
|
|
8
|
+
// In-memory scroll positions keyed by navIndex. Populated on scroll and
|
|
9
|
+
// consulted by handlePopState so returning to a previous entry via
|
|
10
|
+
// back/forward restores the user's scroll, not just scroll 0.
|
|
11
|
+
const scrollByIndex = new Map<number, number>();
|
|
12
|
+
|
|
8
13
|
type Direction = 'forward' | 'back';
|
|
9
14
|
|
|
10
15
|
function findAnchor(event: MouseEvent): HTMLAnchorElement | null {
|
|
@@ -145,27 +150,35 @@ async function performNavigation(
|
|
|
145
150
|
teardownPerPageComponents();
|
|
146
151
|
swapContent(newDoc);
|
|
147
152
|
updateHead(newDoc);
|
|
153
|
+
const parsed = new URL(url);
|
|
154
|
+
currentPath = parsed.pathname + parsed.search;
|
|
155
|
+
|
|
148
156
|
if (isPush) {
|
|
149
157
|
historyIndex++;
|
|
150
|
-
|
|
158
|
+
// Push without the hash; we add it back below via location.replace
|
|
159
|
+
// so the browser performs a real fragment navigation that updates
|
|
160
|
+
// :target and fires hashchange. pushState alone would not do
|
|
161
|
+
// either of those things.
|
|
162
|
+
const urlWithoutHash = parsed.origin + parsed.pathname + parsed.search;
|
|
163
|
+
window.history.pushState({ navIndex: historyIndex }, '', urlWithoutHash);
|
|
151
164
|
}
|
|
152
|
-
const parsed = new URL(url);
|
|
153
|
-
currentPath = parsed.pathname + parsed.search;
|
|
154
165
|
|
|
155
166
|
if (typeof scrollTarget === 'string') {
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
// Trigger a real fragment navigation. location.replace overwrites
|
|
168
|
+
// the current entry's URL in place and runs fragment navigation
|
|
169
|
+
// (updating :target, firing hashchange, scrolling to the element).
|
|
170
|
+
// It wipes the entry's state object, so reapply it via
|
|
171
|
+
// replaceState.
|
|
172
|
+
const urlWithHash = parsed.pathname + parsed.search + '#' + scrollTarget;
|
|
173
|
+
window.location.replace(urlWithHash);
|
|
174
|
+
window.history.replaceState({ navIndex: historyIndex }, '', urlWithHash);
|
|
163
175
|
} else if (typeof scrollTarget === 'number') {
|
|
164
176
|
// Restore scroll position (popstate)
|
|
165
177
|
window.scrollTo({ top: scrollTarget });
|
|
166
178
|
} else {
|
|
167
179
|
window.scrollTo({ top: 0 });
|
|
168
180
|
}
|
|
181
|
+
scrollByIndex.set(historyIndex, window.scrollY);
|
|
169
182
|
};
|
|
170
183
|
|
|
171
184
|
const doc = document as Document & {
|
|
@@ -261,6 +274,16 @@ async function performNavigation(
|
|
|
261
274
|
export default function mountNavigate(window: Window): () => void {
|
|
262
275
|
window.history.scrollRestoration = 'manual';
|
|
263
276
|
currentPath = window.location.pathname + window.location.search;
|
|
277
|
+
scrollByIndex.set(historyIndex, window.scrollY);
|
|
278
|
+
|
|
279
|
+
// Track scroll position on every scroll event. We keep the latest
|
|
280
|
+
// scrollY per navIndex so that back/forward navigation can restore
|
|
281
|
+
// where the user was, not just scroll 0. Map writes are cheap; no
|
|
282
|
+
// need to debounce.
|
|
283
|
+
const saveScroll = () => {
|
|
284
|
+
scrollByIndex.set(historyIndex, window.scrollY);
|
|
285
|
+
};
|
|
286
|
+
window.addEventListener('scroll', saveScroll, { passive: true });
|
|
264
287
|
|
|
265
288
|
function handleClick(event: MouseEvent) {
|
|
266
289
|
const anchor = findAnchor(event);
|
|
@@ -278,7 +301,8 @@ export default function mountNavigate(window: Window): () => void {
|
|
|
278
301
|
return;
|
|
279
302
|
}
|
|
280
303
|
|
|
281
|
-
// Same-page hash links:
|
|
304
|
+
// Same-page hash links: handle locally so we can clear search and
|
|
305
|
+
// close the header without a full SPA fetch.
|
|
282
306
|
const url = new URL(anchor.href);
|
|
283
307
|
if (
|
|
284
308
|
url.pathname === window.location.pathname &&
|
|
@@ -293,11 +317,11 @@ export default function mountNavigate(window: Window): () => void {
|
|
|
293
317
|
details.open = false;
|
|
294
318
|
}
|
|
295
319
|
if (url.hash) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
320
|
+
// location.hash assignment performs a real fragment navigation:
|
|
321
|
+
// updates :target, fires hashchange (which the TOC listens for),
|
|
322
|
+
// creates a new history entry, and scrolls to the element.
|
|
323
|
+
// pushState would do none of those things.
|
|
324
|
+
window.location.hash = url.hash.slice(1);
|
|
301
325
|
}
|
|
302
326
|
return;
|
|
303
327
|
}
|
|
@@ -314,15 +338,8 @@ export default function mountNavigate(window: Window): () => void {
|
|
|
314
338
|
details.open = false;
|
|
315
339
|
}
|
|
316
340
|
|
|
317
|
-
// Save current scroll position
|
|
318
|
-
window.
|
|
319
|
-
{
|
|
320
|
-
...window.history.state,
|
|
321
|
-
scrollY: window.scrollY,
|
|
322
|
-
navIndex: historyIndex,
|
|
323
|
-
},
|
|
324
|
-
'',
|
|
325
|
-
);
|
|
341
|
+
// Save current scroll position for the entry we're leaving
|
|
342
|
+
scrollByIndex.set(historyIndex, window.scrollY);
|
|
326
343
|
|
|
327
344
|
const hash = url.hash ? url.hash.slice(1) : null;
|
|
328
345
|
|
|
@@ -337,23 +354,23 @@ export default function mountNavigate(window: Window): () => void {
|
|
|
337
354
|
if (hash) {
|
|
338
355
|
const el = window.document.getElementById(hash);
|
|
339
356
|
if (el) {
|
|
340
|
-
el.scrollIntoView(
|
|
357
|
+
el.scrollIntoView();
|
|
341
358
|
}
|
|
342
359
|
} else {
|
|
343
|
-
window.scrollTo({ top: 0
|
|
360
|
+
window.scrollTo({ top: 0 });
|
|
344
361
|
}
|
|
345
362
|
return;
|
|
346
363
|
}
|
|
347
364
|
currentPath = newPath;
|
|
348
365
|
|
|
349
|
-
const scrollY = event.state?.scrollY ?? null;
|
|
350
366
|
const targetIndex = event.state?.navIndex ?? 0;
|
|
351
367
|
const direction: Direction =
|
|
352
368
|
targetIndex >= historyIndex ? 'forward' : 'back';
|
|
353
369
|
historyIndex = targetIndex;
|
|
370
|
+
const savedY = scrollByIndex.get(targetIndex);
|
|
354
371
|
performNavigation(
|
|
355
372
|
window.location.href,
|
|
356
|
-
typeof
|
|
373
|
+
typeof savedY === 'number' ? savedY : null,
|
|
357
374
|
direction,
|
|
358
375
|
false,
|
|
359
376
|
);
|
|
@@ -367,5 +384,6 @@ export default function mountNavigate(window: Window): () => void {
|
|
|
367
384
|
return () => {
|
|
368
385
|
window.document.removeEventListener('click', handleClick, true);
|
|
369
386
|
window.removeEventListener('popstate', handlePopState);
|
|
387
|
+
window.removeEventListener('scroll', saveScroll);
|
|
370
388
|
};
|
|
371
389
|
}
|
package/src/print/style.scss
CHANGED
package/src/style.scss
CHANGED
|
@@ -55,42 +55,23 @@ a.disabled {
|
|
|
55
55
|
@media (hover: hover) {
|
|
56
56
|
&:hover {
|
|
57
57
|
color: var(--fg-color-translucent);
|
|
58
|
+
text-decoration-line: none;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
background: var(--icon-external-link);
|
|
65
|
-
background-size: contain;
|
|
66
|
-
background-repeat: no-repeat;
|
|
67
|
-
background-position: center center;
|
|
68
|
-
margin-left: 4px;
|
|
69
|
-
padding-right: 18px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@media (hover: hover) {
|
|
73
|
-
a.external:hover::after {
|
|
74
|
-
background: var(--icon-external-link-hover);
|
|
75
|
-
background-size: contain;
|
|
76
|
-
background-repeat: no-repeat;
|
|
77
|
-
background-position: center center;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
a.external:active::after {
|
|
82
|
-
background: var(--icon-external-link-active) !important;
|
|
83
|
-
background-size: contain !important;
|
|
84
|
-
background-repeat: no-repeat !important;
|
|
85
|
-
background-position: center center !important;
|
|
63
|
+
.external-link-tail {
|
|
64
|
+
white-space: nowrap;
|
|
86
65
|
}
|
|
87
66
|
|
|
88
|
-
|
|
89
|
-
a.external.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
.external-link-tail::after,
|
|
68
|
+
a.external:not(:has(.external-link-tail))::after {
|
|
69
|
+
content: '';
|
|
70
|
+
display: inline-block;
|
|
71
|
+
width: 1em;
|
|
72
|
+
height: 1em;
|
|
73
|
+
vertical-align: middle;
|
|
74
|
+
@include contained-mask(var(--icon-external-link));
|
|
94
75
|
}
|
|
95
76
|
|
|
96
77
|
.footnotes {
|
|
@@ -110,14 +91,34 @@ a.external.disabled:active::after {
|
|
|
110
91
|
margin: 0;
|
|
111
92
|
}
|
|
112
93
|
|
|
94
|
+
.footnotes ol {
|
|
95
|
+
list-style: none;
|
|
96
|
+
padding-left: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
113
99
|
.footnotes li {
|
|
100
|
+
position: relative;
|
|
101
|
+
padding-left: 1.8em;
|
|
114
102
|
margin-bottom: 8px;
|
|
115
103
|
}
|
|
116
104
|
|
|
117
105
|
a.footnote-ref {
|
|
118
|
-
vertical-align:
|
|
119
|
-
border-bottom: none;
|
|
106
|
+
vertical-align: text-bottom;
|
|
120
107
|
font-size: 0.8em;
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.footnote-marker {
|
|
112
|
+
@include user-select(none);
|
|
113
|
+
position: absolute;
|
|
114
|
+
left: 0;
|
|
115
|
+
top: 0;
|
|
116
|
+
font-weight: 500;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
a.footnote-ref,
|
|
120
|
+
.footnote-marker {
|
|
121
|
+
font-feature-settings: 'ss06';
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
.footnote-item {
|
|
@@ -127,7 +128,10 @@ a.footnote-ref {
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
a.footnote-ref
|
|
131
|
+
a.footnote-ref {
|
|
132
|
+
@include user-select(none);
|
|
133
|
+
}
|
|
134
|
+
|
|
131
135
|
.footnotes .footnote-backref {
|
|
132
136
|
display: inline-block;
|
|
133
137
|
@include user-select(none);
|
|
@@ -379,21 +383,6 @@ dl {
|
|
|
379
383
|
dt {
|
|
380
384
|
font-weight: 600;
|
|
381
385
|
color: var(--theme-color-text);
|
|
382
|
-
|
|
383
|
-
a {
|
|
384
|
-
color: var(--theme-color-text);
|
|
385
|
-
text-decoration-color: var(--theme-color-text);
|
|
386
|
-
|
|
387
|
-
@media (hover: hover) {
|
|
388
|
-
&:hover {
|
|
389
|
-
text-decoration-color: var(--fg2-color);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
&:active {
|
|
394
|
-
text-decoration-color: var(--link-active-color);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
386
|
}
|
|
398
387
|
|
|
399
388
|
dd > *:first-child {
|
|
@@ -407,12 +396,17 @@ dfn {
|
|
|
407
396
|
font-style: italic;
|
|
408
397
|
}
|
|
409
398
|
|
|
410
|
-
.breadcrumb {
|
|
399
|
+
a.breadcrumb {
|
|
411
400
|
@include user-select(none);
|
|
401
|
+
@include subdued-link;
|
|
412
402
|
|
|
413
403
|
&::after {
|
|
414
|
-
content:
|
|
404
|
+
content: '';
|
|
405
|
+
display: inline-block;
|
|
406
|
+
width: 1em;
|
|
407
|
+
height: 1em;
|
|
415
408
|
vertical-align: middle;
|
|
409
|
+
@include contained-mask(var(--icon-breadcrumb));
|
|
416
410
|
}
|
|
417
411
|
}
|
|
418
412
|
|
package/src/toc/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ function scrollIfNeeded(element: HTMLElement, doc: Document) {
|
|
|
37
37
|
elementRect.height / 2;
|
|
38
38
|
const desiredScrollTop = elementCenter - container.clientHeight / 2;
|
|
39
39
|
|
|
40
|
-
container.scrollTo({ top: desiredScrollTop
|
|
40
|
+
container.scrollTo({ top: desiredScrollTop });
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function getHighlightIndexes(items: (Heading | Alert | Dinkus)[]) {
|
package/src/toc/style.scss
CHANGED
|
@@ -127,51 +127,22 @@ body.code .toc ol a {
|
|
|
127
127
|
position: relative;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// Preload hover icon variants so the browser decodes them before first hover
|
|
131
|
-
.toc ol li.alert-item.warning::after {
|
|
132
|
-
content: var(--icon-warning-sm-hover);
|
|
133
|
-
position: absolute;
|
|
134
|
-
width: 0;
|
|
135
|
-
height: 0;
|
|
136
|
-
overflow: hidden;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.toc ol li.alert-item.note::after {
|
|
140
|
-
content: var(--icon-note-sm-hover);
|
|
141
|
-
position: absolute;
|
|
142
|
-
width: 0;
|
|
143
|
-
height: 0;
|
|
144
|
-
overflow: hidden;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
130
|
.toc ol li.alert-item.warning a::before,
|
|
148
131
|
.toc ol li.alert-item.note a::before {
|
|
132
|
+
content: '';
|
|
149
133
|
display: inline-block;
|
|
134
|
+
width: 20px;
|
|
150
135
|
height: 20px;
|
|
151
136
|
vertical-align: bottom;
|
|
152
137
|
margin-right: 4px;
|
|
153
138
|
}
|
|
154
139
|
|
|
155
140
|
.toc ol li.alert-item.warning a::before {
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@media (hover: hover) {
|
|
160
|
-
.toc ol li.alert-item.warning:hover a::before,
|
|
161
|
-
.toc ol li.alert-item.warning a:hover::before {
|
|
162
|
-
content: var(--icon-warning-sm-hover);
|
|
163
|
-
}
|
|
141
|
+
@include contained-mask(var(--icon-warning));
|
|
164
142
|
}
|
|
165
143
|
|
|
166
144
|
.toc ol li.alert-item.note a::before {
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
@media (hover: hover) {
|
|
171
|
-
.toc ol li.alert-item.note:hover a::before,
|
|
172
|
-
.toc ol li.alert-item.note a:hover::before {
|
|
173
|
-
content: var(--icon-note-sm-hover);
|
|
174
|
-
}
|
|
145
|
+
@include contained-mask(var(--icon-note));
|
|
175
146
|
}
|
|
176
147
|
|
|
177
148
|
.toc ol li.label {
|
package/src/top/index.ts
CHANGED
|
@@ -30,11 +30,15 @@ export default (window: Window) => {
|
|
|
30
30
|
e.preventDefault();
|
|
31
31
|
const cleanUrl = window.location.pathname + window.location.search;
|
|
32
32
|
if (window.location.hash) {
|
|
33
|
-
|
|
33
|
+
// Clear the hash via fragment navigation so :target clears and
|
|
34
|
+
// hashchange fires. location.hash = '' may leave a trailing '#';
|
|
35
|
+
// strip it with replaceState.
|
|
36
|
+
window.location.hash = '';
|
|
37
|
+
window.history.replaceState(null, '', cleanUrl);
|
|
34
38
|
} else {
|
|
35
39
|
window.history.replaceState(null, '', cleanUrl);
|
|
36
40
|
}
|
|
37
|
-
window.scrollTo({ top: 0
|
|
41
|
+
window.scrollTo({ top: 0 });
|
|
38
42
|
const toc = window.document.querySelector('nav.toc') as HTMLElement | null;
|
|
39
43
|
if (toc) {
|
|
40
44
|
toc.scrollTop = 0;
|
package/templates/_theme.scss
CHANGED
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
// Secondary foreground color (lighter)
|
|
22
22
|
--fg2-color: hsl(var(--tint-hue) calc(6% * var(--tint-amount)) 45%);
|
|
23
23
|
|
|
24
|
+
--link-color: <%= linkColor %>;
|
|
25
|
+
--link-color-hover: <%= linkColorHover %>;
|
|
26
|
+
|
|
24
27
|
// Main background color (the color of the page background)
|
|
25
28
|
--bg-color: hsl(var(--tint-hue) calc(5% * var(--tint-amount)) 97%);
|
|
26
29
|
--bg-color-translucent: hsl(
|
|
@@ -56,20 +59,14 @@
|
|
|
56
59
|
--mono-border-radius: 0.375em;
|
|
57
60
|
|
|
58
61
|
// SVG icons
|
|
59
|
-
|
|
60
|
-
--icon-external-link
|
|
61
|
-
--icon-
|
|
62
|
-
--icon-
|
|
63
|
-
--icon-
|
|
64
|
-
--icon-warning-sm: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='<%= iconColor %>' stroke-width='2' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
65
|
-
--icon-warning-sm-hover: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='<%= iconColorHover %>' stroke-width='2' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='<%= iconColorHover %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='<%= iconColorHover %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
66
|
-
--icon-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColor %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
67
|
-
--icon-note-sm: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColor %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
68
|
-
--icon-note-sm-hover: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColorHover %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColorHover %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColorHover %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
62
|
+
// Mask icons (color-agnostic, painted via background-color: currentColor)
|
|
63
|
+
--icon-external-link: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M6 18 L20 4 M10 4 H20 V14' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
|
|
64
|
+
--icon-anchor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 28'><path d='M11 4 L8 20 M17 4 L14 20 M5 9 H21 M3 15 H19' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
|
|
65
|
+
--icon-warning: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='black' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
66
|
+
--icon-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='black' stroke-width='1.5'/><line x1='12' y1='10' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
69
67
|
--icon-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7' stroke='<%= iconColor %>' stroke-width='2' fill='none'/><line x1='16.5' y1='16.5' x2='22' y2='22' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
70
|
-
--icon-anchor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='<%= iconColor %>' fill-rule='evenodd' clip-rule='evenodd' d='M10.975 14.51a1.05 1.05 0 0 0 0-1.485 2.95 2.95 0 0 1 0-4.172l3.536-3.535a2.95 2.95 0 1 1 4.172 4.172l-1.093 1.092a1.05 1.05 0 0 0 1.485 1.485l1.093-1.092a5.05 5.05 0 0 0-7.142-7.142L9.49 7.368a5.05 5.05 0 0 0 0 7.142c.41.41 1.075.41 1.485 0zm2.05-5.02a1.05 1.05 0 0 0 0 1.485 2.95 2.95 0 0 1 0 4.172l-3.5 3.5a2.95 2.95 0 1 1-4.171-4.172l1.025-1.025a1.05 1.05 0 0 0-1.485-1.485L3.87 12.99a5.05 5.05 0 0 0 7.142 7.142l3.5-3.5a5.05 5.05 0 0 0 0-7.142 1.05 1.05 0 0 0-1.485 0z'/></svg>");
|
|
71
68
|
--icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><polyline points='9 18 15 12 9 6' stroke='<%= iconColor %>' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
|
|
72
|
-
--icon-breadcrumb: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M3 7 H17 V22' stroke='
|
|
69
|
+
--icon-breadcrumb: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M3 7 H17 V22' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/><polyline points='11 16 17 22 23 16' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
|
|
73
70
|
|
|
74
71
|
color-scheme: light dark;
|
|
75
72
|
}
|
|
@@ -85,6 +82,8 @@
|
|
|
85
82
|
var(--tint-hue) calc(85% * var(--tint-amount)) 90% / 33%
|
|
86
83
|
);
|
|
87
84
|
--fg2-color: hsl(var(--tint-hue) calc(6% * var(--tint-amount)) 60%);
|
|
85
|
+
--link-color: <%= linkColorDark %>;
|
|
86
|
+
--link-color-hover: <%= linkColorHoverDark %>;
|
|
88
87
|
--bg-color: hsl(var(--tint-hue) calc(3% * var(--tint-amount)) 5%);
|
|
89
88
|
--bg-color-translucent: hsl(
|
|
90
89
|
var(--tint-hue) calc(15% * var(--tint-amount)) 10% / 66%
|
|
@@ -103,19 +102,7 @@
|
|
|
103
102
|
--note-bg-color: hsl(209 90% 25%);
|
|
104
103
|
|
|
105
104
|
// SVG icons (dark overrides)
|
|
106
|
-
--icon-external-link: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><rect x='3' y='3' width='18' height='18' stroke='<%= iconColorDark %>' stroke-width='2' fill='none' rx='2'/><path d='M9 15 L15 9' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round' fill='none'/><path d='M9 9 H15 V15' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round' fill='none'/></svg>");
|
|
107
|
-
--icon-external-link-hover: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><rect x='3' y='3' width='18' height='18' stroke='<%= iconColorHoverDark %>' stroke-width='2' fill='none' rx='2'/><path d='M9 15 L15 9' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round' fill='none'/><path d='M9 9 H15 V15' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round' fill='none'/></svg>");
|
|
108
|
-
--icon-external-link-active: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><rect x='3' y='3' width='18' height='18' stroke='white' stroke-width='2' fill='none' rx='2'/><path d='M9 15 L15 9' stroke='white' stroke-width='2' stroke-linecap='round' fill='none'/><path d='M9 9 H15 V15' stroke='white' stroke-width='2' stroke-linecap='round' fill='none'/></svg>");
|
|
109
|
-
--icon-external-translucent: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><g opacity='0.3' stroke='<%= iconColorTranslucentDark %>' stroke-width='2' stroke-linecap='round' fill='none'><rect x='3' y='3' width='18' height='18' rx='2'/><path d='M9 15 L15 9' stroke-linecap='round'/><path d='M9 9 H15 V15' stroke-linecap='round'/></g></svg>");
|
|
110
|
-
--icon-warning: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
111
|
-
--icon-warning-sm: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
112
|
-
--icon-warning-sm-hover: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
113
|
-
--icon-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColorDark %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
114
|
-
--icon-note-sm: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColorDark %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
115
|
-
--icon-note-sm-hover: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='<%= iconColorHoverDark %>' stroke-width='2'/><line x1='12' y1='10' x2='12' y2='16' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='<%= iconColorHoverDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
116
105
|
--icon-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7' stroke='<%= iconColorDark %>' stroke-width='2' fill='none'/><line x1='16.5' y1='16.5' x2='22' y2='22' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
117
|
-
--icon-anchor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='<%= iconColorDark %>' fill-rule='evenodd' clip-rule='evenodd' d='M10.975 14.51a1.05 1.05 0 0 0 0-1.485 2.95 2.95 0 0 1 0-4.172l3.536-3.535a2.95 2.95 0 1 1 4.172 4.172l-1.093 1.092a1.05 1.05 0 0 0 1.485 1.485l1.093-1.092a5.05 5.05 0 0 0-7.142-7.142L9.49 7.368a5.05 5.05 0 0 0 0 7.142c.41.41 1.075.41 1.485 0zm2.05-5.02a1.05 1.05 0 0 0 0 1.485 2.95 2.95 0 0 1 0 4.172l-3.5 3.5a2.95 2.95 0 1 1-4.171-4.172l1.025-1.025a1.05 1.05 0 0 0-1.485-1.485L3.87 12.99a5.05 5.05 0 0 0 7.142 7.142l3.5-3.5a5.05 5.05 0 0 0 0-7.142 1.05 1.05 0 0 0-1.485 0z'/></svg>");
|
|
118
106
|
--icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><polyline points='9 18 15 12 9 6' stroke='<%= iconColorDark %>' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
|
|
119
|
-
--icon-breadcrumb: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M3 7 H17 V22' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/><polyline points='11 16 17 22 23 16' stroke='<%= iconColorDark %>' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
|
|
120
107
|
}
|
|
121
108
|
}
|