Skip to content

docs: add dynamic topbar banner#2603

Open
p-malecki wants to merge 1 commit into
software-mansion:mainfrom
p-malecki:@p-malecki/add-topbar-banner
Open

docs: add dynamic topbar banner#2603
p-malecki wants to merge 1 commit into
software-mansion:mainfrom
p-malecki:@p-malecki/add-topbar-banner

Conversation

@p-malecki

Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings June 12, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TopBarBanner into PageLayout.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>("*")),
]);
@p-malecki p-malecki force-pushed the @p-malecki/add-topbar-banner branch from 976bf80 to 83542c6 Compare June 12, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants