diff --git a/preview-src/preview-status-test.adoc b/preview-src/preview-status-test.adoc new file mode 100644 index 00000000..a1ef4d38 --- /dev/null +++ b/preview-src/preview-status-test.adoc @@ -0,0 +1,16 @@ += Preview Status Test Page +:page-preview: true +:description: This page tests the Preview status badge in the UI preview. + +This page demonstrates the **Preview** status badge. + +== Badge locations + +1. **In the sticky header** below the title: a dark "Preview" pill +2. **In the left nav**: "(Preview)" after the page title (only when a content catalog is available; may not render in the gulp preview) + +== Test the tooltip + +Hover the Preview pill. Default text: + +_"This feature is in preview and may change."_ diff --git a/preview-src/ui-model.yml b/preview-src/ui-model.yml index 740c3faf..38a5c01f 100644 --- a/preview-src/ui-model.yml +++ b/preview-src/ui-model.yml @@ -232,6 +232,12 @@ page: - content: Home page url: /streaming/24.3/home.html urlType: internal + - content: Limited Availability Test + url: /limited-availability-test.html + urlType: internal + - content: Preview Status Test + url: /preview-status-test.html + urlType: internal - content: Get Started url: '#' urlType: internal @@ -448,9 +454,6 @@ page: - content: Data Loss Prevention url: '#' urlType: internal - - content: Limited Availability Test - url: /streaming/24.3/limited-availability-test.html - urlType: internal - content: Dev Tools url: '#' urlType: internal diff --git a/src/css/doc.css b/src/css/doc.css index fa97b04a..21d0c564 100644 --- a/src/css/doc.css +++ b/src/css/doc.css @@ -460,6 +460,12 @@ html[data-theme="dark"] .component-indicator-sticky .sm-ver-pill-caret { border: 1px solid #fcd34d; } +.status-badge--preview { + background: #1f2937; + color: #f9fafb; + border: 1px solid #111827; +} + .status-badge--la { background: #ede9fe; color: #5b21b6; @@ -472,6 +478,12 @@ html[data-theme="dark"] .status-badge--beta { border-color: rgba(251, 191, 36, 0.3); } +html[data-theme="dark"] .status-badge--preview { + background: rgba(148, 163, 184, 0.15); + color: #cbd5e1; + border-color: rgba(148, 163, 184, 0.3); +} + html[data-theme="dark"] .status-badge--la { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; diff --git a/src/css/metadata.css b/src/css/metadata.css index 637ae915..171ba054 100644 --- a/src/css/metadata.css +++ b/src/css/metadata.css @@ -167,6 +167,18 @@ color: var(--beta-label-color); } +/* Preview */ +.badge--preview { + color: var(--preview-label-background); + font-weight: bold; + background-color: var(--link-highlight-background-color); +} + +.badge--large.badge--preview { + background-color: var(--preview-label-background); + color: var(--preview-label-color); +} + .beta-label { display: inline-flex; margin: 0; diff --git a/src/css/nav.css b/src/css/nav.css index 6265ced0..6a362920 100644 --- a/src/css/nav.css +++ b/src/css/nav.css @@ -673,6 +673,13 @@ html[data-theme="light"] .nav-item-toggle { white-space: nowrap; } +.nav-link.cloud-preview::after { + display: inline; + content: '(Preview)'; + margin-left: 4px; + white-space: nowrap; +} + .nav-link.cloud-limited-availability::after { display: inline; content: '(Limited)'; diff --git a/src/css/vars.css b/src/css/vars.css index fe4615e0..8b94408f 100644 --- a/src/css/vars.css +++ b/src/css/vars.css @@ -127,6 +127,8 @@ html[data-theme=dark] { --beta-label-color: #fff; --beta-label-background: var(--link-highlight-color); --beta-label-border: var(--slate-800); + --preview-label-background: #1f2937; + --preview-label-color: #f9fafb; --limited-availability-label-color: #fff; --limited-availability-label-background: var(--default-header-color); --limited-availability-label-border: var(--amber-800); @@ -196,6 +198,9 @@ html[data-theme=dark] { --byoc-label-color: #101828; --byoc-label-background: #4da8da; --byoc-highlight-background-color: rgba(77, 168, 218, 0.15); + /* Preview badge - dark mode */ + --preview-label-background: #cbd5e1; + --preview-label-color: #1f2937; /* Cloud badge - brighter purple for dark mode visibility with dark text for contrast */ --cloud-label-color: #101828; --cloud-label-background: #9d97ff; diff --git a/src/helpers/is-preview-feature.js b/src/helpers/is-preview-feature.js new file mode 100644 index 00000000..f94603c8 --- /dev/null +++ b/src/helpers/is-preview-feature.js @@ -0,0 +1,26 @@ +'use strict' + +// Cache: Map> +let urlCache = null +let cachedComponent = null + +module.exports = (navUrl, { data: { root } }) => { + const { contentCatalog, page } = root + if (page.layout === '404') return false + if (!contentCatalog) return false + + // Build URL map once per component (O(n) once, then O(1) lookups) + if (cachedComponent !== page.component.name) { + urlCache = new Map() + cachedComponent = page.component.name + + const pages = contentCatalog.findBy({ component: page.component.name, family: 'page' }) + for (const p of pages) { + if (p.pub?.url) { + urlCache.set(p.pub.url, !!p.asciidoc?.attributes?.['page-preview']) + } + } + } + + return urlCache.get(navUrl) || false +} diff --git a/src/partials/article.hbs b/src/partials/article.hbs index 0a19d237..936dcdf7 100644 --- a/src/partials/article.hbs +++ b/src/partials/article.hbs @@ -24,10 +24,13 @@ {{/with}} {{> version-selector}} - {{!-- Status badges: Beta, Limited Availability --}} + {{!-- Status badges: Beta, Preview, Limited Availability --}} {{#if page.attributes.beta}} beta {{/if}} + {{#if page.attributes.preview}} + Preview + {{/if}} {{#if page.attributes.limited-availability}} @@ -113,7 +116,7 @@ {{!-- Metadata now shown in sticky bar above --}} {{/unless}} -{{#if (or page.attributes.beta page.attributes.limited-availability page.attributes.byoc page.attributes.cloud-only page.attributes.context-switcher)}} +{{#if (or page.attributes.beta page.attributes.preview page.attributes.limited-availability page.attributes.byoc page.attributes.cloud-only page.attributes.context-switcher)}}
{{#if ./url}} - {{{./content}}} {{else}}