Skip to content

feat(core): progress gauge#154

Open
coryrylan wants to merge 1 commit into
mainfrom
topic-progress-guage
Open

feat(core): progress gauge#154
coryrylan wants to merge 1 commit into
mainfrom
topic-progress-guage

Conversation

@coryrylan

@coryrylan coryrylan commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator
Screenshot 2026-06-25 at 8 55 26 AM

Summary by CodeRabbit

  • New Features

    • Added a new Progress Gauge component with support for value, max, status, size, and container variants.
    • Included interactive examples covering different display modes, theming, and a dynamic updating demo.
    • Added documentation and navigation entry for the new component.
  • Bug Fixes

    • Improved accessibility and rendering consistency with new automated checks.
    • Updated bundle-size expectations to account for the added component.

@coryrylan coryrylan self-assigned this Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the nve-progress-gauge LitElement web component (nve-progress-gauge) with SVG gauge rendering, ARIA progressbar semantics, size/status/container variants, CSS animation, package export wiring, Storybook examples, unit/axe/SSR/Lighthouse/visual tests, and a documentation page.

Changes

Progress Gauge feature

Layer / File(s) Summary
Public entrypoints and bundle wiring
projects/core/package.json, projects/core/src/progress-gauge/define.ts, projects/core/src/progress-gauge/index.ts, projects/core/src/bundle.ts, projects/core/src/index.test.lighthouse.ts
Adds ./progress-gauge subpath exports to package.json, registers the custom element via define.ts, re-exports the public API through bundle.ts, and updates the bundle Lighthouse size limit and module list.
Component geometry and ARIA
projects/core/src/progress-gauge/progress-gauge.ts
Defines GAUGE_GEOMETRY for default/half SVG arcs, implements reactive properties with max/value normalization and clamping, renders the SVG gauge with stroke-dasharray/--_progress, and synchronizes ElementInternals ARIA attributes on update.
Component styles
projects/core/src/progress-gauge/progress-gauge.css
Adds host sizing, grid layout, size/container variants, SVG path stroke animation (gauge-progress-in keyframes), status color theming, and prefers-reduced-motion support.
Stories and examples
projects/core/src/progress-gauge/progress-gauge.examples.ts
Exports Storybook-style stories for default, container, values, max, status, text+aria, sizing, and a dynamic interval-driven variant.
Unit tests
projects/core/src/progress-gauge/progress-gauge.test.ts
Covers element registration, ARIA defaults and updates, size-driven widths, slot projection, zero-progress and animation rendering, SVG geometry for both container modes, dasharray scaling, over-maximum clamping, and invalid-input normalization.
Accessibility, visual, SSR, and Lighthouse coverage
projects/core/src/progress-gauge/progress-gauge.test.visual.ts, ...test.axe.ts, ...test.ssr.ts, ...test.lighthouse.ts
Adds visual regression, axe, SSR, and per-component Lighthouse tests.
Docs and navigation
projects/site/src/docs/elements/progress-gauge.md, projects/site/src/_11ty/layouts/common.js
Adds the Progress Gauge documentation page and inserts its navigation entry between Progress Bar and Progress Ring.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new core progress gauge component.
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 topic-progress-guage

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.

projects/core/src/bundle.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

projects/core/src/index.test.lighthouse.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

projects/core/src/progress-gauge/define.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 10 others

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

@github-actions github-actions Bot added scope(core) scope(ci) scope(docs) dependencies Pull requests that update a dependency file labels Jun 26, 2026
@coryrylan coryrylan marked this pull request as ready for review June 26, 2026 17:42
@coryrylan coryrylan force-pushed the topic-progress-guage branch from 5675997 to e315a0f Compare June 26, 2026 17:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 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.

Inline comments:
In `@config/vale/styles/config/vocabularies/Elements/accept.txt`:
- Around line 361-362: The Elements vocabulary entry currently includes generic
terms that should not be part of the shared docs vocabulary. Remove indicate and
utilization from the accept list in the Elements vocabulary file, and keep this
vocabulary limited to technical terms, component names, or abbreviations that
are specific to the project.

