docs: add dynamic topbar banner#2603
Open
p-malecki wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a rotating top-bar banner to the TypeGPU docs layout with a preload/reservation mechanism to reduce layout shift.
Changes:
- Integrates
TopBarBannerintoPageLayout.astro, including an inline<head>reservation script. - Introduces shared utilities and configuration for banner zones/hidden paths.
- Implements a client-side rotating Revive banner component with per-zone caching of layout metrics.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/typegpu-docs/src/layouts/PageLayout.astro | Mounts the banner and injects a prerendered reservation script to reduce CLS. |
| apps/typegpu-docs/src/components/TopBarBanner/shared.ts | Adds cache keying, CSS var naming, hidden-path logic, and the inline reservation script generator. |
| apps/typegpu-docs/src/components/TopBarBanner/index.ts | Provides a public barrel export for the banner module. |
| apps/typegpu-docs/src/components/TopBarBanner/config.ts | Defines banner zones, rotation interval, and paths where the banner should be hidden. |
| apps/typegpu-docs/src/components/TopBarBanner/TopBarBannerClient.tsx | Implements the client component: Revive loader, measurement/caching, and rotation logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+293
to
+298
| * Rotation interval in ms — time the active banner is held before the next | ||
| * slide starts. Defaults to 1000. Floored at the slide duration ({@link | ||
| * SLIDE_MS}) so ticks aren't silently dropped mid-slide. Single zone never | ||
| * rotates. | ||
| */ | ||
| rotateIntervalMs?: number; |
Comment on lines
+80
to
+83
| const isTransparent = (color: string) => | ||
| !color || | ||
| color === "transparent" || | ||
| /^rgba?\([^)]*,\s*0\s*\)$/.test(color.replace(/\s+/g, " ")); |
Comment on lines
+47
to
+55
| `var raw=localStorage.getItem(k);if(!raw)return;` + | ||
| `var c=JSON.parse(raw);` + | ||
| `if(!c||typeof c.height!=="number"||c.height<${MIN_VISIBLE_HEIGHT})return;` + | ||
| `if(Date.now()-c.timestamp>=${CACHE_TTL_MS})return;` + | ||
| `var r=document.documentElement;` + | ||
| `r.style.setProperty(${JSON.stringify(vars.height)},c.height+"px");` + | ||
| `if(typeof c.bgColor==="string")r.style.setProperty(${JSON.stringify( | ||
| vars.bg | ||
| )},c.bgColor);` + |
Comment on lines
+97
to
+110
| const direct = findOpaqueBg([ | ||
| root, | ||
| ...Array.from(root.querySelectorAll<HTMLElement>("*")), | ||
| ]); | ||
| if (direct) return direct; | ||
|
|
||
| for (const frame of Array.from(root.querySelectorAll("iframe"))) { | ||
| try { | ||
| const doc = frame.contentDocument; | ||
| if (!doc?.body) continue; | ||
| const fromFrame = findOpaqueBg([ | ||
| doc.body, | ||
| ...Array.from(doc.body.querySelectorAll<HTMLElement>("*")), | ||
| ]); |
976bf80 to
83542c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a topbar banner to the landing page. Content is served server-side via external service, so banners can be swapped, rotated, or pulled without any repo change or redeploy.
It's hidden on the docs, blog and examples pages - this can be discussed.
Banners are currently hidden.