Skip to content

Add Preview status badge support (page-preview attribute)#398

Merged
micheleRP merged 8 commits into
mainfrom
adp-preview-badge
Jul 8, 2026
Merged

Add Preview status badge support (page-preview attribute)#398
micheleRP merged 8 commits into
mainfrom
adp-preview-badge

Conversation

@micheleRP

Copy link
Copy Markdown
Contributor

What

Adds first-class Preview maturity-badge support to the theme, cloned from the existing beta machinery (which is untouched):

  • :page-preview: true renders a (Preview) pill on sidebar nav links (is-preview-feature helper + cloud-preview class), and a Preview status pill in the sticky page header with a tippy tooltip. Tooltip text defaults to "This feature is in preview and may change." and can be overridden with :page-preview-text:.
  • badge:preview[label=Preview] (the badge inline macro) gets .badge--preview / .badge--large.badge--preview styling via new --preview-label-* theme variables, with dark-mode overrides matching the sibling badges.
  • Includes preview-src/preview-status-test.adoc for the local UI preview.

Why

The Agentic Data Plane UI (ai.redpanda.com) now labels pre-GA features with a single Preview tag. The ADP docs are moving from beta to Preview to match; an upcoming adp-docs PR consumes this. Other components' beta badges are unaffected.

Verification

  • npx gulp preview:build: compiled test page HTML contains the badge span and default tooltip; compiled site.css contains the new classes and both light/dark variable definitions.
  • Beta badge regression-checked (still renders unchanged).

Note for release

The adp-docs change depends on this reaching the releases/latest ui-bundle, so a v* tag after merge would be appreciated.

🤖 Generated with Claude Code

@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for docs-ui ready!

Name Link
🔨 Latest commit 4c00489
🔍 Latest deploy log https://app.netlify.com/projects/docs-ui/deploys/6a4e75b35d633c0008332a6d
😎 Deploy Preview https://deploy-preview-398--docs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 27 (🔴 down 3 from production)
Accessibility: 89 (no change from production)
Best Practices: 92 (no change from production)
SEO: 89 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ecdb8dc-4888-43c9-bd96-430912c875c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a new "Preview" status indicator feature. A helper function (is-preview-feature.js) determines whether a page's URL should show a preview badge based on cached page-preview attribute mappings. This helper is wired into the navigation tree (adding a cloud-preview class) and the article sticky header (rendering a status-badge--preview element with tooltip). Corresponding CSS variables and styles are added for light/dark themes, and a new AsciiDoc test page documents expected badge placements.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Template as nav-tree.hbs / article.hbs
  participant Helper as is-preview-feature.js
  participant Catalog as contentCatalog

  Template->>Helper: is-preview-feature(navUrl, page)
  alt cache stale or missing component
    Helper->>Catalog: read pages' asciidoc attributes
    Catalog-->>Helper: page-preview values
    Helper->>Helper: build urlCache Map keyed by pub.url
  end
  Helper-->>Template: boolean (preview enabled)
  Template->>Template: apply cloud-preview class / render status-badge--preview
Loading

Related Issues: None mentioned
Related PRs: None mentioned
Suggested labels: enhancement, css, documentation
Suggested reviewers: None specified


Poem:
A rabbit spots a badge anew, 🐇
"Preview" in soft glowing hue,
Nav links whisper, headers gleam,
Tooltips hint at what's a dream,
Cached URLs, a lookup neat—
Hop along, this feature's sweet!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding Preview status badge support for the page-preview attribute.
Description check ✅ Passed The description is directly about the implemented Preview badge support and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adp-preview-badge

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
src/helpers/is-preview-feature.js (1)

9-13: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Missing guard for page.component before dereferencing .name.

Line 9-10 guard against page.layout === '404' and a missing contentCatalog, but Line 13 dereferences page.component.name without checking page.component exists. If any page lacks a component (e.g., synthetic/generated pages), this throws.

