igniteui-astro-components 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -268,6 +268,7 @@ const sidebar: SidebarEntry[] = [/* … your tree … */];
268
268
  | -------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------- |
269
269
  | `…/components/mdx/ApiLink.astro` | Inline link to an API symbol with platform-aware URLs | [README](src/components/mdx/ApiLink/README.md) |
270
270
  | `…/components/mdx/ApiRef.astro` | Block API reference card | [README](src/components/mdx/ApiRef/README.md) |
271
+ | `…/components/mdx/DoDont.astro` | Side-by-side Do / Don't image guidance panels | [README](src/components/mdx/DoDont/README.md) |
271
272
  | `…/components/mdx/PlatformBlock.astro` | Show content only on selected platforms | [README](src/components/mdx/PlatformBlock/README.md) |
272
273
  | `…/components/mdx/Sample.astro` | Embedded code-view sample widget | [README](src/components/mdx/Sample/README.md) |
273
274
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-astro-components",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Reusable Astro components, layouts, and integrations for Infragistics / Ignite UI documentation sites. Replaces the Starlight defaults with project-specific implementations.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,7 +10,7 @@
10
10
  "author": "Infragistics",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/IgniteUI/igniteui-astro-components"
13
+ "url": "git+https://github.com/IgniteUI/igniteui-astro-components.git"
14
14
  },
15
15
  "keywords": [
16
16
  "astro",
@@ -66,6 +66,7 @@
66
66
  "./components/mdx/ApiRef.astro": "./src/components/mdx/ApiRef/ApiRef.astro",
67
67
  "./components/mdx/ApiLink.astro": "./src/components/mdx/ApiLink/ApiLink.astro",
68
68
  "./components/mdx/DocsAside.astro": "./src/components/mdx/DocsAside/DocsAside.astro",
69
+ "./components/mdx/DoDont.astro": "./src/components/mdx/DoDont/DoDont.astro",
69
70
  "./components/mdx/Badge.astro": "./src/components/mdx/Badge/Badge.astro",
70
71
  "./components/mdx/Faq.astro": "./src/components/mdx/Faq/Faq.astro",
71
72
  "./components/mdx/FaqItem.astro": "./src/components/mdx/Faq/FaqItem.astro",
@@ -118,6 +119,8 @@
118
119
  "access": "public"
119
120
  },
