@writedocs/generator 0.10.8 → 0.10.10
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
CHANGED
|
@@ -57,8 +57,8 @@ interface Props {
|
|
|
57
57
|
// src/scripts/image-zoom.ts) - rendered as a bare `nozoom` attribute
|
|
58
58
|
// on both <img> tags, the same attribute a raw
|
|
59
59
|
// `<img nozoom src="..." />` written directly in MDX would carry, so
|
|
60
|
-
//
|
|
61
|
-
//
|
|
60
|
+
// lib/image-zoom-rules.js handles both cases identically rather than
|
|
61
|
+
// needing to special-case this component.
|
|
62
62
|
noZoom?: boolean;
|
|
63
63
|
}
|
|
64
64
|
const { src, srcDark, size, alt = "", caption, noZoom } = Astro.props as Props;
|
|
@@ -45,11 +45,31 @@ const { defaultTabIndex = 0 } = Astro.props as Props;
|
|
|
45
45
|
document.addEventListener('astro:page-load', () => initTabs(document));
|
|
46
46
|
</script>
|
|
47
47
|
<style is:global>
|
|
48
|
+
/* A border around the whole component - the tabs and the open tab's
|
|
49
|
+
content - so it's clear where it ends and the page goes on. */
|
|
50
|
+
.wd-tabs {
|
|
51
|
+
margin: 1.25rem 0;
|
|
52
|
+
border: 1px solid var(--wd-border);
|
|
53
|
+
border-radius: 0.6rem;
|
|
54
|
+
}
|
|
48
55
|
.wd-tabs-nav {
|
|
49
56
|
display: flex;
|
|
57
|
+
flex-wrap: wrap;
|
|
50
58
|
gap: 0.25rem;
|
|
59
|
+
padding: 0 0.5rem;
|
|
51
60
|
border-bottom: 1px solid var(--wd-border);
|
|
52
|
-
|
|
61
|
+
}
|
|
62
|
+
.wd-tab {
|
|
63
|
+
padding: 1rem 1.1rem;
|
|
64
|
+
min-width: 0;
|
|
65
|
+
}
|
|
66
|
+
/* The first thing shown - after the hidden icon a tab with `icon` holds. */
|
|
67
|
+
.wd-tab > :first-child,
|
|
68
|
+
.wd-tab > [hidden]:first-child + * {
|
|
69
|
+
margin-top: 0;
|
|
70
|
+
}
|
|
71
|
+
.wd-tab > :last-child {
|
|
72
|
+
margin-bottom: 0;
|
|
53
73
|
}
|
|
54
74
|
.wd-tabs-btn {
|
|
55
75
|
background: none;
|
|
@@ -59,6 +79,8 @@ const { defaultTabIndex = 0 } = Astro.props as Props;
|
|
|
59
79
|
font-size: 0.9rem;
|
|
60
80
|
color: var(--wd-text);
|
|
61
81
|
border-bottom: 2px solid transparent;
|
|
82
|
+
/* The current tab's underline sits on the row's bottom border. */
|
|
83
|
+
margin-bottom: -1px;
|
|
62
84
|
}
|
|
63
85
|
.wd-tabs-btn {
|
|
64
86
|
display: inline-flex;
|
|
@@ -222,6 +222,11 @@ const darkNavbarConfigured = config.styles.navbar?.dark !== undefined;
|
|
|
222
222
|
// regardless of what hue the navbar itself happens to be.
|
|
223
223
|
const lightNavbarFg = lightNavbarConfigured ? contrastTextColor(lightNavbarBg) : "var(--wd-text)";
|
|
224
224
|
const darkNavbarFg = darkNavbarConfigured ? contrastTextColor(darkNavbarBg) : "var(--wd-text)";
|
|
225
|
+
// The current tab (and a hovered one) stands out: the heading color on the
|
|
226
|
+
// page's own background, or the same computed black/white on a configured
|
|
227
|
+
// navbar - which is already the strongest color there.
|
|
228
|
+
const lightNavbarFgStrong = lightNavbarConfigured ? lightNavbarFg : "var(--wd-heading)";
|
|
229
|
+
const darkNavbarFgStrong = darkNavbarConfigured ? darkNavbarFg : "var(--wd-heading)";
|
|
225
230
|
const lightNavbarFgMuted = lightNavbarConfigured
|
|
226
231
|
? `color-mix(in srgb, ${lightNavbarFg} 70%, transparent)`
|
|
227
232
|
: "var(--wd-text-muted)";
|
|
@@ -548,6 +553,7 @@ const fontExtraCss = [fontFaceCss, fontWeightCss].filter(Boolean).join("\n");
|
|
|
548
553
|
wdTextLight: lightText,
|
|
549
554
|
wdNavbarLight: lightNavbarBg,
|
|
550
555
|
wdNavbarFgLight: lightNavbarFg,
|
|
556
|
+
wdNavbarFgStrongLight: lightNavbarFgStrong,
|
|
551
557
|
wdNavbarFgMutedLight: lightNavbarFgMuted,
|
|
552
558
|
wdNavbarAccentLight: lightNavbarAccent,
|
|
553
559
|
wdNavbarBorderLight: lightNavbarBorder,
|
|
@@ -563,6 +569,7 @@ const fontExtraCss = [fontFaceCss, fontWeightCss].filter(Boolean).join("\n");
|
|
|
563
569
|
wdTextDark: darkText,
|
|
564
570
|
wdNavbarDark: darkNavbarBg,
|
|
565
571
|
wdNavbarFgDark: darkNavbarFg,
|
|
572
|
+
wdNavbarFgStrongDark: darkNavbarFgStrong,
|
|
566
573
|
wdNavbarFgMutedDark: darkNavbarFgMuted,
|
|
567
574
|
wdNavbarAccentDark: darkNavbarAccent,
|
|
568
575
|
wdNavbarBorderDark: darkNavbarBorder,
|
|
@@ -578,6 +585,7 @@ const fontExtraCss = [fontFaceCss, fontWeightCss].filter(Boolean).join("\n");
|
|
|
578
585
|
--wd-text: var(--wdTextLight);
|
|
579
586
|
--wd-navbar-background: var(--wdNavbarLight);
|
|
580
587
|
--wd-navbar-foreground: var(--wdNavbarFgLight);
|
|
588
|
+
--wd-navbar-foreground-strong: var(--wdNavbarFgStrongLight);
|
|
581
589
|
--wd-navbar-foreground-muted: var(--wdNavbarFgMutedLight);
|
|
582
590
|
--wd-navbar-accent: var(--wdNavbarAccentLight);
|
|
583
591
|
--wd-navbar-border: var(--wdNavbarBorderLight);
|
|
@@ -616,6 +624,7 @@ const fontExtraCss = [fontFaceCss, fontWeightCss].filter(Boolean).join("\n");
|
|
|
616
624
|
--wd-text: var(--wdTextDark);
|
|
617
625
|
--wd-navbar-background: var(--wdNavbarDark);
|
|
618
626
|
--wd-navbar-foreground: var(--wdNavbarFgDark);
|
|
627
|
+
--wd-navbar-foreground-strong: var(--wdNavbarFgStrongDark);
|
|
619
628
|
--wd-navbar-foreground-muted: var(--wdNavbarFgMutedDark);
|
|
620
629
|
--wd-navbar-accent: var(--wdNavbarAccentDark);
|
|
621
630
|
--wd-navbar-border: var(--wdNavbarBorderDark);
|
|
@@ -259,10 +259,12 @@
|
|
|
259
259
|
}
|
|
260
260
|
/* The selected tab: just its border-bottom, in --wd-navbar-accent (falls
|
|
261
261
|
back to --wd-primary - see BaseLayout.astro), landing on the row's
|
|
262
|
-
bottom edge as an underline. No fill - the text
|
|
263
|
-
color
|
|
262
|
+
bottom edge as an underline. No fill - the text takes the navbar's
|
|
263
|
+
strongest color (the heading color, or the computed black/white on a
|
|
264
|
+
navbar of its own - --wd-navbar-foreground-strong in BaseLayout.astro). */
|
|
264
265
|
.wd-tab-link.active {
|
|
265
266
|
border-bottom-color: var(--wd-navbar-accent);
|
|
267
|
+
color: var(--wd-navbar-foreground-strong);
|
|
266
268
|
font-weight: 600;
|
|
267
269
|
}
|
|
268
270
|
/* Any tab on hover: a light background tint, the same as a sidebar item's
|
|
@@ -270,6 +272,7 @@
|
|
|
270
272
|
corners above shape it. */
|
|
271
273
|
.wd-tab-link:hover {
|
|
272
274
|
background: var(--wd-navbar-hover);
|
|
275
|
+
color: var(--wd-navbar-foreground-strong);
|
|
273
276
|
}
|
|
274
277
|
.wd-topbar-links {
|
|
275
278
|
display: flex;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Which page images open in the zoom lightbox (src/scripts/image-zoom.ts).
|
|
2
|
+
// Plain JavaScript, so scripts/image-zoom-rules.test.js can check it.
|
|
3
|
+
//
|
|
4
|
+
// Every image in a page's article zooms, except:
|
|
5
|
+
// - one opted out with `noZoom` (`<img noZoom>`, `<Image noZoom>`) - the
|
|
6
|
+
// DOM sees it as `nozoom`, since attribute names aren't case-sensitive;
|
|
7
|
+
// - a component's own picture - a Card's header image (.wd-card-image), an
|
|
8
|
+
// Icon's image (.wd-icon-image), anything in a Tile's preview
|
|
9
|
+
// (.wd-tile-preview): part of the component, not content to inspect;
|
|
10
|
+
// - an image inside a link (`[](/page/)`, `<a><img></a>`, a Tile
|
|
11
|
+
// or Card with `href`) - a click follows the link instead.
|
|
12
|
+
|
|
13
|
+
/** Images that never zoom, as a selector for `closest()`. */
|
|
14
|
+
export const NO_ZOOM_SELECTOR = '[nozoom], .wd-card-image, .wd-icon-image, .wd-tile-preview, a[href]';
|
|
15
|
+
|
|
16
|
+
/** Whether a page image opens in the lightbox. `img` is an <img> element
|
|
17
|
+
* (anything with `closest()`); only images in the article are passed in. */
|
|
18
|
+
export function zoomsOnClick(img) {
|
|
19
|
+
return img.closest(NO_ZOOM_SELECTOR) === null;
|
|
20
|
+
}
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
// Click-to-zoom lightbox for content images - opened by ImageZoom.astro's
|
|
2
2
|
// own overlay markup, mounted once in BaseLayout.astro alongside
|
|
3
3
|
// SearchModal. Every <img> inside .wd-article becomes clickable and opens
|
|
4
|
-
// a fullscreen view of itself
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// as `<img noZoom src="..." />` in source (Image.astro's own
|
|
12
|
-
// `noZoom` prop renders the same attribute - see its own comment),
|
|
13
|
-
// but HTML attribute names are ASCII-case-insensitive during
|
|
14
|
-
// parsing, so the DOM (and this selector) sees it as `nozoom`
|
|
15
|
-
// regardless of how it was cased in source.
|
|
16
|
-
// Scoped to .wd-article (not a bare `img` selector) so this never
|
|
17
|
-
// touches chrome images - the topbar/sidebar logo, sidebar icons, or
|
|
18
|
-
// anything else outside actual page content.
|
|
4
|
+
// a fullscreen view of itself - except the ones lib/image-zoom-rules.js
|
|
5
|
+
// leaves out: `noZoom`, a component's own picture (Card, Icon, Tile), and an
|
|
6
|
+
// image inside a link. Scoped to .wd-article (not a bare `img` selector) so
|
|
7
|
+
// this never touches chrome images - the topbar/sidebar logo, sidebar icons,
|
|
8
|
+
// or anything else outside actual page content.
|
|
9
|
+
import { zoomsOnClick } from '../lib/image-zoom-rules.js';
|
|
10
|
+
|
|
19
11
|
export function initImageZoom(root: ParentNode) {
|
|
20
12
|
const overlay = document.querySelector<HTMLElement>('#wd-zoom-overlay');
|
|
21
13
|
const overlayImg = document.querySelector<HTMLImageElement>('#wd-zoom-image');
|
|
22
14
|
if (!overlay || !overlayImg) return;
|
|
23
15
|
|
|
24
|
-
const images = root.querySelectorAll<HTMLImageElement>(
|
|
25
|
-
'.wd-article img:not(.wd-card-image):not(.wd-icon-image):not([nozoom])',
|
|
26
|
-
);
|
|
16
|
+
const images = root.querySelectorAll<HTMLImageElement>('.wd-article img');
|
|
27
17
|
images.forEach((img) => {
|
|
28
|
-
if (img.dataset.wdInit) return;
|
|
18
|
+
if (img.dataset.wdInit || !zoomsOnClick(img)) return;
|
|
29
19
|
img.dataset.wdInit = 'true';
|
|
30
20
|
img.classList.add('wd-zoomable');
|
|
31
21
|
img.addEventListener('click', () => open(img));
|