🛡️ Defensive guard
-  if (!contentCatalog) return false
+  if (!contentCatalog || !page.component) return false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/helpers/is-preview-feature.js` around lines 9 - 13, Add a defensive guard
in isPreviewFeature before accessing page.component.name, since some pages may
not have a component and would throw here. Update the cachedComponent check to
safely handle missing page.component (and its name) while keeping the existing
early returns for page.layout === '404' and missing contentCatalog. Use
isPreviewFeature and the cachedComponent/page.component.name access as the key
locations to adjust.
src/css/doc.css (1)

463-486: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Hardcoded colors duplicate and diverge from the new vars.css preview tokens.

Light mode here hardcodes #1f2937/#f9fafb which happens to match the --preview-label-background/--preview-label-color defaults in vars.css, but the dark-mode override uses a different visual scheme (rgba(148, 163, 184, 0.15) background + #cbd5e1 text) than the dark override defined in vars.css (--preview-label-background: #cbd5e1 solid + `--preview-label-color: `#1f2937 text). This means the sticky-header pill and the inline badge:preview macro (styled via metadata.css using the vars) will render with inconsistent color treatments in dark mode, and any future palette tweak to the vars won't propagate here.

♻️ Proposed fix to consume shared tokens
 .status-badge--preview {
-  background: `#1f2937`;
-  color: `#f9fafb`;
-  border: 1px solid `#111827`;
+  background: var(--preview-label-background);
+  color: var(--preview-label-color);
+  border: 1px solid var(--preview-label-border, `#111827`);
 }
 html[data-theme="dark"] .status-badge--preview {
-  background: rgba(148, 163, 184, 0.15);
-  color: `#cbd5e1`;
-  border-color: rgba(148, 163, 184, 0.3);
+  background: var(--preview-label-background);
+  color: var(--preview-label-color);
+  border-color: var(--preview-label-border, rgba(148, 163, 184, 0.3));
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/css/doc.css` around lines 463 - 486, The preview badge styles in
status-badge--preview are hardcoding colors instead of using the shared preview
tokens from vars.css, which causes dark-mode inconsistency with metadata.css and
the badge:preview macro. Update the status-badge--preview rules to consume the
preview CSS variables (including the dark-theme values) so the sticky-header
pill stays aligned with the shared token set and future palette changes
propagate automatically.
preview-src/preview-status-test.adoc (1)

1-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider documenting the inline badge:preview[] macro too.

The PR objective mentions badge:preview[label=Preview] inline macro support, but this test page only covers the nav "(Preview)" indicator and sticky-header pill, not the inline badge macro. Adding a short section exercising badge:preview[label=Preview] would give full visual coverage for this cohort.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@preview-src/preview-status-test.adoc` around lines 1 - 17, The Preview status
test page currently covers the sticky-header pill and nav indicator, but not the
inline `badge:preview[]` macro. Update the `preview-status-test.adoc` content to
add a short section that explicitly renders `badge:preview[label=Preview]` so
the preview badge cohort is fully exercised. Keep the existing `Preview Status
Test Page` structure and place the new example near the other badge
demonstrations for easy discovery.
src/css/vars.css (1)

130-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

New preview tokens aren't consumed consistently by the sticky-header badge.

These --preview-label-background/--preview-label-color tokens are correctly used by metadata.css's .badge--large.badge--preview, but doc.css's .status-badge--preview hardcodes its own hex/rgba values instead (see comment there) — including dark-mode values that don't match these overrides. Consider having doc.css consume these variables directly to avoid theme drift.

Also note beta defines --beta-label-border but no equivalent --preview-label-border was added, leaving doc.css to hardcode border colors for the preview badge.

Also applies to: 201-203

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/css/vars.css` around lines 130 - 131, The preview badge styles are still
hardcoding colors in doc.css instead of consuming the new preview tokens, which
causes theme drift with metadata.css. Update the status-badge--preview styling
to use --preview-label-background and --preview-label-color directly, and add a
matching --preview-label-border token alongside the existing preview tokens so
the border color can be sourced the same way instead of using hardcoded hex/rgba
values. Keep the change aligned with the existing badge token usage in the
preview-related CSS selectors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@preview-src/preview-status-test.adoc`:
- Around line 1-17: The Preview status test page currently covers the
sticky-header pill and nav indicator, but not the inline `badge:preview[]`
macro. Update the `preview-status-test.adoc` content to add a short section that
explicitly renders `badge:preview[label=Preview]` so the preview badge cohort is
fully exercised. Keep the existing `Preview Status Test Page` structure and
place the new example near the other badge demonstrations for easy discovery.

In `@src/css/doc.css`:
- Around line 463-486: The preview badge styles in status-badge--preview are
hardcoding colors instead of using the shared preview tokens from vars.css,
which causes dark-mode inconsistency with metadata.css and the badge:preview
macro. Update the status-badge--preview rules to consume the preview CSS
variables (including the dark-theme values) so the sticky-header pill stays
aligned with the shared token set and future palette changes propagate
automatically.

In `@src/css/vars.css`:
- Around line 130-131: The preview badge styles are still hardcoding colors in
doc.css instead of consuming the new preview tokens, which causes theme drift
with metadata.css. Update the status-badge--preview styling to use
--preview-label-background and --preview-label-color directly, and add a
matching --preview-label-border token alongside the existing preview tokens so
the border color can be sourced the same way instead of using hardcoded hex/rgba
values. Keep the change aligned with the existing badge token usage in the
preview-related CSS selectors.

In `@src/helpers/is-preview-feature.js`:
- Around line 9-13: Add a defensive guard in isPreviewFeature before accessing
page.component.name, since some pages may not have a component and would throw
here. Update the cachedComponent check to safely handle missing page.component
(and its name) while keeping the existing early returns for page.layout ===
'404' and missing contentCatalog. Use isPreviewFeature and the
cachedComponent/page.component.name access as the key locations to adjust.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3416368-8ccb-4625-9001-33a4dbf0c9a4

📥 Commits

Reviewing files that changed from the base of the PR and between 42657e2 and 6b1c71b.

📒 Files selected for processing (8)
  • preview-src/preview-status-test.adoc
  • src/css/doc.css
  • src/css/metadata.css
  • src/css/nav.css
  • src/css/vars.css
  • src/helpers/is-preview-feature.js
  • src/partials/article.hbs
  • src/partials/nav-tree.hbs

@JakeSCahill

Copy link
Copy Markdown
Contributor

@micheleRP could we add the preview page to the nav tree so I can find it to test.

@micheleRP

Copy link
Copy Markdown
Contributor Author

Done in acde98d. The page is now in the preview nav under Troubleshooting > Preview Status Test, and here's a direct link on this PR's deploy preview: https://deploy-preview-398--docs-ui.netlify.app/preview-status-test.html

You can also see the changes on a real site build: the adp-docs PR that consumes this (redpanda-data/adp-docs#126) has a deploy preview built with this branch's bundle, for example https://deploy-preview-126--redpanda-agentic-data-plane.netlify.app/agentic-data-plane/connect/managed/managed-catalog/ (catalog badges, header pills, and sidebar pills).

One unrelated thing I noticed: the neighboring Limited Availability Test nav link 404s on deploy previews (it points at /streaming/24.3/..., but the page is served at the root). Left as is since it's not part of this PR.

@JakeSCahill

Copy link
Copy Markdown
Contributor

One unrelated thing I noticed: the neighboring Limited Availability Test nav link 404s on deploy previews (it points at /streaming/24.3/..., but the page is served at the root). Left as is since it's not part of this PR.

We may as well fix it.

I don't think Troubleshooting is a good place for the preview. Most previews should go under Quickstarts because it's expanded by default.

@JakeSCahill
JakeSCahill self-requested a review July 8, 2026 15:48
Quickstart is expanded by default, so the Preview Status Test and
Limited Availability Test pages are easier to find there. Also corrects
the Limited Availability Test URL, which pointed at /streaming/24.3/
while the page is served at the site root.
@micheleRP

Copy link
Copy Markdown
Contributor Author

Done in 4c00489: moved Preview Status Test under Quickstart, and moved Limited Availability Test there too with its URL fixed (it now points at /limited-availability-test.html, where the page is actually served). Both verified clickable on the deploy preview: https://deploy-preview-398--docs-ui.netlify.app/

One scoping question: the other Quickstart nav links (Bloblang Syntax, Bloblang Playground, Property Tooltips, Home page, and the Hardware & Software Requirements entry) 404 the same way, because they also point at /streaming/24.3/ while the pages are served at the root. Want me to fix those in this PR as well, or leave them for a separate cleanup?

@JakeSCahill

Copy link
Copy Markdown
Contributor

Looks good. Makes sense to fix any issues here.

also when this is merged, you’ll need to push a new version tag to kick off the build and publish the release.

@micheleRP
micheleRP merged commit b33c277 into main Jul 8, 2026
6 checks passed
@micheleRP
micheleRP deleted the adp-preview-badge branch July 8, 2026 18:25
micheleRP added a commit to redpanda-data/adp-docs that referenced this pull request Jul 8, 2026
redpanda-data/docs-ui#398 merged and v3.1.6 shipped with page-preview
theme support (verified: catalog badges, header pills, sidebar pills,
and dark-mode CSS vars all render against the real released bundle).
Points local-antora-playbook.yml back at releases/latest and drops the
temporary local bundle used for PR 126's deploy preview.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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