In `@projects/core/src/progress-gauge/progress-gauge.css`:
- Around line 4-21: The :host rule in progress-gauge.css fails
declaration-empty-line-before because there is no blank line before display;
update the :host block to add the required empty line separating the custom
property declarations from the standard declarations, keeping the fix within the
progress-gauge styles.

In `@projects/core/src/progress-gauge/progress-gauge.examples.ts`:
- Around line 114-123: The Dynamic example script creates an unmanaged interval
and uses a document-wide query, which can stack timers and keep mutating a
detached or wrong gauge on rerender. Update the inline module in
progress-gauge.examples.ts to scope lookups from the example’s own root
container instead of document, and keep a handle to the timer created in the
dynamic gauge example. Add teardown/cleanup for that setInterval when the
example is re-rendered or disposed so only one timer runs per instance.

In `@projects/core/src/progress-gauge/progress-gauge.test.axe.ts`:
- Around line 15-24: The axe test setup only waits for the first
nve-progress-gauge to stabilize, so the remaining gauges may still be rendering
when runAxe executes. Update the beforeEach in progress-gauge.test.axe.ts to
wait for every rendered ProgressGauge instance from the fixture, not just the
element returned by querySelector, so the DOM is fully settled before
accessibility checks run.

In `@projects/core/src/progress-gauge/progress-gauge.test.visual.ts`:
- Around line 19-24: The visual test template is always setting the nve-theme
attribute, even for the default baseline when theme is empty. Update template to
only call document.documentElement.setAttribute in the dark-theme case, and
leave the default document state untouched when theme === ''. Use the template
helper in progress-gauge.test.visual.ts as the place to guard the attribute
assignment.

In `@projects/core/src/progress-gauge/progress-gauge.ts`:
- Around line 22-26: The public version metadata for ProgressGauge still uses a
placeholder release value. Update the `@since` tag in the component docblock and
the ProgressGauge.metadata.version field so they reflect the real published
version instead of 0.0.0, and make the same change anywhere else in this diff
that duplicates the placeholder metadata.
- Around line 49-53: Normalize the progress gauge inputs before they are used in
geometry or ARIA: in progress-gauge.ts, clamp and sanitize `value` and `max` so
`NaN`, negative values, `max <= 0`, and `value > max` cannot flow into
rendering. Update `render()` and `updated()` to reuse the same normalized
numbers when computing the dash geometry and setting
`aria-valuenow`/`aria-valuemax`, using the `value` and `max` properties as the
source symbols to locate the fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: a3a78298-8f17-4601-b576-e410d040447d

📥 Commits

Reviewing files that changed from the base of the PR and between c58c856 and e315a0f.

⛔ Files ignored due to path filters (2)
  • projects/core/.visual/progress-gauge.dark.png is excluded by !**/*.png
  • projects/core/.visual/progress-gauge.png is excluded by !**/*.png
📒 Files selected for processing (16)
  • config/vale/styles/config/vocabularies/Elements/accept.txt
  • projects/core/package.json
  • projects/core/src/bundle.ts
  • projects/core/src/index.test.lighthouse.ts
  • projects/core/src/progress-gauge/define.ts
  • projects/core/src/progress-gauge/index.ts
  • projects/core/src/progress-gauge/progress-gauge.css
  • projects/core/src/progress-gauge/progress-gauge.examples.ts
  • projects/core/src/progress-gauge/progress-gauge.test.axe.ts
  • projects/core/src/progress-gauge/progress-gauge.test.lighthouse.ts
  • projects/core/src/progress-gauge/progress-gauge.test.ssr.ts
  • projects/core/src/progress-gauge/progress-gauge.test.ts
  • projects/core/src/progress-gauge/progress-gauge.test.visual.ts
  • projects/core/src/progress-gauge/progress-gauge.ts
  • projects/site/src/_11ty/layouts/common.js
  • projects/site/src/docs/elements/progress-gauge.md

Comment on lines +361 to +362
indicate
utilization

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the Elements vocabulary scoped to docs-specific terms.

indicate and utilization are generic words, so adding them here broadens the shared docs vocabulary without a clear technical need.

As per coding guidelines, add new technical terms, component names, or abbreviations to the Elements vocabulary.

