Repository navigation
fix(core): tree node link target and docs #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added test to prevent regression of case where a link is slotted to a tree node and the ::after is not correctly applied creating a broken touch target |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,9 @@ import '@nvidia-elements/core/format-datetime/define.js'; | |
| import '@nvidia-elements/core/grid/define.js'; | ||
| import '@nvidia-elements/core/icon/define.js'; | ||
| import '@nvidia-elements/core/password/define.js'; | ||
| import '@nvidia-elements/core/switch/define.js'; | ||
| import '@nvidia-elements/core/tree/define.js'; | ||
| import '@nvidia-elements/monaco/diff-editor/define.js'; | ||
|
|
||
| export default { | ||
| title: 'Patterns/Code', | ||
|
|
@@ -170,6 +172,43 @@ export const FileTree = { | |
| ` | ||
| }; | ||
|
|
||
| /** | ||
| * @summary Expandable changed-file tree with additions and deletions aligned beside each file. Use during Git reviews to scan the scope of changes without losing the repository hierarchy. | ||
| * @tags pattern | ||
| */ | ||
| export const FileTreeGitDiff = { | ||
| render: () => html` | ||
| <nve-tree behavior-expand aria-label="Changed robot software files" style="max-width: 360px"> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add tree example in context of code patterns |
||
| <nve-tree-node expanded> | ||
| <span nve-text="body muted">src</span> | ||
| <nve-tree-node> | ||
| <code nve-text="code" title="src/robot_state.py">robot_state.py</code> | ||
| <div slot="suffix" nve-layout="row gap:xs"> | ||
| <nve-badge container="flat" status="success" aria-label="18 added lines">+18</nve-badge> | ||
| <nve-badge container="flat" status="failed" aria-label="6 deleted lines">−6</nve-badge> | ||
| </div> | ||
| </nve-tree-node> | ||
| <nve-tree-node expanded> | ||
| <span nve-text="body muted">navigation</span> | ||
| <nve-tree-node> | ||
| <code nve-text="code" title="src/navigation/planner.py">planner.py</code> | ||
| <div slot="suffix" nve-layout="row gap:xs"> | ||
| <nve-badge container="flat" status="success" aria-label="32 added lines">+32</nve-badge> | ||
| <nve-badge container="flat" status="failed" aria-label="12 deleted lines">−12</nve-badge> | ||
| </div> | ||
| </nve-tree-node> | ||
| </nve-tree-node> | ||
| </nve-tree-node> | ||
| <nve-tree-node> | ||
| <code nve-text="code" title="robot.yaml">robot.yaml</code> | ||
| <div slot="suffix" nve-layout="row gap:xs"> | ||
| <nve-badge container="flat" status="success" aria-label="9 added lines">+9</nve-badge> | ||
| </div> | ||
| </nve-tree-node> | ||
| </nve-tree> | ||
| ` | ||
| }; | ||
|
|
||
| /** | ||
| * @summary Commit details with author, copyable hash, and expandable file changes. Use after an assistant edits a repository to show the scope of a change and distinguish added, modified, deleted, and renamed files. | ||
| * @tags pattern | ||
|
|
@@ -274,3 +313,83 @@ export const EnvironmentVariables = { | |
| </nve-card> | ||
| ` | ||
| }; | ||
|
|
||
| /** | ||
| * @summary Git change review for a warehouse robot navigation configuration with branch context and read-only comparisons. Use before merging robot behavior changes to inspect revised parameters in side-by-side or inline views. | ||
| * @tags pattern | ||
| */ | ||
| export const GitReviewDiff = { | ||
| render() { | ||
| return html` | ||
| <div id="git-review-diff" nve-layout="column gap:sm align:horizontal-stretch"> | ||
| <div nve-layout="row gap:md align:wrap align:space-between full:width"> | ||
| <code nve-text="code sm">config/warehouse-navigation.json</code> | ||
| <nve-switch> | ||
| <label>Side by side</label> | ||
| <input type="checkbox" checked /> | ||
| </nve-switch> | ||
| </div> | ||
| <nve-monaco-diff-editor aria-label="Warehouse robot navigation configuration changes" style="height: 480px"></nve-monaco-diff-editor> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added example of monaco git diff in context of code patterns |
||
| </div> | ||
| <script type="module"> | ||
| const review = document.querySelector('#git-review-diff'); | ||
| const diff = review.querySelector('nve-monaco-diff-editor'); | ||
| const sideBySide = review.querySelector('input[type="checkbox"]'); | ||
|
|
||
| const initialize = () => { | ||
| const { editor, monaco } = diff; | ||
| if (!editor || !monaco || editor.getModel()) return; | ||
|
|
||
| const original = monaco.editor.createModel(JSON.stringify({ | ||
| robot_id: 'AMR-07', | ||
| scenario: 'warehouse-aisle-3', | ||
| navigation: { | ||
| max_speed_mps: 1.2, | ||
| obstacle_clearance_m: 0.35, | ||
| blocked_aisle_behavior: 'pause', | ||
| planner: 'grid_search' | ||
| } | ||
| }, null, 2), 'json'); | ||
| const modified = monaco.editor.createModel(JSON.stringify({ | ||
| robot_id: 'AMR-07', | ||
| scenario: 'warehouse-aisle-3', | ||
| navigation: { | ||
| max_speed_mps: 0.8, | ||
| obstacle_clearance_m: 0.6, | ||
| blocked_aisle_behavior: 'replan', | ||
| planner: 'grid_search', | ||
| replanning: { | ||
| enabled: true, | ||
| retry_interval_s: 2, | ||
| max_attempts: 3 | ||
| } | ||
| } | ||
| }, null, 2), 'json'); | ||
|
|
||
| editor.updateOptions({ | ||
| readOnly: true, | ||
| originalEditable: false, | ||
| renderSideBySide: sideBySide.checked, | ||
| useInlineViewWhenSpaceIsLimited: false, | ||
| originalAriaLabel: 'Base warehouse navigation configuration on main', | ||
| modifiedAriaLabel: 'Proposed warehouse navigation configuration', | ||
| minimap: { enabled: false }, | ||
| scrollBeyondLastLine: false | ||
| }); | ||
| editor.setModel({ original, modified }); | ||
| editor.onDidDispose(() => { | ||
| editor.setModel(null); | ||
| original.dispose(); | ||
| modified.dispose(); | ||
| }); | ||
| }; | ||
|
|
||
| diff.addEventListener('ready', initialize); | ||
| initialize(); | ||
| sideBySide.addEventListener('change', () => { | ||
| diff.editor?.updateOptions({ renderSideBySide: sideBySide.checked }); | ||
| }); | ||
| </script> | ||
| `; | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { html } from 'lit'; | ||
| import '@nvidia-elements/core/button/define.js'; | ||
| import '@nvidia-elements/markdown/markdown/define.js'; | ||
| import '@nvidia-elements/markdown/styles/index.css'; | ||
|
|
||
|
|
@@ -249,12 +250,15 @@ This content has <strong>HTML</strong> mixed with markdown. | |
| }; | ||
|
|
||
| /** | ||
| * @summary Progressive streaming demo simulating AI assistant responses with block-by-block content rendering | ||
| * @summary Progressive AI response streaming with a restart action. Use to replay content from the beginning and inspect how markdown renders as new blocks arrive. | ||
| * @tags test-case | ||
| */ | ||
| export const JavaScriptDriven = { | ||
| export const StreamingContent = { | ||
| render: () => html` | ||
| <div> | ||
| <div nve-layout="column gap:md"> | ||
| <div> | ||
| <nve-button id="restart-markdown-stream" type="button">Restart stream</nve-button> | ||
| </div> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add button to re-trigger streaming markdown example |
||
| <nve-markdown id="programmatic-markdown"></nve-markdown> | ||
|
|
||
| <script type="module"> | ||
|
|
@@ -312,19 +316,27 @@ The component uses a reactive approach: | |
| // Split content into blocks/paragraphs for progressive display | ||
| const blocks = fullContent.split('\\n'); | ||
| let currentBlockIndex = 0; | ||
| let streamTimeout; | ||
| function streamContent() { | ||
| if (!element.isConnected) return; | ||
| if (currentBlockIndex < blocks.length) { | ||
| // Add 1 block at a time to preserve markdown structure | ||
| currentBlockIndex++; | ||
| const currentContent = blocks.slice(0, currentBlockIndex).join(' \\n'); | ||
|
|
||
| element.source = currentContent; | ||
|
|
||
| setTimeout(streamContent, 300); | ||
| streamTimeout = setTimeout(streamContent, 300); | ||
| } | ||
| } | ||
| document.getElementById('restart-markdown-stream').addEventListener('click', () => { | ||
| clearTimeout(streamTimeout); | ||
| currentBlockIndex = 0; | ||
| element.source = ''; | ||
| streamTimeout = setTimeout(streamContent, 300); | ||
| }); | ||
| // Start streaming after a brief delay | ||
| setTimeout(streamContent, 1000); | ||
| streamTimeout = setTimeout(streamContent, 1000); | ||
| </script> | ||
| </div> | ||
| ` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -489,13 +489,22 @@ export function renderGlobalsScript(data = { disableTheme: false }) { | |
| } | ||
|
|
||
| export function renderBasePageHeader(data) { | ||
| const isCatalogPage = [ | ||
| '/docs/elements/', | ||
| '/docs/code/', | ||
| '/docs/markdown/', | ||
| '/docs/media/', | ||
| '/docs/monaco/', | ||
| '/docs/viewport/' | ||
| ].some(path => data.page.url.startsWith(path)); | ||
|
|
||
| return /* html */ ` | ||
| <nve-page-header slot="header"> | ||
| <nve-logo slot="prefix" color="brand-green" size="sm" aria-label="NVIDIA Elements Design System">NV</nve-logo> | ||
| <a slot="prefix" href="/">NVIDIA Elements</a> | ||
| <nve-button container="flat" ${data.page.url.includes('docs') ? 'selected' : ''} class="header-btn"><a href="/">Catalog</a></nve-button> | ||
| <nve-button container="flat" ${isCatalogPage ? 'selected' : ''} class="header-btn"><a href="/docs/elements/">Catalog</a></nve-button> | ||
| ${ELEMENTS_PLAYGROUND_BASE_URL ? /* html */ `<nve-button container="flat" class="header-btn"><a href="${ELEMENTS_PLAYGROUND_BASE_URL}/ui/elements-playground/browse.html" target="_blank">Playground</a></nve-button>` : ''} | ||
| <nve-button container="flat" class="header-btn"><a href="/docs/integrations/">Starters</a></nve-button> | ||
| <nve-button container="flat" ${data.page.url.startsWith('/docs/integrations/') ? 'selected' : ''} class="header-btn"><a href="/docs/integrations/">Starters</a></nve-button> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor corrections to selection visual state based on page path |
||
| <nve-button container="flat" class="header-btn"><a href="${ELEMENTS_REPO_BASE_URL}" target="_blank">GitHub</a></nve-button> | ||
| <nve-button slot="suffix" id="system-options-panel-btn" container="flat">System Themes</nve-button> | ||
| <nve-icon-button class="header-menu-btn" role="button" command="--toggle" commandfor="sidenav-panel" container="flat" slot="suffix" icon-name="menu" aria-label="menu"></nve-icon-button> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing outdated migration data