120
121
  "scripts": {
122
+ "test": "node --test \"scripts/**/*.test.mjs\"",
123
+ "test:sample-widget": "node --test scripts/sample-widget.test.mjs",
121
124
  "playground": "npm run playground:dev",
122
125
  "playground:dev": "astro sync --root playground && astro dev --root playground --port 4567",
123
126
  "playground:build": "astro sync --root playground && astro build --root playground",
@@ -0,0 +1,3 @@
1
+ <svg width="18" height="18" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3 8.5 6.5 12 13 4.5" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="18" height="18" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3.75 3.75 12.25 12.25M12.25 3.75 3.75 12.25" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
3
+ </svg>
@@ -13,6 +13,7 @@ import {
13
13
  trailingSlash as configuredTrailingSlash,
14
14
  } from 'virtual:docs-template/site-meta';
15
15
  import { platform as virtualPlatform } from 'virtual:docs-template/nav-html';
16
+ import { ULTIMATE_UI_PLATFORMS, platformLabelFor } from '../../platform';
16
17
  import SidebarFilterInput from './SidebarFilterInput.astro';
17
18
  import './DocsSidebar.scss';
18
19
  import SidebarLabel from './SidebarLabel.astro';
@@ -36,27 +37,20 @@ interface Props {
36
37
  * (exposed via the virtual module). Falls back to `true` if not configured.
37
38
  */
38
39
  trailingSlash?: boolean;
39
- /** Logo text shown in the slide-in sidebar on mobile/tablet. Defaults to 'Ignite UI'. */
40
+ /** Logo text shown in the slide-in sidebar. Defaults to the current product family. */
40
41
  logoText?: string;
41
42
  /** Platform label shown below logoText (e.g. 'Angular'). Auto-detected from virtual module when omitted. */
42
43
  platformLabel?: string | null;
43
44
  }
44
45
 
45
- const PLATFORM_LABELS: Record<string, string> = {
46
- angular: 'Angular',
47
- react: 'React',
48
- blazor: 'Blazor',
49
- 'web-components': 'Web Components',
50
- };
51
-
52
46
  const useTrailingSlash = configuredTrailingSlash !== 'never';
53
47
  const {
54
48
  currentSlug = '',
55
49
  items: itemsProp,
56
50
  showFilter = true,
57
51
  trailingSlash = useTrailingSlash,
58
- logoText = 'Ignite UI',
59
- platformLabel = virtualPlatform ? (PLATFORM_LABELS[virtualPlatform] ?? null) : null,
52
+ logoText = ULTIMATE_UI_PLATFORMS.has(virtualPlatform ?? '') ? 'Ultimate UI' : 'Ignite UI',
53
+ platformLabel = platformLabelFor(virtualPlatform),
60
54
  } = Astro.props;
61
55
  const items = (itemsProp ?? sidebarData) as SidebarEntry[];
62
56
  const nodes = toTreeNodes(items, currentSlug, { trailingSlash });
@@ -69,9 +63,7 @@ const activeId = normalizeSlug(currentSlug);
69
63
  <span class="igd-logo-text">{logoText}</span>
70
64
  {platformLabel && <span class="igd-logo__platform">for {platformLabel}</span>}
71
65
  </div>
72
- <div class="sidebar-gutter">
73
- {showFilter && <SidebarFilterInput />}
74
- </div>
66
+ <div class="sidebar-gutter">{showFilter && <SidebarFilterInput />}</div>
75
67
  <div class="sidebar-scroll" data-sidebar-scroll>
76
68
  <DocsTree
77
69
  nodes={nodes}
@@ -82,18 +74,17 @@ const activeId = normalizeSlug(currentSlug);
82
74
  renderLabel={SidebarLabel}
83
75
  />
84
76
  </div>
85
- {
86
- /* Shared tooltip showing the full text of a truncated (line-clamped) label.
77
+ {/* Shared tooltip showing the full text of a truncated (line-clamped) label.
87
78
  Anchored at runtime to the hovered/focused row by sidebar-tooltip.ts, which
88
- also owns show/hide — hence the empty trigger lists. */
89
- }
79
+ also owns show/hide — hence the empty trigger lists. */}
90
80
  <igc-tooltip
91
81
  data-sidebar-tooltip
92
82
  class="igd-sidebar-tooltip"
93
83
  placement="right"
94
84
  show-triggers=""
95
85
  hide-triggers=""
96
- with-arrow></igc-tooltip>
86
+ with-arrow
87
+ ></igc-tooltip>
97
88
  </sidebar-filter>
98
89
  <div class="docs-sidebar-backdrop" id="docs-sidebar-backdrop" aria-hidden="true"></div>
99
90
 
@@ -13,6 +13,7 @@
13
13
  * moved to the `DocsBreadcrumb` component, rendered inside the main frame.
14
14
  */
15
15
  import { platform as virtualPlatform } from 'virtual:docs-template/nav-html';
16
+ import { ULTIMATE_UI_PLATFORMS, platformLabelFor } from '../../platform';
16
17
  import {
17
18
  productLinks,
18
19
  sidebar as sidebarData,
@@ -91,7 +92,7 @@ interface Props {
91
92
  /**
92
93
  * Text label shown in the logo area when the GlobalNavBar is visible.
93
94
  * Fades out and is replaced by the SVG logo once the subheader becomes sticky.
94
- * Defaults to `'IgniteUI'`.
95
+ * Defaults to `'Ignite UI'` for web products and `'Ultimate UI'` for WinUI/Uno.
95
96
  */
96
97
  logoText?: string;
97
98
  }
@@ -110,7 +111,7 @@ const {
110
111
  versionLabel = 'Version',
111
112
  showThemeToggle = false,
112
113
  themeStorageKey = 'docs-theme',
113
- logoText = 'Ignite UI',
114
+ logoText = ULTIMATE_UI_PLATFORMS.has(virtualPlatform ?? '') ? 'Ultimate UI' : 'Ignite UI',
114
115
  } = Astro.props;
115
116
  const resolvedSiteTitle = siteTitleProp ?? siteTitle;
116
117
  const currentPlatform = virtualPlatform ?? null;
@@ -134,13 +135,7 @@ const resolvedSidebar = (sidebarItems ?? sidebarData) as SidebarEntry[];
134
135
  const sidebarCrumbs = currentSlug ? getBreadcrumb(resolvedSidebar, currentSlug) : [];
135
136
  const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : pageTitle ? [pageTitle] : [];
136
137
 
137
- const PLATFORM_LABELS: Record<string, string> = {
138
- angular: 'Angular',
139
- react: 'React',
140
- blazor: 'Blazor',
141
- 'web-components': 'Web Components',
142
- };
143
- const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? null) : null;
138
+ const platformLabel = platformLabelFor(currentPlatform);
144
139
  ---