♻️ Suggested change
-indicate
-utilization
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
indicate
utilization
🤖 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 `@config/vale/styles/config/vocabularies/Elements/accept.txt` around lines 361
- 362, The Elements vocabulary entry currently includes generic terms that
should not be part of the shared docs vocabulary. Remove indicate and
utilization from the accept list in the Elements vocabulary file, and keep this
vocabulary limited to technical terms, component names, or abbreviations that
are specific to the project.

Source: Coding guidelines

Comment thread projects/core/src/progress-gauge/progress-gauge.css
Comment thread projects/core/src/progress-gauge/progress-gauge.examples.ts
Comment thread projects/core/src/progress-gauge/progress-gauge.test.axe.ts
Comment on lines +19 to +24
function template(theme: '' | 'dark' = '') {
return /* html */ `
<script type="module">
import '@nvidia-elements/core/progress-gauge/define.js';
document.documentElement.setAttribute('nve-theme', '${theme}');
</script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Don't set nve-theme on the default baseline.

When theme === '', this still adds an empty nve-theme attribute. That means the “default” snapshot is no longer exercising the actual default document state, and any selectors that depend on attribute presence can produce a false baseline.

Suggested fix
 function template(theme: '' | 'dark' = '') {
   return /* html */ `
   <script type="module">
     import '`@nvidia-elements/core/progress-gauge/define.js`';
-    document.documentElement.setAttribute('nve-theme', '${theme}');
+    if ('${theme}') {
+      document.documentElement.setAttribute('nve-theme', '${theme}');
+    } else {
+      document.documentElement.removeAttribute('nve-theme');
+    }
   </script>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function template(theme: '' | 'dark' = '') {
return /* html */ `
<script type="module">
import '@nvidia-elements/core/progress-gauge/define.js';
document.documentElement.setAttribute('nve-theme', '${theme}');
</script>
function template(theme: '' | 'dark' = '') {
return /* html */ `
<script type="module">
import '`@nvidia-elements/core/progress-gauge/define.js`';
if ('${theme}') {
document.documentElement.setAttribute('nve-theme', '${theme}');
} else {
document.documentElement.removeAttribute('nve-theme');
}
</script>
🤖 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 `@projects/core/src/progress-gauge/progress-gauge.test.visual.ts` around lines
19 - 24, The visual test template is always setting the nve-theme attribute,
even for the default baseline when theme is empty. Update template to only call
document.documentElement.setAttribute in the dark-theme case, and leave the
default document state untouched when theme === ''. Use the template helper in
progress-gauge.test.visual.ts as the place to guard the attribute assignment.

Comment on lines +22 to +26
/**
* @element nve-progress-gauge
* @description Use progress gauge to indicate system resource utilization.
* @since 0.0.0
* @entrypoint \@nvidia-elements/core/progress-gauge

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Replace the 0.0.0 placeholders in the public version metadata.

@since and ProgressGauge.metadata.version still advertise 0.0.0, so generated docs and CLI/MCP consumers will expose the wrong release information for this component.

Suggested fix
- * `@since` 0.0.0
+ * `@since` 2.0.2
@@
   static readonly metadata = {
     tag: 'nve-progress-gauge',
-    version: '0.0.0'
+    version: '2.0.2'
   };

Also applies to: 41-44

🤖 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 `@projects/core/src/progress-gauge/progress-gauge.ts` around lines 22 - 26, The
public version metadata for ProgressGauge still uses a placeholder release
value. Update the `@since` tag in the component docblock and the
ProgressGauge.metadata.version field so they reflect the real published version
instead of 0.0.0, and make the same change anywhere else in this diff that
duplicates the placeholder metadata.

Comment thread projects/core/src/progress-gauge/progress-gauge.ts
Signed-off-by: Cory Rylan <crylan@nvidia.com>
@coryrylan coryrylan force-pushed the topic-progress-guage branch from e315a0f to a9cd207 Compare June 29, 2026 22:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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.

Inline comments:
In `@projects/core/src/progress-gauge/progress-gauge.css`:
- Around line 96-99: The `::slotted(*)` rule in `progress-gauge.css` is
overriding every assigned child’s typography, including consumer-provided styles
like the muted secondary label in the progress gauge example. Remove the blanket
`color` and `font-size` application from the slot styling and let slotted
content inherit defaults instead, keeping any necessary styling scoped to the
gauge’s internal elements rather than all top-level slotted nodes.

In `@projects/core/src/progress-gauge/progress-gauge.test.ts`:
- Around line 18-19: The test setup in progress-gauge.test.ts assigns the result
of ProgressGauge.metadata.tag from querySelector() directly to element, which
can be null under strict typing. Update the setup to guard or assert the
querySelector() result before calling elementIsStable() and before any
_internals access, using the existing element variable and the
ProgressGauge.metadata.tag lookup so a missing custom element fails clearly
instead of crashing later.

In `@projects/core/src/progress-gauge/progress-gauge.ts`:
- Around line 58-59: The `container` property in `ProgressGauge` can receive
arbitrary HTML strings, so `geometry` lookup in `render()` must not assume only
valid values; guard the value before indexing `GAUGE_GEOMETRY` and fall back to
the default geometry unless `container` is exactly `'half'`. Update the
`ProgressGauge` type handling and the `geometry` selection logic together so
`render()` never sees `undefined` for invalid `container` values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: ad27c55d-a5d0-47d8-857a-91c33b25067d

📥 Commits

Reviewing files that changed from the base of the PR and between e315a0f and a9cd207.

⛔ Files ignored due to path filters (2)
  • projects/core/.visual/progress-gauge.dark.png is excluded by !**/*.png
  • projects/core/.visual/progress-gauge.png is excluded by !**/*.png
📒 Files selected for processing (15)
  • projects/core/package.json
  • projects/core/src/bundle.ts
  • projects/core/src/index.test.lighthouse.ts
  • projects/core/src/progress-gauge/define.ts
  • projects/core/src/progress-gauge/index.ts
  • projects/core/src/progress-gauge/progress-gauge.css
  • projects/core/src/progress-gauge/progress-gauge.examples.ts
  • projects/core/src/progress-gauge/progress-gauge.test.axe.ts
  • projects/core/src/progress-gauge/progress-gauge.test.lighthouse.ts
  • projects/core/src/progress-gauge/progress-gauge.test.ssr.ts
  • projects/core/src/progress-gauge/progress-gauge.test.ts
  • projects/core/src/progress-gauge/progress-gauge.test.visual.ts
  • projects/core/src/progress-gauge/progress-gauge.ts
  • projects/site/src/_11ty/layouts/common.js
  • projects/site/src/docs/elements/progress-gauge.md

Comment on lines +96 to +99
::slotted(*) {
color: var(--color);
font-size: var(--font-size);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not override all consumer slotted typography.

::slotted(*) forces the same color and font-size onto every top-level child. That breaks multi-line content like projects/core/src/progress-gauge/progress-gauge.examples.ts Lines 110-113, where the secondary GPU label is explicitly marked nve-text="body sm muted" but will still render with the primary gauge text styling. Let the slot provide defaults via inheritance instead of restyling every assigned node.

Proposed fix
-::slotted(*) {
-  color: var(--color);
-  font-size: var(--font-size);
-}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
::slotted(*) {
color: var(--color);
font-size: var(--font-size);
}
🤖 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 `@projects/core/src/progress-gauge/progress-gauge.css` around lines 96 - 99,
The `::slotted(*)` rule in `progress-gauge.css` is overriding every assigned
child’s typography, including consumer-provided styles like the muted secondary
label in the progress gauge example. Remove the blanket `color` and `font-size`
application from the slot styling and let slotted content inherit defaults
instead, keeping any necessary styling scoped to the gauge’s internal elements
rather than all top-level slotted nodes.

Comment on lines +18 to +19
element = fixture.querySelector(ProgressGauge.metadata.tag);
await elementIsStable(element);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "TypeScript config(s):"
fd -i 'tsconfig*.json' . -x sh -c 'echo "--- $1"; sed -n "1,220p" "$1"' sh {}

echo
echo "Unsafe ProgressGauge fixture lookups:"
rg -n -C2 'querySelector\(ProgressGauge\.metadata\.tag\)' projects/core/src/progress-gauge/progress-gauge.test.ts

Repository: NVIDIA/elements

Length of output: 20626


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Relevant test file:"
sed -n '1,260p' projects/core/src/progress-gauge/progress-gauge.test.ts

echo
echo "elementIsStable definition:"
rg -n -C3 'function elementIsStable|const elementIsStable|export .*elementIsStable' projects/internals/testing projects/core/src -g '*.ts'

echo
echo "ProgressGauge class and metadata:"
rg -n -C3 'class ProgressGauge|metadata\.tag' projects/core/src/progress-gauge -g '*.ts'

Repository: NVIDIA/elements

Length of output: 18735


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "TypeScript DOM querySelector typings in installed libs, if available:"
node - <<'JS'
const fs = require('fs');
const path = require('path');

const candidates = [
  'node_modules/typescript/lib/lib.dom.d.ts',
  '/usr/lib/node_modules/typescript/lib/lib.dom.d.ts',
  '/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts',
];
for (const p of candidates) {
  if (fs.existsSync(p)) {
    const text = fs.readFileSync(p, 'utf8');
    const idx = text.indexOf('querySelector<K extends keyof HTMLElementTagNameMap>');
    if (idx !== -1) {
      console.log(`FOUND ${p}`);
      console.log(text.slice(idx, idx + 700));
      process.exit(0);
    }
  }
}
console.log('lib.dom.d.ts not found in candidate locations');
JS

Repository: NVIDIA/elements

Length of output: 986


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "createFixture definition:"
sed -n '1,220p' projects/internals/testing/src/index.ts

echo
echo "progress-gauge test fixture patterns in nearby tests:"
rg -n -C2 'fixture\.querySelector\(ProgressGauge\.metadata\.tag\)|querySelector\(ProgressGauge\.metadata\.tag\)' projects/core/src/progress-gauge -g '*.test.ts'

Repository: NVIDIA/elements

Length of output: 6212


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,120p' projects/core/src/progress-gauge/progress-gauge.ts

Repository: NVIDIA/elements

Length of output: 4065


Guard the querySelector() result before assigning element. querySelector() can return null, so these direct assignments are unsafe under strict TS and can turn a missing custom element into an opaque setup crash. Add an assertion/helper before elementIsStable() and the _internals reads.

🤖 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 `@projects/core/src/progress-gauge/progress-gauge.test.ts` around lines 18 -
19, The test setup in progress-gauge.test.ts assigns the result of
ProgressGauge.metadata.tag from querySelector() directly to element, which can
be null under strict typing. Update the setup to guard or assert the
querySelector() result before calling elementIsStable() and before any
_internals access, using the existing element variable and the
ProgressGauge.metadata.tag lookup so a missing custom element fails clearly
instead of crashing later.

Source: Coding guidelines

Comment on lines +58 to +59
/** Determines the gauge container shape. Set `half` for a compact semi-circular arc. */
@property({ type: String, reflect: true }) container?: 'half';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Guard invalid container values before indexing GAUGE_GEOMETRY.

HTML attributes are runtime strings, so <nve-progress-gauge container="foo"> makes geometry undefined and render() throws on Line 83. Fall back explicitly unless the value is exactly 'half'. As per coding guidelines, "When working with TypeScript code, follow /projects/site/src/docs/internal/guidelines/typescript.md for type safety, type guards, discriminated unions, and exhaustive checking."

Suggested fix
-    const geometry = GAUGE_GEOMETRY[this.container ?? 'default'];
+    const geometry =
+      this.container === 'half' ? GAUGE_GEOMETRY.half : GAUGE_GEOMETRY.default;

Also applies to: 76-79

🤖 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 `@projects/core/src/progress-gauge/progress-gauge.ts` around lines 58 - 59, The
`container` property in `ProgressGauge` can receive arbitrary HTML strings, so
`geometry` lookup in `render()` must not assume only valid values; guard the
value before indexing `GAUGE_GEOMETRY` and fall back to the default geometry
unless `container` is exactly `'half'`. Update the `ProgressGauge` type handling
and the `geometry` selection logic together so `render()` never sees `undefined`
for invalid `container` values.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file scope(ci) scope(core) scope(docs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant