From c188399d32bc55b03d4daf150fd1894c87ae50f2 Mon Sep 17 00:00:00 2001
From: Cory Rylan
Date: Fri, 31 Jul 2026 11:24:41 -0500
Subject: [PATCH] chore(docs): add component preview to card list
- add small inline preview of the component to the card
- large components like monaco have small mock html/css inlined visuals
Signed-off-by: Cory Rylan
---
projects/core/src/dialog/dialog.ts | 2 +-
projects/core/src/drawer/drawer.ts | 2 +-
projects/core/src/gauge/gauge.examples.ts | 5 +-
.../core/src/notification/notification.ts | 2 +-
projects/core/src/toast/toast.ts | 2 +-
projects/core/src/tooltip/tooltip.ts | 2 +-
.../src/markdown/markdown.examples.ts | 2 +-
projects/site/package.json | 10 +-
projects/site/src/_11ty/layouts/common.js | 33 +-
projects/site/src/_11ty/layouts/docs.css | 29 +-
projects/site/src/_11ty/libraries/markdown.js | 28 +-
projects/site/src/_11ty/shortcodes/api.js | 36 +-
projects/site/src/_11ty/shortcodes/example.js | 1 +
projects/site/src/docs/elements/index.11ty.js | 547 +++++++++++++++++-
14 files changed, 610 insertions(+), 91 deletions(-)
diff --git a/projects/core/src/dialog/dialog.ts b/projects/core/src/dialog/dialog.ts
index 0492ceb136..744e6b93e1 100644
--- a/projects/core/src/dialog/dialog.ts
+++ b/projects/core/src/dialog/dialog.ts
@@ -21,7 +21,7 @@ import styles from './dialog.css?inline';
/**
* @element nve-dialog
- * @description Dialog is a component that appears above main content. A modal dialog displays critical information that requires user attention and interrupts user flow. [MDN Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
+ * @description Dialog is a component that appears above main content. A modal dialog displays critical information that requires user attention and interrupts user flow.
* @documentation https://nvidia.github.io/elements/docs/elements/dialog/
* @since 0.6.0
* @entrypoint \@nvidia-elements/core/dialog
diff --git a/projects/core/src/drawer/drawer.ts b/projects/core/src/drawer/drawer.ts
index da9a02c59d..37369391ce 100644
--- a/projects/core/src/drawer/drawer.ts
+++ b/projects/core/src/drawer/drawer.ts
@@ -18,7 +18,7 @@ import styles from './drawer.css?inline';
/**
* @element nve-drawer
- * @description Drawer are to display content that is out of context of the rest of the page (notifications, navigation, settings). Or use [Panel](./docs/elements/panel/) inline as its content couples with or closely relates to the content on the page (details, extra actions/options). [MDN Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
+ * @description Drawer are to display content that is out of context of the rest of the page (notifications, navigation, settings).
* @documentation https://nvidia.github.io/elements/docs/elements/drawer/
* @since 0.16.0
* @entrypoint \@nvidia-elements/core/drawer
diff --git a/projects/core/src/gauge/gauge.examples.ts b/projects/core/src/gauge/gauge.examples.ts
index 7c5156b76e..da9c5203b5 100644
--- a/projects/core/src/gauge/gauge.examples.ts
+++ b/projects/core/src/gauge/gauge.examples.ts
@@ -14,10 +14,7 @@ export default {
*/
export const Default = {
render: () => html`
-
- 50%
- 66%
-
+ 66%
`};
/**
diff --git a/projects/core/src/notification/notification.ts b/projects/core/src/notification/notification.ts
index 9cb402e4b6..77e2146f88 100644
--- a/projects/core/src/notification/notification.ts
+++ b/projects/core/src/notification/notification.ts
@@ -20,7 +20,7 @@ import styles from './notification.css?inline';
/**
* @element nve-notification
- * @description Displays real time updates without interrupting the user's workflow to communicate an important message or status. [MDN Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
+ * @description Displays real time updates without interrupting the user's workflow to communicate an important message or status.
* @documentation https://nvidia.github.io/elements/docs/elements/notification/
* @since 0.6.0
* @entrypoint \@nvidia-elements/core/notification
diff --git a/projects/core/src/toast/toast.ts b/projects/core/src/toast/toast.ts
index 87f3ce44ed..e7e4b9f064 100644
--- a/projects/core/src/toast/toast.ts
+++ b/projects/core/src/toast/toast.ts
@@ -21,7 +21,7 @@ import styles from './toast.css?inline';
/**
* @element nve-toast
- * @description A contextual popup that displays a status. Toasts are [triggered](https://w3c.github.io/aria/#tooltip) by clicking, focusing, or tapping an element and cannot have interactive elements within them. [MDN Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
+ * @description A contextual popup that displays a status. Toasts are [triggered](https://w3c.github.io/aria/#tooltip) by clicking, focusing, or tapping an element and cannot have interactive elements within them.
* @documentation https://nvidia.github.io/elements/docs/elements/toast/
* @since 0.6.0
* @entrypoint \@nvidia-elements/core/toast
diff --git a/projects/core/src/tooltip/tooltip.ts b/projects/core/src/tooltip/tooltip.ts
index 107a38d588..fd5963a3e0 100644
--- a/projects/core/src/tooltip/tooltip.ts
+++ b/projects/core/src/tooltip/tooltip.ts
@@ -17,7 +17,7 @@ import styles from './tooltip.css?inline';
/**
* @element nve-tooltip
- * @description A contextual popup that displays a plaintext description. Tooltips are [triggered](https://w3c.github.io/aria/#tooltip) by hovering, focusing, or tapping an element and cannot have interactive elements within them. [MDN Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
+ * @description A contextual popup that displays a plaintext description. Trigger tooltips by hovering, focusing, or tapping an element and cannot have interactive elements within them.
* @documentation https://nvidia.github.io/elements/docs/elements/tooltip/
* @since 0.6.0
* @entrypoint \@nvidia-elements/core/tooltip
diff --git a/projects/markdown/src/markdown/markdown.examples.ts b/projects/markdown/src/markdown/markdown.examples.ts
index 7ba4f9c7b4..eec79f7979 100644
--- a/projects/markdown/src/markdown/markdown.examples.ts
+++ b/projects/markdown/src/markdown/markdown.examples.ts
@@ -17,7 +17,7 @@ export const Default = {
render: () => html`
- # Default
+ ## Markdown
This is a default markdown component in its initial state.
diff --git a/projects/site/package.json b/projects/site/package.json
index c9402121e5..9f878d395b 100644
--- a/projects/site/package.json
+++ b/projects/site/package.json
@@ -167,7 +167,15 @@
"env": {
"PAGES_BASE_URL": {
"external": true,
- "default": "/elements/preview/"
+ "default": "/"
+ },
+ "ELEMENTS_SITE_URL": {
+ "external": true,
+ "default": "http://localhost:4173/"
+ },
+ "LOCAL_PREVIEW": {
+ "external": true,
+ "default": "false"
}
}
},
diff --git a/projects/site/src/_11ty/layouts/common.js b/projects/site/src/_11ty/layouts/common.js
index de8027b741..6db752b648 100644
--- a/projects/site/src/_11ty/layouts/common.js
+++ b/projects/site/src/_11ty/layouts/common.js
@@ -77,7 +77,8 @@ export const renderBaseHead = data => {
/* hide non-ssr elements until defined */
nve-tree:not(:defined),
nve-grid:not(:defined),
- nvd-canvas:not(:defined) {
+ nvd-canvas:not(:defined),
+ nve-button:not(:defined) {
visibility: hidden !important;
}
@@ -219,7 +220,7 @@ export const renderDocsNav = data => /* html */ `
DESIGN.md
-
+
Elements
Accordion
Alert
@@ -231,6 +232,7 @@ export const renderDocsNav = data => /* html */ `
Card
Chat Message
Checkbox
+ Codeblock
Color
Combobox
Copy Button
@@ -285,8 +287,15 @@ export const renderDocsNav = data => /* html */ `
Input
Input Group
Logo
+ Markdown
+ Markdown CSS
Menu
Month
+ Monaco Input
+ Monaco Diff Input
+ Monaco Editor
+ Monaco Diff Editor
+ Monaco Problems
Notification
Page
Page Header
@@ -342,26 +351,6 @@ export const renderDocsNav = data => /* html */ `
Trend
-
- Code
- Codeblock
-
-
-
- Monaco
- Input
- Diff Input
- Editor
- Diff Editor
- Problems
-
-
-
- Markdown
- Markdown
- CSS Utility
-
-
Labs
diff --git a/projects/site/src/_11ty/layouts/docs.css b/projects/site/src/_11ty/layouts/docs.css
index 67fc187e3a..4dab2367cb 100644
--- a/projects/site/src/_11ty/layouts/docs.css
+++ b/projects/site/src/_11ty/layouts/docs.css
@@ -205,10 +205,6 @@ p[nve-text~='mkd']:has(*:not(code, a, pre)) {
text-box: initial !important;
}
-code:has(nve-codeblock) {
- display: contents;
-}
-
pre {
display: block;
margin: 0;
@@ -216,14 +212,19 @@ pre {
width: 100%;
}
-code > nve-codeblock {
- --padding: var(--nve-ref-space-lg);
- min-height: 65px;
+.markdown-codeblock {
+ anchor-scope: --codeblock;
width: 100%;
- anchor-name: --codeblock;
+
+ nve-codeblock {
+ --padding: var(--nve-ref-space-lg);
+ anchor-name: --codeblock;
+ min-height: 65px;
+ width: 100%;
+ }
}
-nve-copy-button.markdown-copy-button {
+.markdown-copy-button {
position: absolute;
position-anchor: --codeblock;
bottom: calc(anchor(bottom) + var(--nve-ref-space-md));
@@ -232,17 +233,11 @@ nve-copy-button.markdown-copy-button {
transition: opacity 0.15s ease-in-out;
}
-code:has(nve-codeblock:hover) nve-copy-button.markdown-copy-button,
-nve-copy-button.markdown-copy-button:hover {
+.markdown-codeblock:has(nve-codeblock:hover) .markdown-copy-button,
+.markdown-copy-button:hover {
opacity: 1;
}
-pre:has(nve-codeblock),
-code:has(nve-codeblock) {
- display: contents;
- anchor-scope: --codeblock;
-}
-
/* Canvas Styles */
nvd-canvas {
min-height: 120px;
diff --git a/projects/site/src/_11ty/libraries/markdown.js b/projects/site/src/_11ty/libraries/markdown.js
index df0b56020b..5fd6387c0b 100644
--- a/projects/site/src/_11ty/libraries/markdown.js
+++ b/projects/site/src/_11ty/libraries/markdown.js
@@ -7,9 +7,12 @@ const markdown = markdownIt({
linkify: true,
highlight: function (str, lang) {
lang = lang === 'javascript' ? 'typescript' : lang; // alias javascript to typescript
- return /* html */ `${markdown.utils.escapeHtml(str)}
-
-
+ return /* html */ `
+
+
${markdown.utils.escapeHtml(str)}
+
${markdown.utils.escapeHtml(str)}
+
+
`;
export function render(data) {
const components = createComponentCatalog(data.collections.componentDocs);
return /* html */ `
NVIDIA Elements Components
@@ -91,7 +596,9 @@ export function render(data) {
stable nve-* APIs, design tokens, accessibility guidance, and examples.
-
- ${components.map(renderComponentLink).join('')}
-
`;
+
+ ${components.map(renderComponentCard).join('')}
+
+
+${renderPreviewScript()}`;
}