145
140
 
146
141
  <docs-subheader-menu class="igd-docs-subheader" data-platform={currentPlatform ?? ''}>
@@ -165,65 +160,63 @@ const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? nul
165
160
 
166
161
  <div class="igd-docs-subheader__content">
167
162
  <!-- Search (overridable via named slot) -->
168
- <slot name="search"><Search /></slot>
163
+ <slot name="search">
164
+ <Search />
165
+ </slot>
169
166
 
170
167
  {/* Package selector */}
171
- {
172
- packages && packages.length > 0 && (
173
- <>
174
- <igc-select
175
- distance="4"
176
- id="package-select"
177
- class="igd-package-select"
178
- outlined
179
- value={selectedPackage}
180
- aria-label={packageLabel}
181
- >
182
- {platformIcon && (
183
- <igc-icon name={platformIcon} collection="docs" slot="prefix" aria-hidden="true" />
184
- )}
185
- {packages.map((p) => {
186
- const icon = getPlatformIcon(p.value ?? '') ?? getPlatformIcon(p.label ?? '');
187
- return (
188
- <igc-select-item value={p.value} data-href={p.href}>
189
- {icon && (
190
- <igc-icon slot="prefix" name={icon} collection="docs" aria-hidden="true" />
191
- )}
192
- {p.label}
193
- </igc-select-item>
194
- );
195
- })}
196
- </igc-select>
197
- <igc-tooltip
198
- id="package-tooltip"
199
- class="igd-package-select-tooltip"
200
- anchor="package-select"
201
- placement="bottom"
202
- with-arrow
203
- >
204
- {selectedPackageLabel}
205
- </igc-tooltip>
206
- </>
207
- )
208
- }
209
-
210
- <!-- Version selector -->
211
- {
212
- versions && versions.length > 0 && (
168
+ {packages && packages.length > 0 && (
169
+ <>
213
170
  <igc-select
214
171
  distance="4"
215
- id="version-select"
216
- class="igd-version-select"
172
+ id="package-select"
173
+ class="igd-package-select"
217
174
  outlined
218
- value={selectedVersion}
219
- aria-label={versionLabel}
175
+ value={selectedPackage}
176
+ aria-label={packageLabel}
220
177
  >
221
- {versions.map((v) => (
222
- <igc-select-item value={v}>{v}</igc-select-item>
223
- ))}
178
+ {platformIcon && (
179
+ <igc-icon name={platformIcon} collection="docs" slot="prefix" aria-hidden="true" />
180
+ )}
181
+ {packages.map((p) => {
182
+ const icon = getPlatformIcon(p.value ?? '') ?? getPlatformIcon(p.label ?? '');
183
+ return (
184
+ <igc-select-item value={p.value} data-href={p.href}>
185
+ {icon && (
186
+ <igc-icon slot="prefix" name={icon} collection="docs" aria-hidden="true" />
187
+ )}
188
+ {p.label}
189
+ </igc-select-item>
190
+ );
191
+ })}
224
192
  </igc-select>
225
- )
226
- }
193
+ <igc-tooltip
194
+ id="package-tooltip"
195
+ class="igd-package-select-tooltip"
196
+ anchor="package-select"
197
+ placement="bottom"
198
+ with-arrow
199
+ >
200
+ {selectedPackageLabel}
201
+ </igc-tooltip>
202
+ </>
203
+ )}
204
+
205
+ <!-- Version selector -->
206
+ {versions && versions.length > 0 && (
207
+ <igc-select
208
+ distance="4"
209
+ id="version-select"
210
+ class="igd-version-select"
211
+ outlined
212
+ value={selectedVersion}
213
+ aria-label={versionLabel}
214
+ >
215
+ {versions.map((v) => (
216
+ <igc-select-item value={v}>{v}</igc-select-item>
217
+ ))}
218
+ </igc-select>
219
+ )}
227
220
 
