diff --git a/src/components/next/BlogPostPage.astro b/src/components/next/BlogPostPage.astro index 0474c91..52d0b34 100644 --- a/src/components/next/BlogPostPage.astro +++ b/src/components/next/BlogPostPage.astro @@ -118,16 +118,28 @@ const pageDescription = post.data.seoDescription ?? post.data.description;
{toc.length >= 3 && ( - +
+
+ +
+ + +
+
+
)}
@@ -260,9 +272,10 @@ const pageDescription = post.data.seoDescription ?? post.data.description; .bp-body { padding-block: clamp(2.5rem, 6vw, 4rem) clamp(3rem, 7vw, 5rem); } - /* ── Contents: a quiet list, not a widget ────────────────────────────── */ + /* ── Contents: a quiet list at rest, a pinned dropdown while reading ─── */ + .bp-toc-slot { margin: 0 0 2.75rem; } + .bp-toc-float { position: relative; } .bp-toc { - margin: 0 0 2.75rem; padding: 1.25rem 1.4rem; border-radius: 1.25rem; background: var(--color-warm); @@ -288,7 +301,62 @@ const pageDescription = post.data.seoDescription ?? post.data.description; color: var(--color-ink-soft); text-decoration: none; } - .bp-toc a:hover { color: var(--color-ink); text-decoration: underline; text-underline-offset: 0.2em; } + .bp-toc a:hover, + .bp-toc a.is-active { color: var(--color-ink); text-decoration: underline; text-underline-offset: 0.2em; } + + .bp-toc-select { display: none; position: relative; } + .bp-toc-select__label { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + } + .bp-toc-select select { + width: 100%; + appearance: none; + -webkit-appearance: none; + padding: 0.7rem 2.5rem 0.7rem 1.1rem; + border: 0; + border-radius: 999px; + background: transparent; + font: inherit; + font-size: 0.9rem; + font-weight: 500; + color: var(--color-ink); + text-overflow: ellipsis; + cursor: pointer; + } + .bp-toc-select::after { + content: ""; + position: absolute; + right: 1.1rem; + top: 50%; + width: 0.45rem; + height: 0.45rem; + border-right: 1.5px solid var(--color-ink-faint); + border-bottom: 1.5px solid var(--color-ink-faint); + transform: translateY(-70%) rotate(45deg); + pointer-events: none; + } + .bp-toc-float.is-fixed { + position: fixed; + top: 4.75rem; + left: 50%; + transform: translateX(-50%); + z-index: 45; + width: min(22rem, calc(100% - 2rem)); + border-radius: 999px; + background: color-mix(in srgb, var(--color-paper) 82%, transparent); + backdrop-filter: saturate(1.6) blur(18px); + -webkit-backdrop-filter: saturate(1.6) blur(18px); + box-shadow: + 0 0 0 1px color-mix(in srgb, var(--color-ink) 7%, transparent), + 0 8px 28px -12px rgba(15, 23, 42, 0.22); + } + .bp-toc-float.is-fixed .bp-toc { display: none; } + .bp-toc-float.is-fixed .bp-toc-select { display: block; } /* ── Prose ───────────────────────────────────────────────────────────── */ .bp-prose { @@ -307,7 +375,7 @@ const pageDescription = post.data.seoDescription ?? post.data.description; font-weight: 600; color: var(--color-ink); text-wrap: balance; - scroll-margin-top: 7rem; + scroll-margin-top: 9rem; } .bp-prose :global(h2) { margin: 2.4em 0 0.6em; @@ -516,3 +584,57 @@ const pageDescription = post.data.seoDescription ?? post.data.description; } .bp-more__all { margin: 2rem 0 0; text-align: center; } + +