From 4ed4132ea9bf8294d143b38c92f9638f714e3fd0 Mon Sep 17 00:00:00 2001 From: rajsite <1588923+rajsite@users.noreply.github.com> Date: Tue, 13 Jan 2026 18:15:23 -0600 Subject: [PATCH 1/7] SVGIcon proto --- .../build/generate-icons/source/index.js | 6 +++--- .../nimble-components/src/icon-base/index.ts | 10 ++++++--- .../src/icon-base/template.ts | 4 ++-- .../mapping/icon/tests/mapping-icon.spec.ts | 6 +++--- .../mapping/table-column-mapping.stories.ts | 21 +++++++++++++++++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/packages/nimble-components/build/generate-icons/source/index.js b/packages/nimble-components/build/generate-icons/source/index.js index 170b771ccb..de4a02ab34 100644 --- a/packages/nimble-components/build/generate-icons/source/index.js +++ b/packages/nimble-components/build/generate-icons/source/index.js @@ -45,7 +45,7 @@ for (const key of Object.keys(icons)) { const componentFileContents = `${generatedFilePrefix} import { ${svgName} } from '@ni/nimble-tokens/dist/icons/js'; -import { Icon, registerIcon } from '../icon-base'; +import { SvgIcon, registerSvgIcon } from '../icon-base'; declare global { interface HTMLElementTagNameMap { @@ -56,13 +56,13 @@ declare global { /** * The icon component for the '${iconName}' icon */ -export class ${className} extends Icon { +export class ${className} extends SvgIcon { public constructor() { super(${svgName}); } } -registerIcon('${elementBaseName}', ${className}); +registerSvgIcon('${elementBaseName}', ${className}); export const ${tagName} = '${elementName}'; `; diff --git a/packages/nimble-components/src/icon-base/index.ts b/packages/nimble-components/src/icon-base/index.ts index 90da606b6b..334a2a6482 100644 --- a/packages/nimble-components/src/icon-base/index.ts +++ b/packages/nimble-components/src/icon-base/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-classes-per-file */ import { attr } from '@ni/fast-element'; import { DesignSystem, FoundationElement } from '@ni/fast-foundation'; import type { NimbleIcon } from '@ni/nimble-tokens/dist/icons/js'; @@ -16,15 +17,18 @@ export class Icon extends FoundationElement { */ @attr public severity: IconSeverity; +} +/** + * Icon base class for the standard nimble icon set + */ +export class SvgIcon extends Icon { public constructor(/** @internal */ public readonly icon: NimbleIcon) { super(); } } -type IconClass = typeof Icon; - -export const registerIcon = (baseName: string, iconClass: IconClass): void => { +export const registerSvgIcon = (baseName: string, iconClass: typeof SvgIcon): void => { const composedIcon = iconClass.compose({ baseName, template, diff --git a/packages/nimble-components/src/icon-base/template.ts b/packages/nimble-components/src/icon-base/template.ts index bcbba0f894..23f12a5f76 100644 --- a/packages/nimble-components/src/icon-base/template.ts +++ b/packages/nimble-components/src/icon-base/template.ts @@ -1,8 +1,8 @@ import { html } from '@ni/fast-element'; -import type { Icon } from '.'; +import type { SvgIcon } from '.'; // Avoiding any whitespace in the template because this is an inline element -export const template = html`
`