228
221
  <!-- TODO WHY WE NEED THIS? -->
229
222
  <!--{filteredLinks.length > 0 && (-->
@@ -26,6 +26,11 @@ type SassProps = {
26
26
 
27
27
  /** Props for TypeDoc API documentation links. */
28
28
  type TypeDocProps = {
29
+ /**
30
+ * Marks a deliberately authored raw ApiLink in strict-xplat documentation.
31
+ * This is an authoring/checker annotation and has no rendering effect.
32
+ */
33
+ raw?: boolean;
29
34
  /**
30
35
  * TypeDoc symbol kind. Narrows registry lookup when the same symbol exists
31
36
  * as multiple TypeDoc kinds.
@@ -0,0 +1,332 @@
1
+ ---
2
+ /**
3
+ * Renders a side-by-side "Do" / "Don't" pair of component screenshots.
4
+ *
5
+ * Usage:
6
+ * <DoDont
7
+ * doSrc={virtualScrollDo}
8
+ * doAlt="Virtual Scroll showing a list of 100,000 employees"
9
+ * dontSrc={virtualScrollDoNot}
10
+ * dontAlt="Virtual Scroll used for a list of only five employees"
11
+ * >
12
+ * <Fragment slot="do">Use the Virtual Scroll for a long list.</Fragment>
13
+ * <Fragment slot="dont">Render a short list directly with the List.</Fragment>
14
+ * </DoDont>
15
+ *
16
+ * Each panel is a framed image with a status badge pinned to its top-inline
17
+ * corner — a green check for the recommended usage, a red clear for the one to
18
+ * avoid. The frames hug their content and share a subgrid row, so every frame
19
+ * is as tall as the tallest screenshot in the row and the captions start on a
20
+ * common baseline. The frame's gray canvas shows in its padding and beside a
21
+ * screenshot narrower than the frame; screenshots are drawn at full opacity so
22
+ * their text keeps its contrast.
23
+ *
24
+ * Both description slots are required: a screenshot is never self-explanatory,
25
+ * so each panel must say in real text why it is the one to follow or avoid.
26
+ * A missing or empty slot throws at build time, like a missing `alt`.
27
+ *
28
+ * Images: an `astro:assets` import is rendered through Astro's <Image>, which
29
+ * converts the format, emits a `srcset` for 1x/2x/3x displays and writes the
30
+ * intrinsic `width`/`height` so the frame holds its size before the file
31
+ * arrives. A plain URL string is rendered as a bare <img> — Astro cannot
32
+ * inspect it, so it gets no `srcset` and no dimensions, and the frame grows
33
+ * when the image lands. Prefer imports for anything that ships in the docs.
34
+ *
35
+ * Loading: a small client script marks a frame whose image is still pending
36
+ * (`data-loading`) and the stylesheet shimmers its canvas until the image
37
+ * loads or fails. A failed image leaves `data-error` on the frame and
38
+ * the script drops a broken-image icon and a short
39
+ * "could not be loaded" notice into it. The notice is `aria-hidden`: it only
40
+ * explains the empty box to a sighted reader, and the <img> keeps carrying
41
+ * the alt for assistive tech. Without JavaScript nothing is marked and the frame
42
+ * stays static.
43
+ *
44
+ * Accessibility: `doAlt` and `dontAlt` are required and become the inner
45
+ * <img> `alt`. These images carry the guidance, so describe what each one
46
+ * shows, not merely which component it is. The badges are decorative — the
47
+ * labels already name each panel — so they are hidden from assistive tech.
48
+ * A visually hidden colon separates each label from its description so a
49
+ * screen reader hears "Do: use…" rather than one run-on phrase.
50
+ *
51
+ * Localization: the default labels follow the site language — the docs
52
+ * integration's `navLang`, the same value DocsLayout passes to the nav bar and
53
+ * footer. Pass `doLabel` / `dontLabel` to override it.
54
+ */
55
+ import type { ImageMetadata } from 'astro';
56
+ import { Image } from 'astro:assets';
57
+ import { navLang } from 'virtual:docs-template/site-meta';
58
+ import './DoDont.scss';
59
+
60
+ interface Props {
61
+ /**
62
+ * The recommended-usage image. An `astro:assets` import or a URL. Required.
63
+ *
64
+ * Named `doSrc`, not `do`, because Astro merges named slots into props —
65
+ * a prop sharing a slot's name would be overwritten by that slot.
66
+ */
67
+ doSrc: ImageMetadata | string;
68
+ /**
69
+ * The recommended-usage image's accessible description. Required — it
70
+ * becomes the inner <img>'s `alt`. Describe what the screenshot shows.
71
+ */
72
+ doAlt: string;
73
+ /** The usage-to-avoid image. An `astro:assets` import or a URL. Required. */
74
+ dontSrc: ImageMetadata | string;
75
+ /**
76
+ * The usage-to-avoid image's accessible description. Required — it becomes
77
+ * the inner <img>'s `alt`. Describe what the screenshot shows.
78
+ */
79
+ dontAlt: string;
80
+ /**
81
+ * Label for the recommended panel.
82
+ * @default 'Do' (localized: 推奨 for jp, 권장 for kr)
83
+ */
84
+ doLabel?: string;
85
+ /**
86
+ * Label for the panel to avoid.
87
+ * @default "Don't" (localized: 非推奨 for jp, 비권장 for kr)
88
+ */
89
+ dontLabel?: string;
90
+ /**
91
+ * Image loading strategy. Keep the default for a block further down a topic;
92
+ * pass `'eager'` when the block is the first thing on the page, so the
93
+ * largest contentful paint is not delayed. Eager images are also fetched at
94
+ * high priority.
95
+ * @default 'lazy'
96
+ */
97
+ loading?: 'lazy' | 'eager';
98
+ /**
99
+ * Notice shown inside a frame whose image failed to load. Hidden from
100
+ * assistive tech, which still gets the image's `alt`.
101
+ * @default 'Sorry, this image could not be loaded.' (localized for jp / kr)
102
+ */
103
+ errorText?: string;
104
+ /** Optional extra class(es) forwarded to the container. */
105
+ class?: string;
106
+ }
107
+
108
+ /**
109
+ * Default labels per site language: the integration's `navLang` (`jp`, `kr`)
110
+ * or an Astro i18n locale (`ja`, `ko`). Anything unrecognized falls back to
111
+ * English.
112
+ */
113
+ const DEFAULT_LABELS: Record<string, { do: string; dont: string; error: string }> = {
114
+ en: { do: 'Do', dont: "Don't", error: 'Sorry, this image could not be loaded.' },
115
+ jp: { do: '推奨', dont: '非推奨', error: '申し訳ありません。この画像を読み込めませんでした。' },
116
+ ja: { do: '推奨', dont: '非推奨', error: '申し訳ありません。この画像を読み込めませんでした。' },
117
+ kr: { do: '권장', dont: '비권장', error: '죄송합니다. 이 이미지를 불러올 수 없습니다.' },
118
+ ko: { do: '권장', dont: '비권장', error: '죄송합니다. 이 이미지를 불러올 수 없습니다.' },
119
+ };
120
+
121
+ const lang = (navLang ?? Astro.currentLocale ?? 'en').toLowerCase();
122
+ const defaults = DEFAULT_LABELS[lang] ?? DEFAULT_LABELS.en;
123
+
124
+ const {
125
+ doSrc,
126
+ doAlt,
127
+ dontSrc,
128
+ dontAlt,
129
+ doLabel = defaults.do,
130
+ dontLabel = defaults.dont,
131
+ loading = 'lazy',
132
+ errorText = defaults.error,
133
+ class: className,
134
+ } = Astro.props;
135
+
136
+ /**
137
+ * The width the stylesheet lays a screenshot out at (`--igd-dodont-image-width`)
138
+ * and the frame's minimum inline padding (`--igd-dodont-padding-inline`). They
139
+ * size the `srcset` candidates and the `sizes` hint, so keep them in step with
140
+ * DoDont.scss. A topic that retunes the token still gets correct pixels — the
141
+ * browser picks the closest candidate — just not the perfectly matched one.
142
+ */
143
+ const IMAGE_WIDTH = 360;
144
+ const PADDING_INLINE = 20;
145
+ const widths = [IMAGE_WIDTH, IMAGE_WIDTH * 2, IMAGE_WIDTH * 3];
146
+ // Below the stacking point the panel is the full container, so the image is
147
+ // roughly viewport-wide; above it the image sits at its design width.
148
+ const sizes = `(max-width: ${IMAGE_WIDTH + 2 * PADDING_INLINE}px) 100vw, ${IMAGE_WIDTH}px`;
149
+
150
+ const isImport = (image: ImageMetadata | string): image is ImageMetadata =>
151
+ typeof image !== 'string';
152
+
153
+ const panels = [
154
+ {
155
+ key: 'do',
156
+ image: doSrc,
157
+ alt: doAlt,
158
+ label: doLabel,
159
+ icon: 'check-bold',
160
+ variant: 'success',
161
+ },
162
+ {
163
+ key: 'dont',
164
+ image: dontSrc,
165
+ alt: dontAlt,
166
+ label: dontLabel,
167
+ icon: 'clear-bold',
168
+ variant: 'danger',
169
+ },
170
+ ] as const;
171
+
172
+ for (const panel of panels) {
173
+ if (typeof panel.image === 'string' ? !panel.image.trim() : !panel.image?.src) {
174
+ throw new Error(`<DoDont> requires a \`${panel.key}Src\` image (an import or a URL).`);
175
+ }
176
+ // The screenshots carry the guidance, so an absent, empty or whitespace-only
177
+ // alt would hide that guidance from screen-reader users. Fail loudly in dev.
178
+ if (!panel.alt?.trim()) {
179
+ throw new Error(
180
+ `<DoDont> requires a non-empty \`${panel.key}Alt\` describing the image for screen readers.`,
181
+ );
182
+ }
183
+ }
184
+
185
+ /**
186
+ * The descriptions are rendered up front so they can be validated. The slots
187
+ * carry the guidance in real, indexable text — a screenshot alone would leave
188
+ * search engines, translators and screen-reader users with only the alt — so
189
+ * an absent, empty or whitespace-only slot is a build error, like a missing
190
+ * alt. The rendered HTML is reused below instead of rendering the slot twice.
191
+ */
192
+ const descriptions: Record<(typeof panels)[number]['key'], string> = {
193
+ do: Astro.slots.has('do') ? await Astro.slots.render('do') : '',
194
+ dont: Astro.slots.has('dont') ? await Astro.slots.render('dont') : '',
195
+ };
196
+
197
+ for (const panel of panels) {
198
+ const text = descriptions[panel.key].replace(/<[^>]*>/g, '').replace(/&nbsp;/g, ' ');
199
+ if (!text.trim()) {
200
+ throw new Error(
201
+ `<DoDont> requires a non-empty "${panel.key}" slot explaining why that panel is the one to ${
202
+ panel.key === 'do' ? 'follow' : 'avoid'
203
+ }. An image is not guidance on its own.`,
204
+ );
205
+ }
206
+ }
207
+
208
+ const fetchpriority = loading === 'eager' ? 'high' : undefined;
209
+ ---
210
+
211
+ <div class:list={['igd-dodont', className]}>
212
+ {panels.map((panel) => (
213
+ <figure class:list={['igd-dodont__panel', `igd-dodont__panel--${panel.key}`]}>
214
+ <div class="igd-dodont__frame" data-error-text={errorText}>
215
+ {isImport(panel.image) ? (
216
+ <Image
217
+ class="igd-dodont__image"
218
+ src={panel.image}
219
+ alt={panel.alt}
220
+ widths={widths}
221
+ sizes={sizes}
222
+ loading={loading}
223
+ decoding="async"
224
+ fetchpriority={fetchpriority}
225
+ />
226
+ ) : (
227
+ <img
228
+ class="igd-dodont__image"
229
+ src={panel.image}
230
+ alt={panel.alt}
231
+ loading={loading}
232
+ decoding="async"
233
+ fetchpriority={fetchpriority}
234
+ />
235
+ )}
236
+ <igc-badge class="igd-dodont__badge" variant={panel.variant} outlined aria-hidden="true">
237
+ <igc-icon name={panel.icon} collection="docs" aria-hidden="true" />
238
+ </igc-badge>
239
+ </div>
240
+
241
+ <figcaption class="igd-dodont__caption">
242
+ {/* Kept on one line: Astro preserves template whitespace, and a text-node
243
+ space between the label and the separator would be announced as "Do : …". */}
244
+ {/* prettier-ignore */}
245
+ <span class="igd-dodont__label">{panel.label}<span class="igd-dodont__sr-only">: </span></span>
246
+ <div class="igd-dodont__description" set:html={descriptions[panel.key]} />
247
+ </figcaption>
248
+ </figure>
249
+ ))}
250
+ </div>
251
+
252
+ <script>
253
+ import { defineComponents, IgcBadgeComponent, IgcIconComponent } from 'igniteui-webcomponents';
254
+ import '../../../scripts/icon-registry';
255
+
256
+ defineComponents(IgcBadgeComponent, IgcIconComponent);
257
+
258
+ /**
259
+ * Mark every frame whose image has not arrived yet; the stylesheet shimmers
260
+ * a marked frame's canvas. The mark is added here, not server-side, so a
261
+ * page without JavaScript never shows a shimmer it cannot clear.
262
+ *
263
+ * `complete` is false for a lazy image the browser has not started fetching,
264
+ * so an off-screen frame shimmers until it scrolls into view and loads —
265
+ * which is exactly when a reader would look at it.
266
+ */
267
+ /** A torn picture frame: two halves of a rectangle split by a zigzag. */
268
+ const BROKEN_IMAGE_SVG =
269
+ '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">' +
270
+ '<path d="M4 11 4 5h16v6l-4-4-4 4-4-4Zm0 3 4-4 4 4 4-4 4 4v5H4Z" ' +
271
+ 'stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
272
+
273
+ /**
274
+ * Flag a frame whose image failed and show a broken-image icon with the
275
+ * frame's notice in its place. The notice is aria-hidden: it only tells a
276
+ * sighted reader why the box is empty, and the <img> still exposes the alt.
277
+ */
278
+ function markBroken(frame: HTMLElement): void {
279
+ if (frame.dataset.error !== undefined) return;
280
+ frame.dataset.error = '';
281
+
282
+ const fallback = document.createElement('span');
283
+ fallback.className = 'igd-dodont__fallback';
284
+ fallback.setAttribute('aria-hidden', 'true');
285
+
286
+ // Inline SVG rather than <igc-icon>: the fallback must not depend on the
287
+ // icon registry having loaded (or, in dev, on a glob that was evaluated
288
+ // before the icon file existed). Static markup, no user input.
289
+ const icon = document.createElement('span');
290
+ icon.className = 'igd-dodont__fallback-icon';
291
+ icon.innerHTML = BROKEN_IMAGE_SVG;
292
+
293
+ const text = document.createElement('span');
294
+ text.className = 'igd-dodont__fallback-text';
295
+ text.textContent = frame.dataset.errorText ?? '';
296
+
297
+ fallback.append(icon, text);
298
+ frame.append(fallback);
299
+ }
300
+
301
+ function markPendingFrames(): void {
302
+ const frames = document.querySelectorAll<HTMLElement>('.igd-dodont__frame');
303
+ for (const frame of frames) {
304
+ const img = frame.querySelector<HTMLImageElement>('.igd-dodont__image');
305
+ if (!img) continue;
306
+ if (img.complete) {
307
+ // Already settled before this ran. A broken image reports complete
308
+ // with no natural size.
309
+ if (img.naturalWidth === 0) markBroken(frame);
310
+ continue;
311
+ }
312
+
313
+ frame.dataset.loading = '';
314
+ const settle = () => {
315
+ delete frame.dataset.loading;
316
+ };
317
+ img.addEventListener('load', settle, { once: true });
318
+ img.addEventListener(
319
+ 'error',
320
+ () => {
321
+ settle();
322
+ markBroken(frame);
323
+ },
324
+ { once: true },
325
+ );
326
+ }
327
+ }
328
+
329
+ // astro:page-load fires on the initial load and after every client-router
330
+ // navigation, so it covers both without double-initialization.
331
+ document.addEventListener('astro:page-load', markPendingFrames);
332
+ </script>