@sarimarcus/content-sites-ui 0.60.4 → 0.60.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/package.json +2 -2
- package/src/composed/TableOfContents.astro +2 -1
- package/src/editorial/ArticleCategoryNav.astro +4 -1
- package/src/editorial/ArticlePage.astro +7 -7
- package/src/editorial/ArticleTagPage.astro +4 -1
- package/src/editorial/ArticleTopicPage.astro +5 -3
- package/src/editorial/AuthorPage.astro +2 -1
- package/src/editorial/AuthorsIndexPage.astro +2 -1
- package/src/editorial/EraTimelineNav.astro +2 -1
- package/src/editorial/StaticProsePage.astro +2 -1
- package/src/editorial/interludes/RelatedCard.astro +10 -7
- package/src/layout/BreadcrumbBand.astro +3 -2
- package/src/layout/DocumentShell.astro +1 -1
- package/src/layout/headerOffset.ts +3 -0
- package/src/navigation/MobileNavLink.astro +1 -1
- package/src/navigation/SiteHeader.astro +16 -8
- package/src/navigation/navigation.ts +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.60.6 (2026-11-07)
|
|
6
|
+
|
|
7
|
+
Hub pages can drop the category row, and the Sotto Scocca audit's package fixes land (SLA-3942). Default markup is unchanged for the hub prop (`render-diff` against 0.60.5 is identical for the topic hub, the paged topic page and the tag page: `tests/fixtures/render-diff/hub-category-nav-default.json`, `article-nav-routes-default.json`); the markup changes below are intended.
|
|
8
|
+
|
|
9
|
+
- `ArticleTopicPage`, `ArticleTagPage`: new optional `showCategoryNav` (default `true`); `false` omits the category nav row, for a site whose header already lists the categories. `ArticleCategoryNav`: new optional `hidden`, which renders nothing.
|
|
10
|
+
- `BreadcrumbBand`, `AuthorPage`, `AuthorsIndexPage`, `StaticProsePage`: the header offset is `pt-[var(--site-header-offset,4rem)]` instead of `pt-16`; `TableOfContents` (fixed bar), `EraTimelineNav` and the `SiteHeader` mobile panel use `top-[var(--site-header-offset,4rem)]` instead of `top-16`. `SiteHeader` sets `--site-header-offset` to the nav plus the trending bar (`4rem + 2.75rem + 1px`) from md when `trendingTags` is set, so nothing under the header slides beneath the bar (SLA-3942 d). The classes live in `layout/headerOffset.ts`.
|
|
11
|
+
- `ArticlePage`: `<main>` is the outer element and `<article data-pagefind-body>` sits inside it; the breadcrumb band stays above `<main>` (e).
|
|
12
|
+
- `RelatedCard`: the title is an `h3` by default, new optional `headingLevel` (`3 | 4`) for the old `h4` (f).
|
|
13
|
+
- `MobileNavLink` rows are at least 44px (`min-h-11`); the trending bar is 44px tall (was 36px) and its links fill it (g).
|
|
14
|
+
- `SiteHeader` stamps `data-desktop-breakpoint`; the mobile-menu cleanup in `navigation.ts` follows each header's `desktopBreakpoint` (`lg` 64rem, `xl` 80rem) instead of always 64rem. `DocumentShell`: `#main-content` gets `tabindex="-1"`, so the skip link moves focus in every browser (h).
|
|
15
|
+
|
|
16
|
+
## 0.60.5 (2026-11-06)
|
|
17
|
+
|
|
18
|
+
Markup change only where `SiteHeader` gets `trendingTags`: the 0.60.3 centring did not work, because the bar sat in a `max-w-content` Container that overflowed, which collapsed the auto margins.
|
|
19
|
+
|
|
20
|
+
- `SiteHeader`: the trending bar uses the nav's `max-w-shell` rail with `justify-center`; the tag list scrolls on its own (`min-w-0 overflow-x-auto`) instead of the whole bar. `Container` is no longer imported.
|
|
21
|
+
|
|
5
22
|
## 0.60.4 (2026-11-06)
|
|
6
23
|
|
|
7
24
|
Markup and style changes at the end of an article (SLA-3904); no prop is removed or retyped.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarimarcus/content-sites-ui",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.6",
|
|
4
4
|
"description": "Universal Astro UI components, layout shell and design tokens shared by the content sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"@lucide/astro": "^1.23.0",
|
|
52
52
|
"astro": "^7.0.6",
|
|
53
53
|
"tailwindcss": "^4.1.18",
|
|
54
|
-
"@sarimarcus/content-sites-core": "0.60.
|
|
54
|
+
"@sarimarcus/content-sites-core": "0.60.6"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// empty heading on every caller that omits one (SLA-2340); `mb-2` sits behind `title` so an eyebrow-only header does
|
|
8
8
|
// not double the gap.
|
|
9
9
|
import Chip from '../primitives/Chip.astro';
|
|
10
|
+
import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
|
|
10
11
|
import { getLabels } from '../internal/labels';
|
|
11
12
|
import type { TableOfContentsItem } from './tocItem.ts';
|
|
12
13
|
|
|
@@ -78,7 +79,7 @@ const showMini = variant === 'card';
|
|
|
78
79
|
data-toc-mini
|
|
79
80
|
data-toc
|
|
80
81
|
data-toc-section-selector={sectionSelector}
|
|
81
|
-
class=
|
|
82
|
+
class:list={['invisible fixed left-0 right-0 z-40 translate-y-[-100%] opacity-0 pointer-events-none transition-[transform,opacity,visibility] duration-300 ease-out bg-background/95 backdrop-blur-sm border-b border-border shadow-sm', HEADER_OFFSET_TOP]}
|
|
82
83
|
aria-hidden="true"
|
|
83
84
|
inert
|
|
84
85
|
>
|
|
@@ -19,6 +19,8 @@ interface Props {
|
|
|
19
19
|
routes?: SiteRoutes;
|
|
20
20
|
locale?: string;
|
|
21
21
|
class?: string;
|
|
22
|
+
/** Renders nothing, for a page whose site header already lists the categories. */
|
|
23
|
+
hidden?: boolean;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
const defaultLabels = getLabels(Astro.props.locale ?? Astro.currentLocale).articleCategoryNav;
|
|
@@ -31,6 +33,7 @@ const {
|
|
|
31
33
|
allLabel = defaultLabels.allLabel,
|
|
32
34
|
routes,
|
|
33
35
|
class: className,
|
|
36
|
+
hidden = false,
|
|
34
37
|
} = Astro.props;
|
|
35
38
|
|
|
36
39
|
const counts = new Map<string, number>();
|
|
@@ -50,7 +53,7 @@ const all = { href: url(routePath('articles', undefined, routes)), label: allLab
|
|
|
50
53
|
const countClass = (active: boolean) => (active ? 'bg-overlay-foreground/20' : 'bg-muted');
|
|
51
54
|
---
|
|
52
55
|
|
|
53
|
-
{categories.length > 0 && (
|
|
56
|
+
{!hidden && categories.length > 0 && (
|
|
54
57
|
<nav aria-label={ariaLabel} class={className}>
|
|
55
58
|
<div class="flex gap-2.5 overflow-x-auto flex-nowrap pb-2 scrollbar-hide md:flex-wrap md:overflow-visible md:pb-0">
|
|
56
59
|
<Chip
|
|
@@ -330,11 +330,6 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
|
|
|
330
330
|
|
|
331
331
|
<slot name="head" />
|
|
332
332
|
|
|
333
|
-
<article data-pagefind-body data-pagefind-meta="type:article">
|
|
334
|
-
{emitAudienceFacets && article.audiences?.map((a) => (
|
|
335
|
-
<span class="sr-only" data-pagefind-filter={`audience:${a}`}>{a}</span>
|
|
336
|
-
))}
|
|
337
|
-
|
|
338
333
|
{editorial && backLink ? (
|
|
339
334
|
<BreadcrumbBand class={breadcrumbBandClass}>
|
|
340
335
|
<a href={backLink.href} data-article-back class="inline-flex items-center gap-2 py-1 text-sm font-medium text-muted-foreground hover:text-primary sm:hidden">
|
|
@@ -349,6 +344,12 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
|
|
|
349
344
|
</BreadcrumbBand>
|
|
350
345
|
)}
|
|
351
346
|
|
|
347
|
+
<main>
|
|
348
|
+
<article data-pagefind-body data-pagefind-meta="type:article">
|
|
349
|
+
{emitAudienceFacets && article.audiences?.map((a) => (
|
|
350
|
+
<span class="sr-only" data-pagefind-filter={`audience:${a}`}>{a}</span>
|
|
351
|
+
))}
|
|
352
|
+
|
|
352
353
|
{heroImage ? (
|
|
353
354
|
railHead ? (
|
|
354
355
|
<ContentHero
|
|
@@ -410,7 +411,6 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
|
|
|
410
411
|
</header>
|
|
411
412
|
)}
|
|
412
413
|
|
|
413
|
-
<main>
|
|
414
414
|
<Container size="measure" class={editorial ? 'relative pt-6 pb-10 sm:pt-8 sm:pb-14' : 'py-10 sm:py-14'}>
|
|
415
415
|
{!railHead && <ArticleMetadata
|
|
416
416
|
author={author}
|
|
@@ -601,5 +601,5 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
|
|
|
601
601
|
</footer>
|
|
602
602
|
)}
|
|
603
603
|
</Container>
|
|
604
|
-
</main>
|
|
605
604
|
</article>
|
|
605
|
+
</main>
|
|
@@ -36,6 +36,8 @@ interface Props {
|
|
|
36
36
|
/** Chips shown in the tag row (all by default). */
|
|
37
37
|
relatedTagsLimit?: number;
|
|
38
38
|
showRelatedTags?: boolean;
|
|
39
|
+
/** Pass `false` where the site header already lists the categories. */
|
|
40
|
+
showCategoryNav?: boolean;
|
|
39
41
|
locale?: string;
|
|
40
42
|
/** Overrides of the article routes (`articles`, `articleTopic`), for the topic nav. */
|
|
41
43
|
routes?: SiteRoutes;
|
|
@@ -52,6 +54,7 @@ const {
|
|
|
52
54
|
relatedTags = [],
|
|
53
55
|
relatedTagsLimit,
|
|
54
56
|
showRelatedTags = true,
|
|
57
|
+
showCategoryNav = true,
|
|
55
58
|
locale,
|
|
56
59
|
routes,
|
|
57
60
|
} = Astro.props;
|
|
@@ -68,7 +71,7 @@ const countWord = count === 1 ? l.countOne : l.countMany;
|
|
|
68
71
|
</p>
|
|
69
72
|
|
|
70
73
|
<Container>
|
|
71
|
-
{categories && articles.length > 0 && (
|
|
74
|
+
{showCategoryNav && categories && articles.length > 0 && (
|
|
72
75
|
<ArticleCategoryNav articles={articles} categories={categories} routes={routes} class="mb-8" />
|
|
73
76
|
)}
|
|
74
77
|
|
|
@@ -38,11 +38,13 @@ interface Props {
|
|
|
38
38
|
authors?: { heading: string; items: TopicAuthorCard[] };
|
|
39
39
|
/** The site's prose theme modifier for the overview, added to `prose` (a dark site needs its own body colour). */
|
|
40
40
|
proseClass?: string;
|
|
41
|
+
/** Pass `false` where the site header already lists the categories. */
|
|
42
|
+
showCategoryNav?: boolean;
|
|
41
43
|
/** Overrides of the article routes (`articles`, `articleTopic`), for the topic nav. */
|
|
42
44
|
routes?: SiteRoutes;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
const { eyebrow, heading, lede, articles, categories, category, currentPage, listHeading, overview, authors, proseClass = 'prose-lg', routes } = Astro.props;
|
|
47
|
+
const { eyebrow, heading, lede, articles, categories, category, currentPage, listHeading, overview, authors, proseClass = 'prose-lg', showCategoryNav = true, routes } = Astro.props;
|
|
46
48
|
const hub = currentPage === 1;
|
|
47
49
|
// Astro.slots.has() is true for a slotted expression that evaluated to false, so test what it rendered.
|
|
48
50
|
const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')).trim() : '';
|
|
@@ -53,7 +55,7 @@ const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')
|
|
|
53
55
|
<slot name="breadcrumb" slot="breadcrumb" />
|
|
54
56
|
<slot name="header-extra" slot="header-extra" />
|
|
55
57
|
<Container>
|
|
56
|
-
<ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} class="mb-12" />
|
|
58
|
+
<ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} hidden={!showCategoryNav} class="mb-12" />
|
|
57
59
|
<slot name="start-here" /></Container>
|
|
58
60
|
|
|
59
61
|
{overview && (
|
|
@@ -106,7 +108,7 @@ const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')
|
|
|
106
108
|
<ArticlesListingPage eyebrow={eyebrow} heading={heading} lede={lede}>
|
|
107
109
|
<slot name="breadcrumb" slot="breadcrumb" />
|
|
108
110
|
<Container>
|
|
109
|
-
<ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} class="mb-10" />
|
|
111
|
+
<ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} hidden={!showCategoryNav} class="mb-10" />
|
|
110
112
|
<slot name="grid" />
|
|
111
113
|
<slot name="pagination" />
|
|
112
114
|
</Container>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { ImageMetadata } from 'astro';
|
|
3
3
|
import Container from '../layout/Container.astro';
|
|
4
4
|
import BreadcrumbBand from '../layout/BreadcrumbBand.astro';
|
|
5
|
+
import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
|
|
5
6
|
import ResponsiveImage from '../primitives/ResponsiveImage.astro';
|
|
6
7
|
import Chip from '../primitives/Chip.astro';
|
|
7
8
|
import RoleBadge from './RoleBadge.astro';
|
|
@@ -90,7 +91,7 @@ const hasWorksSlot = Astro.slots.has('works');
|
|
|
90
91
|
---
|
|
91
92
|
|
|
92
93
|
<div class="bg-muted border-b border-border" data-pagefind-body>
|
|
93
|
-
<BreadcrumbBand ignore={false} class=
|
|
94
|
+
<BreadcrumbBand ignore={false} class={HEADER_OFFSET_PT}>
|
|
94
95
|
<slot name="breadcrumb" />
|
|
95
96
|
</BreadcrumbBand>
|
|
96
97
|
<header class="pt-10 pb-12">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Container from '../layout/Container.astro';
|
|
3
3
|
import BreadcrumbBand from '../layout/BreadcrumbBand.astro';
|
|
4
|
+
import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
|
|
4
5
|
import Button from '../primitives/Button.astro';
|
|
5
6
|
import { getLabels } from '../internal/labels';
|
|
6
7
|
|
|
@@ -52,7 +53,7 @@ const hasFaq = Astro.slots.has('faq');
|
|
|
52
53
|
---
|
|
53
54
|
|
|
54
55
|
<div class="bg-muted border-b border-border" data-pagefind-body>
|
|
55
|
-
<BreadcrumbBand ignore={false} class=
|
|
56
|
+
<BreadcrumbBand ignore={false} class={HEADER_OFFSET_PT}>
|
|
56
57
|
<slot name="breadcrumb" />
|
|
57
58
|
</BreadcrumbBand>
|
|
58
59
|
<header class="pt-12 pb-12">
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { EraDefinition } from '@sarimarcus/content-sites-core/eras';
|
|
10
10
|
import { getLabels } from '../internal/labels';
|
|
11
|
+
import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
|
|
11
12
|
|
|
12
13
|
interface Props {
|
|
13
14
|
eras: readonly EraDefinition[];
|
|
@@ -26,7 +27,7 @@ const { eras, ariaLabel = getLabels(Astro.props.locale ?? Astro.currentLocale).e
|
|
|
26
27
|
data-era-timeline-nav
|
|
27
28
|
data-toc-section-selector={sectionSelector}
|
|
28
29
|
aria-label={ariaLabel}
|
|
29
|
-
class:list={['sticky
|
|
30
|
+
class:list={['sticky z-30 hidden border-b border-border bg-background/95 backdrop-blur-sm md:block', HEADER_OFFSET_TOP, className]}
|
|
30
31
|
>
|
|
31
32
|
<ol class="mx-auto flex max-w-shell px-4 sm:px-6 lg:px-8">
|
|
32
33
|
{eras.map((era) => (
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Not Pagefind-indexed: it carries no body marker.
|
|
6
6
|
*/
|
|
7
7
|
import Container from '../layout/Container.astro';
|
|
8
|
+
import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
|
|
8
9
|
import Button from '../primitives/Button.astro';
|
|
9
10
|
|
|
10
11
|
interface CtaLink {
|
|
@@ -25,7 +26,7 @@ interface Props {
|
|
|
25
26
|
const { heading, eyebrow, cta, proseClass = 'prose-stone' } = Astro.props;
|
|
26
27
|
---
|
|
27
28
|
|
|
28
|
-
<div class=
|
|
29
|
+
<div class:list={[HEADER_OFFSET_PT, 'bg-gradient-to-b from-muted/60 via-background to-background border-b border-border']}>
|
|
29
30
|
<Container size="measure" class="py-10 sm:py-14">
|
|
30
31
|
{eyebrow && <p class="text-sm font-semibold uppercase tracking-[0.18em] text-primary">{eyebrow}</p>}
|
|
31
32
|
<h1 class="mt-3 text-4xl sm:text-5xl font-bold font-display text-foreground leading-tight text-balance">{heading}</h1>
|
|
@@ -17,8 +17,11 @@ interface Props {
|
|
|
17
17
|
image?: ImageMetadata;
|
|
18
18
|
imageAlt?: string;
|
|
19
19
|
eyebrowClass?: string;
|
|
20
|
+
/** Heading level of the title: h3 by default, the level under an article's H2 sections. */
|
|
21
|
+
headingLevel?: 3 | 4;
|
|
20
22
|
}
|
|
21
|
-
const { href, eyebrow, title, description, variant = 'inline', image, imageAlt, eyebrowClass } = Astro.props;
|
|
23
|
+
const { href, eyebrow, title, description, variant = 'inline', image, imageAlt, eyebrowClass, headingLevel = 3 } = Astro.props;
|
|
24
|
+
const Heading = `h${headingLevel}` as 'h3' | 'h4';
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
{variant === 'inline' ? (
|
|
@@ -30,9 +33,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
|
|
|
30
33
|
<p class={eyebrowClass ?? 'text-xs font-semibold uppercase tracking-[0.16em] text-primary mb-1'}>
|
|
31
34
|
{eyebrow}
|
|
32
35
|
</p>
|
|
33
|
-
<
|
|
36
|
+
<Heading class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
|
|
34
37
|
{title}
|
|
35
|
-
</
|
|
38
|
+
</Heading>
|
|
36
39
|
{description && (
|
|
37
40
|
<p class="mt-1 text-sm text-muted-foreground leading-relaxed line-clamp-2">{description}</p>
|
|
38
41
|
)}
|
|
@@ -63,9 +66,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
|
|
|
63
66
|
<p class={eyebrowClass ?? 'text-xs font-semibold uppercase tracking-[0.16em] text-primary mb-1'}>
|
|
64
67
|
{eyebrow}
|
|
65
68
|
</p>
|
|
66
|
-
<
|
|
69
|
+
<Heading class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors line-clamp-2">
|
|
67
70
|
{title}
|
|
68
|
-
</
|
|
71
|
+
</Heading>
|
|
69
72
|
</div>
|
|
70
73
|
<Icon
|
|
71
74
|
name="arrow-right"
|
|
@@ -96,9 +99,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
|
|
|
96
99
|
<p class={eyebrowClass ?? 'text-xs font-medium uppercase tracking-[0.16em] text-primary'}>
|
|
97
100
|
{eyebrow}
|
|
98
101
|
</p>
|
|
99
|
-
<
|
|
102
|
+
<Heading class="text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
|
|
100
103
|
{title}
|
|
101
|
-
</
|
|
104
|
+
</Heading>
|
|
102
105
|
{description && (
|
|
103
106
|
<p class="text-sm text-muted-foreground leading-relaxed line-clamp-2">{description}</p>
|
|
104
107
|
)}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
/**
|
|
3
3
|
* BreadcrumbBand — the muted strip under the fixed header that holds a page's breadcrumb trail (default slot).
|
|
4
|
-
* `ignore` keeps it out of the Pagefind body. `class` replaces the band's own classes (keep `
|
|
4
|
+
* `ignore` keeps it out of the Pagefind body. `class` replaces the band's own classes (keep `HEADER_OFFSET_PT` from `./headerOffset.ts`, the header offset).
|
|
5
5
|
*/
|
|
6
6
|
import Container from './Container.astro';
|
|
7
|
+
import { HEADER_OFFSET_PT } from './headerOffset.ts';
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
9
10
|
ignore?: boolean;
|
|
10
11
|
class?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const { ignore = true, class: className =
|
|
14
|
+
const { ignore = true, class: className = `${HEADER_OFFSET_PT} bg-muted/50 border-b border-border` } = Astro.props;
|
|
14
15
|
---
|
|
15
16
|
|
|
16
17
|
<div class={className} data-pagefind-ignore={ignore ? '' : undefined}>
|
|
@@ -169,7 +169,7 @@ const isArticleMeta = Boolean(articleAuthorUrl || publishedTime || modifiedTime
|
|
|
169
169
|
|
|
170
170
|
{Astro.slots.has('nav') && <div data-pagefind-ignore><slot name="nav" /></div>}
|
|
171
171
|
|
|
172
|
-
<div id="main-content" class:list={[mainClass, 'flex-1']}>
|
|
172
|
+
<div id="main-content" tabindex="-1" class:list={[mainClass, 'flex-1 focus:outline-none']}>
|
|
173
173
|
<slot />
|
|
174
174
|
</div>
|
|
175
175
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Classes that clear the fixed site header: 4rem, or the nav plus its trending bar where `SiteHeader` sets `--site-header-offset`. */
|
|
2
|
+
export const HEADER_OFFSET_PT = 'pt-[var(--site-header-offset,4rem)]';
|
|
3
|
+
export const HEADER_OFFSET_TOP = 'top-[var(--site-header-offset,4rem)]';
|
|
@@ -28,7 +28,7 @@ const look = emphasis
|
|
|
28
28
|
href={link.href}
|
|
29
29
|
aria-current={active ? 'page' : undefined}
|
|
30
30
|
class:list={[
|
|
31
|
-
`flex items-center gap-3 px-4 py-2.5 text-sm ${look} hover:bg-muted transition-colors focus-visible:ring-2 ${t.ring} focus-visible:ring-offset-2`,
|
|
31
|
+
`flex min-h-11 items-center gap-3 px-4 py-2.5 text-sm ${look} hover:bg-muted transition-colors focus-visible:ring-2 ${t.ring} focus-visible:ring-offset-2`,
|
|
32
32
|
active && !emphasis && `${t.text} font-medium`,
|
|
33
33
|
className,
|
|
34
34
|
]}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* The ids default to the ones the sites reserve (`main-nav`, `mobile-menu`, `mobile-menu-btn`). The panel sits outside
|
|
12
12
|
* `<nav>`, so it carries its own `data-pagefind-ignore`.
|
|
13
13
|
*/
|
|
14
|
-
import Container from '../layout/Container.astro';
|
|
15
14
|
import { Icon } from '../primitives/index.ts';
|
|
16
15
|
import { getLabels } from '../internal/labels';
|
|
16
|
+
import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
|
|
17
17
|
|
|
18
18
|
export interface TrendingTopicLink {
|
|
19
19
|
label: string;
|
|
@@ -65,6 +65,7 @@ const xl = desktopBreakpoint === 'xl';
|
|
|
65
65
|
id={id}
|
|
66
66
|
class:list={['site-header', className]}
|
|
67
67
|
data-site-nav
|
|
68
|
+
data-desktop-breakpoint={desktopBreakpoint}
|
|
68
69
|
data-search-path={searchPath}
|
|
69
70
|
data-search-base={searchPath ? import.meta.env.BASE_URL : undefined}
|
|
70
71
|
>
|
|
@@ -94,25 +95,25 @@ const xl = desktopBreakpoint === 'xl';
|
|
|
94
95
|
</div>
|
|
95
96
|
</div>
|
|
96
97
|
</nav>{trendingTags.length > 0 && (
|
|
97
|
-
<div class="hidden md:block border-t border-border/60 bg-muted/40">
|
|
98
|
-
<
|
|
99
|
-
<span class="font-semibold uppercase tracking-widest text-primary shrink-0
|
|
98
|
+
<div class="hidden md:block border-t border-border/60 bg-muted/40" data-site-trending>
|
|
99
|
+
<div class="mx-auto max-w-shell px-4 sm:px-6 lg:px-8 flex items-center justify-center gap-3 h-11 text-xs">
|
|
100
|
+
<span class="font-semibold uppercase tracking-widest text-primary shrink-0">{trendingLabel}</span>
|
|
100
101
|
<span class="text-border shrink-0" aria-hidden="true">|</span>
|
|
101
|
-
<ul class="flex items-center gap-4
|
|
102
|
+
<ul class="flex items-center gap-4 min-w-0 overflow-x-auto">
|
|
102
103
|
{trendingTags.map((tag) => (
|
|
103
104
|
<li>
|
|
104
|
-
<a href={tag.href} class="text-muted-foreground hover:text-foreground transition-colors font-medium whitespace-nowrap">
|
|
105
|
+
<a href={tag.href} class="flex h-11 items-center text-muted-foreground hover:text-foreground transition-colors font-medium whitespace-nowrap">
|
|
105
106
|
#{tag.label}
|
|
106
107
|
</a>
|
|
107
108
|
</li>
|
|
108
109
|
))}
|
|
109
110
|
</ul>
|
|
110
|
-
</
|
|
111
|
+
</div>
|
|
111
112
|
</div>
|
|
112
113
|
)}
|
|
113
114
|
</header>
|
|
114
115
|
|
|
115
|
-
<div id={panelId} class:list={[xl ? 'xl:hidden' : 'lg:hidden', 'hidden fixed inset-x-0
|
|
116
|
+
<div id={panelId} class:list={[xl ? 'xl:hidden' : 'lg:hidden', 'hidden fixed inset-x-0 bottom-0 z-50 overflow-y-auto overscroll-contain', HEADER_OFFSET_TOP, surfaceClass]} data-pagefind-ignore>
|
|
116
117
|
<div class="flex flex-col pt-2 pb-12 border-t border-border relative">
|
|
117
118
|
<slot name="mobile" />
|
|
118
119
|
</div>
|
|
@@ -131,6 +132,13 @@ const xl = desktopBreakpoint === 'xl';
|
|
|
131
132
|
overflow: hidden;
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
/* The fixed header is the 4rem nav plus, from md, the 2.75rem trending bar and its 1px rule: `--site-header-offset` is what a band under it clears. */
|
|
136
|
+
@media (min-width: 768px) {
|
|
137
|
+
:global(:root:has([data-site-trending])) {
|
|
138
|
+
--site-header-offset: calc(4rem + 2.75rem + 1px);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
/* The icons are Icon components, which scoped selectors do not reach. */
|
|
135
143
|
.site-header-toggle :global(.menu-close-icon),
|
|
136
144
|
.site-header-toggle[aria-expanded='true'] :global(.menu-open-icon) {
|
|
@@ -113,8 +113,13 @@ function searchPathOf(root: HTMLElement): string | null {
|
|
|
113
113
|
return (window.location.pathname.indexOf(compiled) === 0 ? compiled : '') + path;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
const DESKTOP_MIN_WIDTH = { lg: '64rem', xl: '80rem' } as const;
|
|
117
|
+
type DesktopBreakpoint = keyof typeof DESKTOP_MIN_WIDTH;
|
|
118
|
+
const breakpointOf = (root: HTMLElement): DesktopBreakpoint => (root.dataset.desktopBreakpoint === 'xl' ? 'xl' : 'lg');
|
|
119
|
+
|
|
120
|
+
function closeOpenMobileMenus(refocus: boolean, breakpoint?: DesktopBreakpoint): void {
|
|
117
121
|
roots().forEach((root) => {
|
|
122
|
+
if (breakpoint && breakpointOf(root) !== breakpoint) return;
|
|
118
123
|
const toggle = root.querySelector<HTMLButtonElement>('[data-mobile-menu-toggle]');
|
|
119
124
|
if (toggle?.getAttribute('aria-expanded') === 'true') setMobileMenu(root, toggle, false, refocus);
|
|
120
125
|
});
|
|
@@ -145,9 +150,11 @@ function bindDocument(): void {
|
|
|
145
150
|
window.location.assign(`${searchPath}?focus=1`);
|
|
146
151
|
});
|
|
147
152
|
|
|
148
|
-
// Tailwind
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
// Past its breakpoint (Tailwind lg: or xl:) a header's panel hides itself, so the body scroll lock must go with it.
|
|
154
|
+
(Object.keys(DESKTOP_MIN_WIDTH) as DesktopBreakpoint[]).forEach((breakpoint) => {
|
|
155
|
+
window.matchMedia(`(min-width: ${DESKTOP_MIN_WIDTH[breakpoint]})`).addEventListener('change', (event) => {
|
|
156
|
+
if (event.matches) closeOpenMobileMenus(false, breakpoint);
|
|
157
|
+
});
|
|
151
158
|
});
|
|
152
159
|
}
|
|
153
160
|
|