Skip to content

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

Open
micheleRP wants to merge 6 commits into
mainfrom
adp-preview-badge
Open

Add Preview status badge support (page-preview attribute)#398
micheleRP wants to merge 6 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 6b1c71b
🔍 Latest deploy log https://app.netlify.com/projects/docs-ui/deploys/6a4dc2ee43bcf50008d8fe15
😎 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: 31 (🟢 up 1 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

📝 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adp-preview-badge

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/css/doc.css

Parsing error: Unexpected token {

src/css/metadata.css

Parsing error: Unexpected token .

src/css/nav.css

Parsing error: Unexpected token :

  • 1 others

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

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.

1 participant