igniteui-astro-components 1.1.0 → 1.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-astro-components",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
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": {
@@ -1,12 +1,12 @@
1
1
  # ThemingWidget
2
2
 
3
- A compact theme picker dropdown for sample viewers. The trigger shows the active
4
- theme (a multi-dot color swatch + theme name + muted mode label). Opening it
5
- reveals an optional **MODE** toggle (Light / Dark / System) and the list of
6
- selectable themes, with the active one checked.
3
+ A compact theme picker dropdown for sample viewers. An `igc-select` shows the
4
+ active theme with its multi-dot swatch. Its menu includes an optional **MODE**
5
+ row with Light and Dark icon buttons, followed by selectable theme options.
7
6
 
8
- Self-contained: icons are inlined SVGs and behavior is wired by a small client
9
- script — no `igniteui-webcomponents` registration required.
7
+ The widget uses `igniteui-webcomponents`: `igc-select`, `igc-select-item`,
8
+ `igc-select-header`, `igc-icon-button`, and `igc-icon`. A small client script
9
+ synchronizes widget state and publishes changes to sample iframes.
10
10
 
11
11
  ## Usage
12
12
 
@@ -29,32 +29,14 @@ page load.
29
29
 
30
30
  ## Color mode
31
31
 
32
- The MODE row offers **Light**, **Dark** and **System**. `system` is not passed
33
- on as-is: it is resolved against the OS `prefers-color-scheme` before it leaves
34
- the widget, so `mode` in the event — and the `data-igd-mode` written onto
35
- `target` — is always a concrete `light` or `dark` and consumers need no
36
- media-query handling of their own. The raw selection stays available as
37
- `modePreference` (and as `data-mode` on the widget root, with the resolved value
38
- mirrored on `data-resolved-mode`) for anything that mirrors the UI state.
39
-
40
- The trigger's muted mode label names the resolved mode, so a `system` selection
41
- reads as "Light" or "Dark" there — which mode is actually selected stays visible
42
- through the pressed state of the MODE buttons.
43
-
44
- While `system` is selected the widget follows the OS live: flipping the system
45
- appearance re-reflects `data-igd-mode`, updates that label and re-emits
46
- `igd-theme-change` without any interaction.
32
+ The MODE row exposes **Light** and **Dark** controls. A `system` value remains
33
+ accepted as an initial prop for compatibility; it resolves against
34
+ `prefers-color-scheme` before it is emitted or reflected onto `target`.
47
35
 
48
36
  ## Panel placement
49
37
 
50
- The panel is promoted to a native [popover](https://developer.mozilla.org/docs/Web/API/Popover_API)
51
- when the browser supports it, so it renders in the top layer and is never
52
- clipped by a scrolling or `overflow: hidden` ancestor (the sample container is
53
- one). It is placed below the trigger, flips above it when the space below is too
54
- small, and gets a `max-height` (with a scrolling list) when neither side fits —
55
- so it always stays inside the viewport. The position is recomputed while the
56
- panel is open on scroll and resize. Browsers without the Popover API keep the
57
- absolutely positioned panel, which still flips.
38
+ `igc-select` owns the popup. Its built-in `igc-popover` anchors the menu to the
39
+ input, flips it when necessary, and keeps the menu aligned with the select.
58
40
 
59
41
  ```js
60
42
  document.addEventListener('igd-theme-change', (e) => {
@@ -70,9 +52,9 @@ document.addEventListener('igd-theme-change', (e) => {
70
52
  | `themes` | `ThemeOption[]` | Material, Fluent, Bootstrap, Indigo | Selectable themes. Each has `name`, optional `label`, and a `swatch` array. |
71
53
  | `selectedTheme` | `string` | env, then first theme | Active theme `name`. See [Ambient defaults](#ambient-defaults). |
72
54
  | `mode` | `'light' \| 'dark' \| 'system'` | env, then `'light'` | Active color mode. See [Color mode](#color-mode) and [Ambient defaults](#ambient-defaults). |
73
- | `showMode` | `boolean` | `true` | Show the MODE (Light / Dark / System) toggle row. |
55
+ | `showMode` | `boolean` | `true` | Show the MODE (Light / Dark) control row. |
74
56
  | `target` | `string` | — | CSS selector to reflect `data-igd-theme` / `data-igd-mode` onto. |
75
- | `label` | `string` | `'Select theme'` | Accessible label for the trigger. |
57
+ | `label` | `string` | `'Select theme'` | Accessible label for the select. |
76
58
  | `id` | `string` | auto | Root element id. |
77
59
  | `class` | `string` | — | Extra class(es) forwarded to the root. |
78
60
 
@@ -2,16 +2,15 @@
2
2
  /**
3
3
  * ThemingWidget
4
4
  *
5
- * A compact theme picker dropdown used inside sample viewers. The trigger shows
6
- * the active theme (a small multi-dot color swatch + the theme name and, when a
7
- * mode is active, a muted label with the mode it resolves to). Opening the
8
- * trigger reveals a panel with:
5
+ * A compact theme picker dropdown used inside sample viewers. The select shows
6
+ * the active theme (a small multi-dot color swatch and its name). Opening it
7
+ * reveals a panel with:
9
8
  *
10
- * • an optional MODE row — three icon toggles for Light / Dark / System, and
9
+ * • an optional MODE row — two icon toggles for Light / Dark, and
11
10
  * • a list of selectable themes, each with its swatch; the active one is checked.
12
11
  *
13
- * The widget is self-contained (no web-component dependency): icons are inlined
14
- * SVGs and all behavior is wired by a small client script. On change it:
12
+ * The widget uses Ignite UI Web Components for the select, selectable options,
13
+ * and mode buttons. A small client script synchronizes the state. On change it:
15
14
  * • dispatches a bubbling `igd-theme-change` CustomEvent with
16
15
  * `{ theme, mode, modePreference }`, and
17
16
  * • reflects `data-igd-theme` / `data-igd-mode` on the optional `target` element.
@@ -30,14 +29,8 @@
30
29
  * `Astro.locals.envVars` — so a site sets its starting theme once instead of at
31
30
  * every call site.
32
31
  *
33
- * The panel is promoted to a native popover (top layer) when the browser
34
- * supports it, so it escapes any clipping/stacking ancestor — e.g. the sample
35
- * container's `overflow: hidden`. Its position is computed from the trigger and
36
- * flips above it when there is not enough room below; when constrained it gets
37
- * a `max-height` and scrolls. Browsers without the Popover API fall back to the
38
- * absolutely positioned panel, which still flips.
39
- *
40
- * Mirrors the "Theme-Input-Dropdown" design from the Doc Samples Figma file.
32
+ * The select's built-in popover owns overlay positioning and keyboard navigation.
33
+ * Mirrors the Combo Input and Dropdown designs from the Doc Samples Figma file.
41
34
  */
42
35
  import './ThemingWidget.scss';
43
36
 
@@ -65,7 +58,7 @@ interface Props {
65
58
  * `defaultSampleMode` env var and then to `'light'`.
66
59
  */
67
60
  mode?: ThemeMode;
68
- /** Show the MODE (Light / Dark / System) toggle row. Defaults to `true`. */
61
+ /** Show the MODE (Light / Dark) toggle row. Defaults to `true`. */
69
62
  showMode?: boolean;
70
63
  /** Element id for the root. Defaults to an auto-generated id. */
71
64
  id?: string;
@@ -99,6 +92,7 @@ const {
99
92
  } = Astro.props;
100
93
 
101
94
  const rootId = id ?? `igd-theming-${Math.random().toString(36).slice(2, 9)}`;
95
+ const modeButtonId = (mode: ThemeMode) => `${rootId}-${mode}-mode`;
102
96
 
103
97
  const titleCase = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
104
98
 
@@ -112,9 +106,7 @@ const env = Astro.locals.envVars ?? {};
112
106
  const activeName = selectedTheme ?? env.defaultSampleTheme ?? themes[0]?.name;
113
107
  const active = themes.find((t) => t.name === activeName) ?? themes[0];
114
108
  const activeLabel = active ? (active.label ?? titleCase(active.name)) : '';
115
-
116
- // ThemingWidget supports a "system" mode, but the docs host doesn't yet which results in an inconsistent behavior.
117
- // const const MODES: ThemeMode[] = ['light', 'dark', 'system'];
109
+ // Only explicit light and dark modes are offered by the sample theme picker.
118
110
  const MODES: ThemeMode[] = ['light', 'dark'];
119
111
 
120
112
  // The env var is free-form text, so an unrecognized value falls back to 'light'
@@ -139,160 +131,124 @@ const modeLabels: Record<ThemeMode, string> = {
139
131
  data-resolved-mode={mode === 'system' ? undefined : mode}
140
132
  data-theme={active?.name}
141
133
  >
142
- <button
143
- type="button"
144
- class="igd-theming__trigger"
145
- aria-haspopup="listbox"
146
- aria-expanded="false"
134
+ <igc-select
135
+ class="igd-theming__select"
147
136
  aria-label={label}
137
+ distance="4"
138
+ placement="bottom-end"
139
+ value={active?.name}
140
+ data-theme-select
148
141
  >
149
- <span class="igd-theming__swatch" data-swatch>
142
+ <igc-icon
143
+ slot="toggle-icon"
144
+ name="chevron"
145
+ collection="theming-widget"
146
+ class="igd-theming__toggle-icon igd-theming__toggle-icon--collapsed"
147
+ aria-hidden="true"></igc-icon>
148
+ <igc-icon
149
+ slot="toggle-icon-expanded"
150
+ name="chevron"
151
+ collection="theming-widget"
152
+ class="igd-theming__toggle-icon"
153
+ aria-hidden="true"></igc-icon>
154
+ <span slot="prefix" class="igd-theming__swatch" data-swatch>
150
155
  {active?.swatch.map((c) => <span class="igd-theming__dot" style={`--dot: ${c}`} />)}
151
156
  </span>
152
- <span class="igd-theming__value">
153
- <span class="igd-theming__theme-name" data-theme-name>{activeLabel}</span>
154
- {
155
- showMode && (
156
- <span class="igd-theming__mode-name" data-mode-name>
157
- {modeLabels[mode === 'system' ? 'light' : mode]}
158
- </span>
159
- )
160
- }
161
- </span>
162
- <svg
163
- class="igd-theming__chevron"
164
- width="12"
165
- height="12"
166
- viewBox="0 0 24 24"
167
- fill="none"
168
- aria-hidden="true"
169
- >
170
- <path
171
- d="M6 9l6 6 6-6"
172
- stroke="currentColor"
173
- stroke-width="2"
174
- stroke-linecap="round"
175
- stroke-linejoin="round"></path>
176
- </svg>
177
- </button>
178
-
179
- <div class="igd-theming__panel" role="dialog" hidden>
180
157
  {
181
158
  showMode && (
182
- <div class="igd-theming__mode-row">
159
+ <igc-select-header slot="header" class="igd-theming__mode-row">
183
160
  <span class="igd-theming__section-label">Mode</span>
184
161
  <div class="igd-theming__mode-buttons" role="group" aria-label="Color mode">
185
162
  {MODES.map((m) => (
186
- <button
187
- type="button"
163
+ <igc-icon-button
164
+ variant="flat"
165
+ name={m === 'light' ? 'sun' : 'moon'}
166
+ collection="theming-widget"
188
167
  class="igd-theming__mode-btn"
168
+ id={modeButtonId(m)}
189
169
  data-mode-btn={m}
190
170
  aria-pressed={m === mode ? 'true' : 'false'}
191
171
  aria-label={modeLabels[m]}
192
- title={modeLabels[m]}
193
- >
194
- {m === 'light' && (
195
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
196
- <circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="2" />
197
- <path
198
- d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4"
199
- stroke="currentColor"
200
- stroke-width="2"
201
- stroke-linecap="round"
202
- />
203
- </svg>
204
- )}
205
- {m === 'dark' && (
206
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
207
- <path
208
- d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"
209
- stroke="currentColor"
210
- stroke-width="2"
211
- stroke-linejoin="round"
212
- />
213
- </svg>
214
- )}
215
- {m === 'system' && (
216
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
217
- <rect
218
- x="3"
219
- y="4"
220
- width="18"
221
- height="12"
222
- rx="1.5"
223
- stroke="currentColor"
224
- stroke-width="2"
225
- />
226
- <path
227
- d="M8 20h8M12 16v4"
228
- stroke="currentColor"
229
- stroke-width="2"
230
- stroke-linecap="round"
231
- />
232
- </svg>
233
- )}
234
- </button>
172
+ />
235
173
  ))}
236
174
  </div>
237
- </div>
175
+ </igc-select-header>
238
176
  )
239
177
  }
240
-
241
- <ul class="igd-theming__list" role="listbox" aria-label={label}>
242
- {
243
- themes.map((t) => {
244
- const name = t.label ?? titleCase(t.name);
245
- const isActive = t.name === active?.name;
246
- return (
247
- <li>
248
- <button
249
- type="button"
250
- class="igd-theming__option"
251
- role="option"
252
- aria-selected={isActive ? 'true' : 'false'}
253
- data-option={t.name}
254
- data-label={name}
255
- data-swatch={t.swatch.join(',')}
256
- >
257
- <span class="igd-theming__swatch">
258
- {t.swatch.map((c) => (
259
- <span class="igd-theming__dot" style={`--dot: ${c}`} />
260
- ))}
261
- </span>
262
- <span class="igd-theming__option-name">{name}</span>
263
- <svg
264
- class="igd-theming__check"
265
- width="16"
266
- height="16"
267
- viewBox="0 0 24 24"
268
- fill="none"
269
- aria-hidden="true"
270
- >
271
- <path
272
- d="M5 13l4 4L19 7"
273
- stroke="currentColor"
274
- stroke-width="2"
275
- stroke-linecap="round"
276
- stroke-linejoin="round"
277
- />
278
- </svg>
279
- </button>
280
- </li>
281
- );
282
- })
283
- }
284
- </ul>
285
- </div>
178
+ {
179
+ themes.map((t) => {
180
+ const name = t.label ?? titleCase(t.name);
181
+ return (
182
+ <igc-select-item
183
+ class="igd-theming__option"
184
+ value={t.name}
185
+ data-option={t.name}
186
+ data-label={name}
187
+ data-swatch={t.swatch.join(',')}
188
+ >
189
+ <span slot="prefix" class="igd-theming__swatch">
190
+ {t.swatch.map((c) => (
191
+ <span class="igd-theming__dot" style={`--dot: ${c}`} />
192
+ ))}
193
+ </span>
194
+ <span class="igd-theming__option-name">{name}</span>
195
+ <igc-icon slot="suffix" name="check" collection="theming-widget" aria-hidden="true" />
196
+ </igc-select-item>
197
+ );
198
+ })
199
+ }
200
+ </igc-select>
201
+ {
202
+ showMode &&
203
+ MODES.map((m) => (
204
+ <igc-tooltip
205
+ anchor={modeButtonId(m)}
206
+ class="igd-theming__mode-tooltip"
207
+ placement="bottom"
208
+ with-arrow
209
+ >
210
+ {modeLabels[m]}
211
+ </igc-tooltip>
212
+ ))
213
+ }
214
+ <span class="igd-theming__selected-value" aria-hidden="true">
215
+ <span class="igd-theming__selected-theme" data-selected-theme>{activeLabel}</span>
216
+ <span class="igd-theming__selected-mode" data-selected-mode>{modeLabels[mode]}</span>
217
+ </span>
286
218
  </div>
287
219
 
288
220
  <script>
221
+ import {
222
+ defineComponents,
223
+ IgcIconButtonComponent,
224
+ IgcIconComponent,
225
+ IgcSelectComponent,
226
+ IgcSelectHeaderComponent,
227
+ IgcSelectItemComponent,
228
+ IgcTooltipComponent,
229
+ registerIconFromText,
230
+ } from 'igniteui-webcomponents';
231
+ import sun from './assets/sun.svg?raw';
232
+ import moon from './assets/moon.svg?raw';
233
+ import check from './assets/check.svg?raw';
234
+ import chevron from './assets/chevron.svg?raw';
235
+
236
+ defineComponents(
237
+ IgcIconButtonComponent,
238
+ IgcIconComponent,
239
+ IgcSelectComponent,
240
+ IgcSelectHeaderComponent,
241
+ IgcSelectItemComponent,
242
+ IgcTooltipComponent,
243
+ );
244
+ registerIconFromText('sun', sun, 'theming-widget');
245
+ registerIconFromText('moon', moon, 'theming-widget');
246
+ registerIconFromText('check', check, 'theming-widget');
247
+ registerIconFromText('chevron', chevron, 'theming-widget');
248
+
289
249
  class IgdThemingWidget {
290
250
  private root: HTMLElement;
291
- private trigger: HTMLButtonElement;
292
- private panel: HTMLElement;
293
- /** Whether the panel was promoted to a top-layer popover. */
294
- private usePopover: boolean;
295
- private reposition = () => this.position();
251
+ private select: HTMLElement & { value?: string };
296
252
  /** Backs the `system` mode: the OS color-scheme preference. */
297
253
  private scheme = window.matchMedia('(prefers-color-scheme: dark)');
298
254
  private onSchemeChange = () => {
@@ -304,21 +260,7 @@ const modeLabels: Record<ThemeMode, string> = {
304
260
 
305
261
  constructor(root: HTMLElement) {
306
262
  this.root = root;
307
- this.trigger = root.querySelector('.igd-theming__trigger') as HTMLButtonElement;
308
- this.panel = root.querySelector('.igd-theming__panel') as HTMLElement;
309
-
310
- // Promote to the top layer so ancestors that clip (the sample container
311
- // uses `overflow: hidden`) or create a stacking context can't swallow the
312
- // panel. `manual` — not `auto` — because light dismiss and Escape are
313
- // already handled below, and `auto` would also close the panel on the
314
- // very click that opened it.
315
- this.usePopover = typeof this.panel.showPopover === 'function';
316
- if (this.usePopover) {
317
- this.panel.setAttribute('popover', 'manual');
318
- // A closed popover is `display: none` by UA style, so the `hidden`
319
- // attribute (the no-JS fallback) is no longer needed and would win.
320
- this.panel.hidden = false;
321
- }
263
+ this.select = root.querySelector('[data-theme-select]') as HTMLElement & { value?: string };
322
264
 
323
265
  this.bind();
324
266
 
@@ -329,129 +271,33 @@ const modeLabels: Record<ThemeMode, string> = {
329
271
  }
330
272
 
331
273
  private bind() {
332
- this.trigger.addEventListener('click', () => this.toggle());
333
-
334
- this.root.querySelectorAll<HTMLElement>('.igd-theming__option').forEach((opt) => {
335
- opt.addEventListener('click', () => {
336
- this.selectTheme(opt, true);
337
- this.close();
338
- });
274
+ this.select.addEventListener('igcChange', (event) => {
275
+ const option = (event as CustomEvent<HTMLElement>).detail;
276
+ if (option) this.selectTheme(option, true);
339
277
  });
340
278
 
341
279
  this.root.querySelectorAll<HTMLElement>('.igd-theming__mode-btn').forEach((btn) => {
342
- btn.addEventListener('click', () => {
280
+ btn.addEventListener('click', (event) => {
281
+ event.stopPropagation();
343
282
  this.selectMode(btn.dataset.modeBtn || 'light', true);
344
283
  });
345
284
  });
346
-
347
- document.addEventListener('click', (e) => {
348
- if (!this.root.contains(e.target as Node)) this.close();
349
- });
350
- document.addEventListener('keydown', (e) => {
351
- if (e.key === 'Escape' && this.isOpen()) {
352
- this.close();
353
- this.trigger.focus();
354
- }
355
- });
356
- }
357
-
358
- private isOpen() {
359
- return this.trigger.getAttribute('aria-expanded') === 'true';
360
- }
361
-
362
- private toggle() {
363
- if (this.isOpen()) {
364
- this.close();
365
- } else {
366
- this.open();
367
- }
368
- }
369
-
370
- private open() {
371
- this.trigger.setAttribute('aria-expanded', 'true');
372
- if (this.usePopover) {
373
- this.panel.showPopover();
374
- } else {
375
- this.panel.hidden = false;
376
- }
377
- this.root.classList.add('is-open');
378
- this.position();
379
- // The trigger can live inside a scrolling container (or the page itself
380
- // can scroll), so follow it for as long as the panel is open. Capture
381
- // phase catches scrolls on any ancestor, not just the document.
382
- window.addEventListener('scroll', this.reposition, { capture: true, passive: true });
383
- window.addEventListener('resize', this.reposition, { passive: true });
384
- }
385
-
386
- private close() {
387
- this.trigger.setAttribute('aria-expanded', 'false');
388
- if (this.usePopover) {
389
- if (this.panel.matches(':popover-open')) this.panel.hidePopover();
390
- } else {
391
- this.panel.hidden = true;
392
- }
393
- this.root.classList.remove('is-open', 'is-above');
394
- window.removeEventListener('scroll', this.reposition, { capture: true });
395
- window.removeEventListener('resize', this.reposition);
396
- }
397
-
398
- /**
399
- * Place the panel below the trigger, or above it when the space below is
400
- * too small and there is more room above. When neither side fits the full
401
- * panel, the taller side wins and the panel is capped with a `max-height`
402
- * (the list scrolls) so it always stays inside the viewport.
403
- */
404
- private position() {
405
- if (!this.isOpen()) return;
406
-
407
- const GAP = 4; // matches the CSS offset of the fallback panel
408
- const EDGE = 8; // keep this much clearance from the viewport edges
409
-
410
- const anchor = this.trigger.getBoundingClientRect();
411
- this.panel.style.maxHeight = '';
412
- const height = this.panel.offsetHeight;
413
-
414
- const roomBelow = window.innerHeight - anchor.bottom - GAP - EDGE;
415
- const roomAbove = anchor.top - GAP - EDGE;
416
- const above = height > roomBelow && roomAbove > roomBelow;
417
-
418
- const available = above ? roomAbove : roomBelow;
419
- if (height > available) this.panel.style.maxHeight = `${Math.max(available, 96)}px`;
420
- this.root.classList.toggle('is-above', above);
421
-
422
- if (!this.usePopover) return;
423
-
424
- // Top-layer popovers are positioned against the viewport, so the
425
- // trigger's viewport rect can be used directly.
426
- const shown = this.panel.offsetHeight; // post-cap height
427
- const top = above ? Math.max(EDGE, anchor.top - GAP - shown) : anchor.bottom + GAP;
428
- const maxLeft = window.innerWidth - this.panel.offsetWidth - EDGE;
429
- const left = Math.max(EDGE, Math.min(anchor.left, maxLeft));
430
-
431
- this.panel.style.top = `${top}px`;
432
- this.panel.style.left = `${left}px`;
433
285
  }
434
286
 
435
287
  private selectTheme(opt: HTMLElement, emit: boolean) {
436
288
  const name = opt.dataset.option || '';
437
- const label = opt.dataset.label || name;
438
289
  const swatch = (opt.dataset.swatch || '').split(',').filter(Boolean);
439
290
 
440
- this.root
441
- .querySelectorAll('.igd-theming__option')
442
- .forEach((o) => o.setAttribute('aria-selected', 'false'));
443
- opt.setAttribute('aria-selected', 'true');
444
-
445
- const nameEl = this.trigger.querySelector('[data-theme-name]');
446
- if (nameEl) nameEl.textContent = label;
447
-
448
- const swatchEl = this.trigger.querySelector('[data-swatch]');
291
+ const swatchEl = this.root.querySelector('[data-swatch]');
449
292
  if (swatchEl) {
450
293
  swatchEl.innerHTML = swatch
451
294
  .map((c) => `<span class="igd-theming__dot" style="--dot: ${c}"></span>`)
452
295
  .join('');
453
296
  }
454
297
 
298
+ const themeLabel = this.root.querySelector<HTMLElement>('[data-selected-theme]');
299
+ if (themeLabel) themeLabel.textContent = opt.dataset.label || name;
300
+
455
301
  this.root.dataset.theme = name;
456
302
  this.reflect();
457
303
  if (emit) this.emit();
@@ -478,14 +324,6 @@ const modeLabels: Record<ThemeMode, string> = {
478
324
  const resolved = this.resolvedMode;
479
325
  this.root.dataset.resolvedMode = resolved;
480
326
 
481
- // The trigger names the mode the sample actually renders in, so `system`
482
- // reads as "Light" / "Dark" there — the selection itself stays visible
483
- // through the pressed state of the mode buttons.
484
- const modeNameEl = this.trigger.querySelector('[data-mode-name]');
485
- if (modeNameEl) {
486
- modeNameEl.textContent = resolved.charAt(0).toUpperCase() + resolved.slice(1);
487
- }
488
-
489
327
  this.reflect();
490
328
  }
491
329
 
@@ -495,6 +333,9 @@ const modeLabels: Record<ThemeMode, string> = {
495
333
  });
496
334
  this.root.dataset.mode = mode;
497
335
 
336
+ const modeLabel = this.root.querySelector<HTMLElement>('[data-selected-mode]');
337
+ if (modeLabel) modeLabel.textContent = mode === 'dark' ? 'Dark' : 'Light';
338
+
498
339
  this.applyResolvedMode();
499
340
  if (emit) this.emit();
500
341
  }
@@ -2,84 +2,135 @@
2
2
 
3
3
  @layer components {
4
4
  .igd-theming {
5
- // Public custom properties (override from an ancestor or via `class`)
6
- --igd-theming-radius: #{rem(5px)};
5
+ --igd-theming-radius: #{rem(4px)};
7
6
  --igd-theming-border: var(--ig-gray-300);
8
7
  --igd-theming-bg: light-dark(#fff, var(--ig-gray-100));
9
8
  --igd-theming-fg: var(--ig-gray-900);
10
9
  --igd-theming-muted: var(--ig-gray-500);
11
10
  --igd-theming-hover-bg: var(--ig-gray-100);
12
11
  --igd-theming-accent: var(--igd-accent, var(--ig-primary-500));
13
- --igd-theming-selected-bg: rgb(33 33 33 / 8%);
14
- --igd-theming-selected-bg: color-mix(in srgb, var(--ig-gray-900) 8%, transparent);
15
12
 
16
13
  position: relative;
17
14
  display: inline-block;
18
- font-family: var(--ig-font-family, 'Aktiv Grotesk', var(--igd-font-sans, sans-serif));
19
- font-size: #{rem(14px)};
20
- line-height: #{rem(20px)};
15
+ width: rem(203px);
16
+ max-width: 100%;
21
17
  color: var(--igd-theming-fg);
18
+ font-family: var(--ig-font-family, 'Aktiv Grotesk', var(--igd-font-sans, sans-serif));
22
19
  }
23
20
 
24
- // ── Trigger ──────────────────────────────────────────────────────────────
25
- .igd-theming__trigger {
26
- display: inline-flex;
27
- align-items: center;
28
- gap: rem(8px);
29
- width: rem(203px);
30
- box-sizing: border-box;
31
- height: rem(40px);
32
- min-height: rem(40px);
33
- padding: rem(8px) rem(16px);
34
- background: var(--igd-theming-bg);
35
- color: var(--igd-theming-fg);
36
- border: rem(1px) solid var(--igd-theming-border);
37
- border-radius: var(--igd-theming-radius);
38
- cursor: pointer;
39
- line-height: #{rem(20px)};
40
- transition:
41
- border-color 0.15s ease,
42
- box-shadow 0.15s ease;
43
-
44
- &:focus-visible {
45
- outline: none;
46
- border-color: var(--igd-theming-accent);
47
- box-shadow: 0 0 0 rem(2px) color-mix(in srgb, var(--igd-theming-accent) 25%, transparent);
21
+ .igd-theming__select {
22
+ width: 100%;
23
+ --ig-input-group-border-color: var(--igd-theming-border);
24
+ --ig-input-group-hover-border-color: var(--ig-gray-400);
25
+ --ig-input-group-focused-border-color: var(--igd-theming-accent);
26
+ --ig-input-group-border-border-radius: var(--igd-theming-radius);
27
+ --ig-input-group-input-prefix-background: transparent;
28
+ --ig-input-group-input-prefix-background--filled: transparent;
29
+ --ig-input-group-input-prefix-color--filled: var(--igd-theming-fg);
30
+ --ig-input-group-input-suffix-background: transparent;
31
+ --ig-input-group-input-suffix-background--filled: transparent;
32
+ --ig-input-group-idle-text-color: transparent;
33
+ --ig-input-group-filled-text-color: transparent;
34
+ --ig-input-group-filled-text-hover-color: transparent;
35
+ --ig-input-group-focused-text-color: transparent;
36
+ --ig-select-toggle-button-background: transparent;
37
+ --ig-select-toggle-button-foreground: var(--ig-gray-600);
38
+ --ig-drop-down-background-color: var(--igd-theming-bg);
39
+ --ig-drop-down-border-color: var(--igd-theming-border);
40
+ --ig-drop-down-border-width: #{rem(1px)};
41
+ --ig-drop-down-border-radius: var(--igd-theming-radius);
42
+ --ig-drop-down-size: #{rem(40px)};
43
+ --ig-drop-down-hover-item-background: var(--igd-theming-hover-bg);
44
+ --ig-drop-down-item-text-color: var(--igd-theming-fg);
45
+ --ig-drop-down-item-icon-color: var(--igd-theming-fg);
46
+ --ig-drop-down-hover-item-text-color: var(--igd-theming-fg);
47
+ --ig-drop-down-hover-item-icon-color: var(--igd-theming-fg);
48
+ --ig-drop-down-focused-item-background: var(--igd-theming-hover-bg);
49
+ --ig-drop-down-focused-item-text-color: var(--igd-theming-fg);
50
+ --ig-drop-down-focused-item-icon-color: var(--igd-theming-fg);
51
+ --ig-drop-down-focused-item-border-color: transparent;
52
+ --ig-drop-down-selected-item-background: transparent;
53
+ --ig-drop-down-selected-item-text-color: var(--igd-theming-fg);
54
+ --ig-drop-down-selected-item-icon-color: var(--igd-theming-accent);
55
+ --ig-drop-down-selected-hover-item-background: var(--igd-theming-hover-bg);
56
+ --ig-drop-down-selected-hover-item-text-color: var(--igd-theming-fg);
57
+ --ig-drop-down-selected-hover-item-icon-color: var(--igd-theming-accent);
58
+ --ig-drop-down-selected-focus-item-background: transparent;
59
+ --ig-drop-down-selected-focus-item-text-color: var(--igd-theming-fg);
60
+ --ig-drop-down-selected-focus-item-icon-color: var(--igd-theming-accent);
61
+
62
+ &::part(input) {
63
+ min-height: rem(40px);
64
+ color: transparent;
65
+ font-family: inherit;
66
+ font-size: rem(14px);
67
+ font-weight: 500;
68
+ letter-spacing: rem(0.25px);
69
+ line-height: rem(20px);
70
+ }
71
+
72
+ &::part(base) {
73
+ padding-block: 0;
74
+ border: rem(1px) solid var(--igd-theming-border);
75
+ border-radius: var(--igd-theming-radius);
76
+ box-shadow:
77
+ 0 rem(10px) rem(15px) rem(-3px) rgb(0 0 0 / 10%),
78
+ 0 rem(4px) rem(6px) rem(-4px) rgb(0 0 0 / 10%);
48
79
  }
49
80
  }
50
81
 
51
- .igd-theming__value {
82
+ .igd-theming__selected-value {
83
+ position: absolute;
84
+ z-index: 1;
85
+ top: 50%;
86
+ left: rem(48px);
52
87
  display: inline-flex;
53
88
  align-items: baseline;
54
89
  gap: rem(4px);
55
- margin-inline-end: auto;
90
+ max-width: calc(100% - #{rem(88px)});
91
+ pointer-events: none;
92
+ transform: translateY(-50%);
56
93
  white-space: nowrap;
57
94
  }
58
95
 
59
- .igd-theming__theme-name {
60
- font-weight: 500;
96
+ // Dark mode displays all three swatch dots. Reserve space for the extra dot
97
+ // before the absolutely positioned label so the two never overlap.
98
+ .igd-theming[data-resolved-mode='dark'] .igd-theming__selected-value {
99
+ left: rem(56px);
100
+ max-width: calc(100% - #{rem(96px)});
61
101
  }
62
102
 
63
- .igd-theming__mode-name {
64
- color: var(--igd-theming-muted);
65
- font-weight: 400;
103
+ .igd-theming__selected-theme,
104
+ .igd-theming__selected-mode {
105
+ overflow: hidden;
106
+ text-overflow: ellipsis;
107
+ font-size: rem(14px);
108
+ letter-spacing: rem(0.25px);
66
109
  }
67
110
 
68
- .igd-theming__chevron {
69
- flex-shrink: 0;
70
- color: var(--igd-theming-muted);
71
- transition: transform 0.15s ease;
111
+ .igd-theming__selected-theme {
112
+ color: var(--igd-theming-fg);
113
+ font-weight: 500;
114
+ line-height: rem(20px);
72
115
  }
73
116
 
74
- .igd-theming.is-open .igd-theming__chevron {
75
- transform: rotate(180deg);
117
+ .igd-theming__selected-mode {
118
+ color: var(--igd-theming-muted);
119
+ font-size: rem(12px);
120
+ font-weight: 400;
121
+ line-height: rem(16px);
76
122
  }
77
123
 
78
- // ── Swatch ───────────────────────────────────────────────────────────────
79
124
  .igd-theming__swatch {
80
125
  display: inline-flex;
81
126
  flex-shrink: 0;
82
127
  align-items: center;
128
+ gap: rem(2px);
129
+ }
130
+
131
+ // Bootstrap's medium select prefix inset is 10px; the Figma trigger uses 16px.
132
+ .igd-theming__select > .igd-theming__swatch {
133
+ margin-inline-start: rem(6px);
83
134
  }
84
135
 
85
136
  .igd-theming__dot {
@@ -88,195 +139,137 @@
88
139
  height: rem(12px);
89
140
  border-radius: 50%;
90
141
  background: var(--dot);
91
- box-shadow: 0 0 0 rem(3px) var(--igd-theming-bg);
92
142
  }
93
143
 
94
- // Light mode shows only the two accent dots; dark mode adds the leading
95
- // (surface) dot for three total. Mirrors the Figma light/dark variants.
96
- .igd-theming[data-mode='light'] .igd-theming__dot:first-child {
97
- display: none;
144
+ .igd-theming__dot:not(:last-child) {
145
+ width: rem(10.123px);
146
+ border-radius: 0;
147
+ mask: url('./assets/swatch-leading.svg') center / contain no-repeat;
98
148
  }
99
149
 
100
- // The now-first visible dot must not keep the overlap offset.
101
- .igd-theming[data-mode='light'] .igd-theming__dot:first-child + .igd-theming__dot {
102
- margin-inline-start: 0;
150
+ .igd-theming[data-mode='light'] .igd-theming__dot:first-child {
151
+ display: none;
103
152
  }
104
153
 
105
- // `system` follows the OS preference. The dark arrangement is the default,
106
- // so only the light half needs a rule — expressed in CSS rather than through
107
- // the script's resolved mode so the swatch is already correct on first paint.
108
154
  @media (prefers-color-scheme: light) {
109
155
  .igd-theming[data-mode='system'] .igd-theming__dot:first-child {
110
156
  display: none;
111
157
  }
112
-
113
- .igd-theming[data-mode='system'] .igd-theming__dot:first-child + .igd-theming__dot {
114
- margin-inline-start: 0;
115
- }
116
- }
117
-
118
- // ── Panel ────────────────────────────────────────────────────────────────
119
- // Fallback placement, used when the browser has no Popover API. The panel
120
- // stays in flow next to the trigger and is therefore still subject to any
121
- // clipping ancestor; it can at least flip via `.is-above`.
122
- .igd-theming__panel {
123
- position: absolute;
124
- inset-block-start: calc(100% + #{rem(4px)});
125
- inset-inline-start: 0;
126
- z-index: 100;
127
- width: rem(203px);
128
- box-sizing: border-box;
129
- padding-block: 0;
130
- background: var(--igd-theming-bg);
131
- border: rem(1px) solid var(--igd-theming-border);
132
- border-radius: var(--igd-theming-radius);
133
- box-shadow: 0 rem(8px) rem(24px) rgb(0 0 0 / 12%);
134
- overflow: hidden auto;
135
-
136
- &[hidden] {
137
- display: none;
138
- }
139
158
  }
140
159
 
141
- .igd-theming.is-above .igd-theming__panel {
142
- inset-block-start: auto;
143
- inset-block-end: calc(100% + #{rem(4px)});
144
- }
145
-
146
- // Top-layer placement: the script sets `popover` on the panel and drives
147
- // `top`/`left` from the trigger's viewport rect, so the UA popover centering
148
- // (`margin: auto; inset: 0`) has to be cleared.
149
- .igd-theming__panel:popover-open {
150
- position: fixed;
151
- inset: auto;
152
- margin: 0;
153
- overflow: hidden auto;
154
- overscroll-behavior: contain;
155
- }
156
-
157
- // ── Mode row ─────────────────────────────────────────────────────────────
158
160
  .igd-theming__mode-row {
161
+ // igc-select-header is non-interactive by default. This header contains
162
+ // the color-mode controls, so restore hit testing only for this widget.
163
+ pointer-events: auto !important;
159
164
  display: flex;
160
165
  align-items: center;
161
166
  justify-content: space-between;
162
- gap: rem(12px);
163
- min-height: rem(40px);
164
- padding-inline: rem(12px);
165
- border: none;
166
167
  margin: 0;
168
+ min-height: rem(40px);
169
+ padding-inline: rem(16px);
167
170
  }
168
171
 
169
172
  .igd-theming__section-label {
170
173
  @include type-style('overline');
171
174
 
172
- color: var(--ig-gray-500);
175
+ color: var(--igd-theming-muted);
176
+ font-size: rem(10px);
177
+ letter-spacing: rem(1.5px);
178
+ text-transform: uppercase;
173
179
  }
174
180
 
175
181
  .igd-theming__mode-buttons {
176
182
  display: inline-flex;
177
- gap: 0;
178
- margin: 0;
183
+ align-items: center;
184
+ pointer-events: auto;
179
185
  }
180
186
 
181
187
  .igd-theming__mode-btn {
182
- display: inline-flex;
183
- align-items: center;
184
- justify-content: center;
185
188
  width: rem(24px);
186
189
  height: rem(24px);
187
- padding: 0;
188
- margin: 0;
189
- background: transparent;
190
- color: var(--igd-theming-muted);
191
- border: none;
192
- border-radius: 50%;
193
- cursor: pointer;
194
- transition:
195
- background 0.15s ease,
196
- color 0.15s ease;
197
-
198
- &:hover {
199
- background: var(--igd-theming-hover-bg);
200
- color: var(--igd-theming-fg);
190
+ pointer-events: auto;
191
+ --foreground: var(--igd-theming-muted);
192
+ --hover-foreground: var(--igd-theming-fg);
193
+ --focus-foreground: var(--igd-theming-fg);
194
+ --hover-background: var(--igd-theming-hover-bg);
195
+ --focus-background: var(--igd-theming-hover-bg);
196
+ --active-background: var(--igd-theming-hover-bg);
197
+ --border-radius: 50%;
198
+
199
+ &::part(base) {
200
+ width: rem(24px);
201
+ height: rem(24px);
202
+ padding: rem(3px);
203
+ }
204
+
205
+ &::part(icon) {
206
+ --size: #{rem(18px)};
201
207
  }
202
208
 
203
209
  &[aria-pressed='true'] {
204
- background-color: var(--igd-theming-selected-bg);
205
- color: var(--igd-theming-fg);
210
+ --foreground: var(--igd-theming-fg);
211
+ --background: rgb(0 20 43 / 8%);
212
+ --hover-background: rgb(0 20 43 / 8%);
213
+ --focus-background: rgb(0 20 43 / 8%);
206
214
  }
215
+ }
207
216
 
208
- &:focus-visible {
209
- outline: rem(2px) solid var(--igd-theming-accent);
210
- outline-offset: rem(1px);
217
+ .igd-theming__mode-tooltip {
218
+ --ig-tooltip-background: rgb(52 75 101 / 90%);
219
+ --ig-tooltip-text-color: var(--ig-gray-50);
220
+ --ig-tooltip-border-radius: var(--igd-theming-radius);
221
+
222
+ &::part(base) {
223
+ min-height: rem(24px);
224
+ padding: rem(4px) rem(8px);
225
+ font-family: inherit;
226
+ font-size: rem(10px);
227
+ font-weight: 500;
228
+ letter-spacing: rem(0.33px);
229
+ line-height: rem(16px);
211
230
  }
212
231
  }
213
232
 
214
- // ── Theme list ───────────────────────────────────────────────────────────
215
- .igd-theming .igd-theming__list {
216
- list-style: none;
217
- margin: 0;
218
- padding: 0;
219
- border: none;
233
+ .igd-theming__toggle-icon {
234
+ --size: #{rem(18px)};
220
235
  }
221
236
 
222
- .igd-theming__list > li {
223
- margin: 0;
224
- padding: 0;
237
+ // The exported Figma chevron points upward; the collapsed select state
238
+ // uses the same glyph rotated to point down.
239
+ .igd-theming__toggle-icon--collapsed {
240
+ transform: rotate(180deg);
225
241
  }
226
242
 
227
- .igd-theming .igd-theming__option {
228
- display: flex;
229
- align-items: center;
230
- justify-content: flex-start;
231
- gap: rem(8px);
232
- width: 100%;
233
- box-sizing: border-box;
234
- height: rem(40px);
243
+ .igd-theming__option {
244
+ border: 0;
245
+ outline: none;
235
246
  min-height: rem(40px);
236
- padding-block: 0;
237
- padding-inline: rem(24px) rem(12px);
238
- background: transparent;
239
- color: #00142b;
240
- border: none;
241
- cursor: pointer;
242
- text-align: start;
243
- font-family: var(--ig-body-2-font-family, var(--ig-font-family, 'Aktiv Grotesk', sans-serif));
244
- font-size: #{rem(14px)};
245
- line-height: #{rem(20px)};
246
- letter-spacing: 0.25px;
247
+ padding-inline: rem(24px) rem(18px);
248
+ font-family: inherit;
249
+ font-size: rem(14px);
247
250
  font-weight: 500;
251
+ letter-spacing: rem(0.25px);
252
+ line-height: rem(20px);
248
253
 
249
- &:hover {
250
- background: var(--igd-theming-hover-bg);
254
+ &::part(prefix) {
255
+ margin-inline-end: rem(8px);
251
256
  }
252
257
 
253
- &:focus-visible {
254
- outline: rem(2px) solid var(--igd-theming-accent);
255
- outline-offset: rem(-2px);
258
+ &:not([selected]) igc-icon {
259
+ visibility: hidden;
256
260
  }
257
- }
258
-
259
- .igd-theming__option-name {
260
- margin-inline-end: auto;
261
- font-family: var(--ig-body-2-font-family, var(--ig-font-family, 'Aktiv Grotesk', sans-serif));
262
- font-size: #{rem(14px)};
263
- line-height: #{rem(20px)};
264
- letter-spacing: 0.25px;
265
- font-weight: 500;
266
- color: #00142b;
267
- }
268
261
 
269
- .igd-theming__option[aria-selected='true'] .igd-theming__option-name {
270
- font-weight: 500;
271
- }
262
+ igc-icon {
263
+ --size: #{rem(20px)};
264
+ }
272
265
 
273
- .igd-theming__check {
274
- flex-shrink: 0;
275
- color: var(--igd-theming-accent);
276
- opacity: 0;
266
+ &[active],
267
+ &[selected] {
268
+ outline: none;
269
+ }
277
270
  }
278
271
 
279
- .igd-theming__option[aria-selected='true'] .igd-theming__check {
280
- opacity: 1;
272
+ .igd-theming__option-name {
273
+ color: var(--igd-theming-fg);
281
274
  }
282
275
  }
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Doc-Samples-Icons">
3
+ <path id="Vector" d="M8.10816 12.3124L14.3373 6.08325C14.4901 5.93048 14.6672 5.85409 14.8686 5.85409C15.07 5.85409 15.247 5.93048 15.3998 6.08325C15.5526 6.23603 15.629 6.41312 15.629 6.6145C15.629 6.81589 15.5526 6.99298 15.3998 7.14575L8.64982 13.9166C8.49704 14.0694 8.31996 14.1458 8.11857 14.1458C7.91718 14.1458 7.7401 14.0694 7.58732 13.9166L4.60815 10.9374C4.45538 10.7846 4.37899 10.6076 4.37899 10.4062C4.37899 10.2048 4.45538 10.0277 4.60815 9.87492C4.76093 9.72214 4.93802 9.64575 5.1394 9.64575C5.34079 9.64575 5.51788 9.72214 5.67065 9.87492L8.10816 12.3124Z" fill="#0176FF"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Icon">
3
+ <path id="Color" fill-rule="evenodd" clip-rule="evenodd" d="M5.5575 11.5575L9 8.1225L12.4425 11.5575L13.5 10.5L9 6L4.5 10.5L5.5575 11.5575Z" fill="#556C86"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Doc-Samples-Icons">
3
+ <path id="Vector" d="M9.09321 14.8362C7.45384 14.8362 6.05652 14.2586 4.90127 13.1033C3.74602 11.9479 3.1684 10.5504 3.1684 8.91062C3.1684 7.55625 3.58877 6.34419 4.42952 5.27444C5.2704 4.20469 6.37852 3.50906 7.7539 3.18756C7.89777 3.14944 8.02665 3.15706 8.14052 3.21044C8.25452 3.26381 8.34327 3.33712 8.40677 3.43037C8.47015 3.52375 8.50809 3.637 8.52059 3.77012C8.53309 3.90325 8.50765 4.03619 8.44427 4.16894C8.3269 4.41319 8.23696 4.6715 8.17446 4.94387C8.11196 5.21625 8.08071 5.48869 8.08071 5.76119C8.08071 6.92781 8.48284 7.91325 9.28709 8.7175C10.0912 9.52162 11.0766 9.92369 12.2432 9.92369C12.561 9.92369 12.8628 9.88644 13.1486 9.81194C13.4345 9.73744 13.6971 9.65112 13.9365 9.553C14.0596 9.49925 14.1798 9.48337 14.2971 9.50537C14.4145 9.5275 14.5116 9.56981 14.5885 9.63231C14.6741 9.69481 14.7423 9.77706 14.7932 9.87906C14.8442 9.98094 14.8524 10.0924 14.8178 10.2136C14.5514 11.5636 13.8838 12.6715 12.8151 13.5374C11.7463 14.4032 10.5057 14.8362 9.09321 14.8362ZM9.07446 13.8612C10.1111 13.8612 11.0416 13.5736 11.8661 12.9985C12.6906 12.4235 13.2913 11.6736 13.6682 10.7487C13.4182 10.8112 13.1745 10.8612 12.937 10.8987C12.6995 10.9362 12.462 10.9549 12.2245 10.9549C10.7961 10.9549 9.57965 10.4519 8.57515 9.44594C7.57052 8.43994 7.06821 7.22175 7.06821 5.79137C7.06821 5.55875 7.08696 5.32369 7.12446 5.08619C7.16196 4.84869 7.21196 4.60494 7.27446 4.35494C6.34946 4.72994 5.59946 5.3295 5.02446 6.15362C4.44946 6.97775 4.16196 7.90781 4.16196 8.94381C4.16196 10.3096 4.64152 11.4706 5.60065 12.4268C6.55977 13.3831 7.71771 13.8612 9.07446 13.8612Z" fill="black"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Doc-Samples-Icons">
3
+ <path id="Vector" d="M10.5973 10.5937C11.0348 10.1562 11.2536 9.62498 11.2536 8.99998C11.2536 8.37498 11.0348 7.84373 10.5973 7.40623C10.1598 6.96873 9.62859 6.74998 9.00359 6.74998C8.37859 6.74998 7.84734 6.96873 7.40984 7.40623C6.97234 7.84373 6.75359 8.37498 6.75359 8.99998C6.75359 9.62498 6.97234 10.1562 7.40984 10.5937C7.84734 11.0312 8.37859 11.25 9.00359 11.25C9.62859 11.25 10.1598 11.0312 10.5973 10.5937ZM6.71684 11.2824C6.09134 10.6542 5.77859 9.89192 5.77859 8.99567C5.77859 8.09954 6.09277 7.33873 6.72115 6.71323C7.3494 6.08773 8.11165 5.77498 9.0079 5.77498C9.90402 5.77498 10.6648 6.08917 11.2903 6.71754C11.9158 7.34579 12.2286 8.10804 12.2286 9.00429C12.2286 9.90042 11.9144 10.6612 11.286 11.2867C10.6578 11.9122 9.89552 12.225 8.99927 12.225C8.10315 12.225 7.34234 11.9108 6.71684 11.2824ZM1.57859 9.48748C1.44021 9.48748 1.3244 9.44117 1.23115 9.34854C1.13777 9.25604 1.09109 9.14117 1.09109 9.00392C1.09109 8.86667 1.13777 8.75048 1.23115 8.65536C1.3244 8.56011 1.44021 8.51248 1.57859 8.51248H3.56609C3.70446 8.51248 3.82027 8.55879 3.91352 8.65142C4.0069 8.74392 4.05359 8.85879 4.05359 8.99604C4.05359 9.13329 4.0069 9.24948 3.91352 9.34461C3.82027 9.43986 3.70446 9.48748 3.56609 9.48748H1.57859ZM14.4411 9.48748C14.3027 9.48748 14.1869 9.44117 14.0936 9.34854C14.0003 9.25604 13.9536 9.14117 13.9536 9.00392C13.9536 8.86667 14.0003 8.75048 14.0936 8.65536C14.1869 8.56011 14.3027 8.51248 14.4411 8.51248H16.4286C16.567 8.51248 16.6828 8.55879 16.776 8.65142C16.8694 8.74392 16.9161 8.85879 16.9161 8.99604C16.9161 9.13329 16.8694 9.24948 16.776 9.34461C16.6828 9.43986 16.567 9.48748 16.4286 9.48748H14.4411ZM8.65896 3.90992C8.56371 3.81667 8.51609 3.70086 8.51609 3.56248V1.57498C8.51609 1.43661 8.5624 1.32079 8.65502 1.22754C8.74752 1.13417 8.8624 1.08748 8.99965 1.08748C9.1369 1.08748 9.25309 1.13417 9.34821 1.22754C9.44346 1.32079 9.49109 1.43661 9.49109 1.57498V3.56248C9.49109 3.70086 9.44477 3.81667 9.35215 3.90992C9.25965 4.00329 9.14477 4.04998 9.00752 4.04998C8.87027 4.04998 8.75409 4.00329 8.65896 3.90992ZM8.65896 16.7724C8.56371 16.6792 8.51609 16.5634 8.51609 16.425V14.4375C8.51609 14.2991 8.5624 14.1833 8.65502 14.09C8.74752 13.9967 8.8624 13.95 8.99965 13.95C9.1369 13.95 9.25309 13.9967 9.34821 14.09C9.44346 14.1833 9.49109 14.2991 9.49109 14.4375V16.425C9.49109 16.5634 9.44477 16.6792 9.35215 16.7724C9.25965 16.8658 9.14477 16.9125 9.00752 16.9125C8.87027 16.9125 8.75409 16.8658 8.65896 16.7724ZM4.8079 5.48661L3.73334 4.40042C3.63434 4.30904 3.58365 4.20042 3.58127 4.07454C3.5789 3.94854 3.62959 3.83361 3.73334 3.72973C3.83021 3.62598 3.94215 3.57411 4.06915 3.57411C4.19627 3.57411 4.3079 3.62598 4.40402 3.72973L5.49734 4.79717C5.60596 4.90029 5.66027 5.01654 5.66027 5.14592C5.66027 5.27542 5.60596 5.39173 5.49734 5.49486C5.40596 5.59798 5.29421 5.64954 5.16209 5.64954C5.02984 5.64954 4.91177 5.59523 4.8079 5.48661ZM13.6031 14.2702L12.5098 13.2028C12.4012 13.1032 12.3469 12.9894 12.3469 12.8614C12.3469 12.7332 12.4012 12.6149 12.5098 12.5062C12.6012 12.4024 12.713 12.3504 12.8451 12.3504C12.9773 12.3504 13.0954 12.4047 13.1993 12.5134L14.2738 13.5995C14.3728 13.6909 14.4235 13.7995 14.4259 13.9254C14.4283 14.0514 14.3805 14.1664 14.2826 14.2702C14.1729 14.374 14.0593 14.4259 13.942 14.4259C13.8247 14.4259 13.7118 14.374 13.6031 14.2702ZM12.5087 5.49373C12.4056 5.40236 12.354 5.29061 12.354 5.15848C12.354 5.02623 12.4083 4.90817 12.517 4.80429L13.6031 3.72973C13.707 3.63073 13.8188 3.58317 13.9384 3.58704C14.0581 3.59092 14.17 3.63879 14.2738 3.73067C14.3776 3.83392 14.4295 3.94423 14.4295 4.06161C14.4295 4.17886 14.3776 4.29179 14.2738 4.40042L13.2064 5.49373C13.1033 5.60236 12.987 5.65667 12.8576 5.65667C12.7281 5.65667 12.6118 5.60236 12.5087 5.49373ZM3.73334 14.2702C3.62959 14.1734 3.57771 14.0614 3.57771 13.9344C3.57771 13.8073 3.62959 13.6957 3.73334 13.5995L4.80077 12.5062C4.9004 12.4101 5.01421 12.362 5.14221 12.362C5.27034 12.362 5.38871 12.4101 5.49734 12.5062C5.59634 12.6101 5.64296 12.726 5.63721 12.854C5.63159 12.982 5.58259 13.0959 5.49021 13.1957L4.40402 14.2702C4.3079 14.374 4.19809 14.4271 4.07459 14.4296C3.95096 14.432 3.83721 14.3789 3.73334 14.2702Z" fill="#7D91AB"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="10.123" height="12" viewBox="0 0 10.123 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Group 3">
3
+ <path id="Subtract" d="M6 0C7.59747 0 9.04787 0.62563 10.123 1.64355C9.40759 2.93442 9 4.41957 9 6C9 7.58012 9.40785 9.06478 10.123 10.3555C9.04782 11.3737 7.59771 12 6 12C2.68629 12 0 9.31371 0 6C0 2.68629 2.68629 0 6 0Z" fill="black"/>
4
+ </g>
5
+ </svg>
@@ -140,6 +140,14 @@ igc-tab::part(tab-header) {
140
140
 
141
141
  &[data-igd-mode='dark'] {
142
142
  background: var(--igd-sample-bg-dark);
143
+
144
+ // The demo switches its own document to `color-scheme: dark`. When that
145
+ // differs from the iframe element's scheme (a light docs site), the browser
146
+ // paints an opaque default canvas behind the demo instead of letting this
147
+ // surface show through, so the iframe has to match the demo's scheme.
148
+ iframe {
149
+ color-scheme: dark;
150
+ }
143
151
  }
144
152
 
145
153
  iframe {
@@ -399,11 +407,28 @@ igc-tab::part(tab-header) {
399
407
 
400
408
  .igd-code-view__footer-actions {
401
409
  border-block-start: rem(1px) solid var(--ig-gray-300);
410
+ border-end-start-radius: 0.25rem;
411
+ border-end-end-radius: 0.25rem;
412
+ min-height: rem(56px);
413
+ padding: rem(8px) rem(24px);
414
+ gap: rem(8px);
415
+ background: light-dark(#fff, var(--ig-surface-500));
402
416
  }
403
417
 
404
- // The in-sample theme picker is appended after the edit controls.
418
+ // The footer picker is intentionally borderless: the footer itself provides
419
+ // the visual container while the select continues to own its menu and state.
405
420
  .igd-code-view__footer-actions .igd-sample-theming {
406
421
  margin-inline-start: 0;
422
+
423
+ .igd-theming__select {
424
+ --ig-input-group-border-color: transparent;
425
+ --ig-input-group-hover-border-color: transparent;
426
+ }
427
+
428
+ .igd-theming__select::part(input) {
429
+ border-color: transparent;
430
+ box-shadow: none;
431
+ }
407
432
  }
408
433
 
409
434
  .igd-code-view__header-actions,
@@ -416,6 +441,27 @@ igc-tab::part(tab-header) {
416
441
  gap: rem(16px);
417
442
  }
418
443
 
444
+ .igd-code-view__footer-actions {
445
+ padding: rem(8px) rem(24px);
446
+ gap: rem(8px);
447
+
448
+ .igd-code-view__footer-edit-actions {
449
+ display: flex;
450
+ flex: 1 0 0;
451
+ align-items: center;
452
+ justify-content: flex-end;
453
+ min-width: 0;
454
+ padding-inline-start: rem(16px);
455
+ gap: rem(8px);
456
+ }
457
+
458
+ .igd-edit-in-btn {
459
+ --size: #{rem(24px)};
460
+ --ig-icon-size: #{rem(18px)};
461
+ --border-radius: #{rem(18px)};
462
+ }
463
+ }
464
+
419
465
  .igd-code-view__header-actions {
420
466
  height: var(--sample-container-header-height);
421
467
  border-block-start: rem(1px) solid var(--ig-gray-300);
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Icon">
3
+ <path id="Vector" d="M3.75654 15.5834C3.3814 15.5834 3.06432 15.4538 2.80529 15.1948C2.54626 14.9358 2.41675 14.6187 2.41675 14.2436V3.75648C2.41675 3.38134 2.54626 3.06426 2.80529 2.80523C3.06432 2.5462 3.3814 2.41669 3.75654 2.41669H8.13779C8.29154 2.41669 8.42029 2.46814 8.52404 2.57106C8.62765 2.67384 8.67946 2.80148 8.67946 2.95398C8.67946 3.10648 8.62765 3.23558 8.52404 3.34127C8.42029 3.4471 8.29154 3.50002 8.13779 3.50002H3.75654C3.69237 3.50002 3.63362 3.52676 3.58029 3.58023C3.52682 3.63356 3.50008 3.69231 3.50008 3.75648V14.2436C3.50008 14.3077 3.52682 14.3665 3.58029 14.4198C3.63362 14.4733 3.69237 14.5 3.75654 14.5H14.2436C14.3078 14.5 14.3665 14.4733 14.4199 14.4198C14.4733 14.3665 14.5001 14.3077 14.5001 14.2436V9.86231C14.5001 9.70856 14.5515 9.57981 14.6542 9.47606C14.7572 9.37245 14.8849 9.32065 15.0374 9.32065C15.1899 9.32065 15.319 9.37245 15.4247 9.47606C15.5305 9.57981 15.5834 9.70856 15.5834 9.86231V14.2436C15.5834 14.6187 15.4539 14.9358 15.1949 15.1948C14.9358 15.4538 14.6188 15.5834 14.2436 15.5834H3.75654ZM14.5001 4.27398L7.45529 11.319C7.33987 11.4343 7.21564 11.4898 7.08258 11.4856C6.94966 11.4813 6.82279 11.4188 6.70196 11.2981C6.58126 11.1773 6.52091 11.0483 6.52091 10.9111C6.52091 10.7738 6.58126 10.6448 6.70196 10.524L13.7261 3.50002H11.5417C11.388 3.50002 11.2593 3.44863 11.1557 3.34585C11.052 3.24294 11.0001 3.11523 11.0001 2.96273C11.0001 2.81023 11.052 2.68113 11.1557 2.57544C11.2593 2.4696 11.388 2.41669 11.5417 2.41669H14.9134C15.1047 2.41669 15.2641 2.48058 15.3917 2.60835C15.5195 2.73599 15.5834 2.89544 15.5834 3.08669V6.45835C15.5834 6.6121 15.532 6.74078 15.429 6.8444C15.3263 6.94815 15.1986 7.00002 15.0461 7.00002C14.8936 7.00002 14.7645 6.94815 14.6588 6.8444C14.553 6.74078 14.5001 6.6121 14.5001 6.45835V4.27398Z" fill="#00142B"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Icon">
3
+ <path id="Vector" d="M8.09783 10.6365H2.72633L12.5461 2.0504e-05L9.90233 7.36352H15.2738L5.45408 18L8.09708 10.6365H8.09783Z" fill="#00142B"/>
4
+ </g>
5
+ </svg>
@@ -17,15 +17,14 @@ import {
17
17
  defineComponents,
18
18
  IgcTabsComponent,
19
19
  IgcTabComponent,
20
- IgcButtonComponent,
21
20
  IgcIconButtonComponent,
22
21
  IgcIconComponent,
23
22
  IgcCircularProgressComponent,
23
+ registerIconFromText,
24
24
  } from 'igniteui-webcomponents';
25
25
  defineComponents(
26
26
  IgcTabsComponent,
27
27
  IgcTabComponent,
28
- IgcButtonComponent,
29
28
  IgcIconButtonComponent,
30
29
  IgcIconComponent,
31
30
  IgcCircularProgressComponent,
@@ -33,7 +32,12 @@ defineComponents(
33
32
 
34
33
  import './icon-registry';
35
34
  import type { Highlighter } from 'shiki';
36
- import stackblitzSvg from '../assets/logos/stackblitz.svg?raw';
35
+ import footerStackblitzIcon from '../components/mdx/Sample/assets/stackblitz.svg?raw';
36
+ import footerOpenExternalIcon from '../components/mdx/Sample/assets/open-external.svg?raw';
37
+
38
+ const FOOTER_ICON_COLLECTION = 'sample-footer';
39
+ registerIconFromText('stackblitz', footerStackblitzIcon, FOOTER_ICON_COLLECTION);
40
+ registerIconFromText('open-external', footerOpenExternalIcon, FOOTER_ICON_COLLECTION);
37
41
 
38
42
  // ─── Constants ────────────────────────────────────────────────────────────────
39
43
 
@@ -256,18 +260,22 @@ function addFooter(
256
260
  const footer = document.createElement('div');
257
261
  footer.className = 'igd-code-view__footer-actions';
258
262
 
263
+ const actions = document.createElement('div');
264
+ actions.className = 'igd-code-view__footer-edit-actions';
265
+
259
266
  // Move the server-rendered theme picker (if any) into the existing footer,
260
267
  // after the edit controls so it is the rightmost footer item.
261
268
  const themingBar = widget.querySelector<HTMLElement>('.igd-sample-theming');
262
269
 
263
270
  if ((!explicitEditor || explicitEditor === 'stackblitz') && onStackblitz) {
264
- const btn = document.createElement('igc-button') as HTMLElement;
265
- btn.setAttribute('variant', 'outlined');
271
+ const btn = document.createElement('igc-icon-button') as HTMLElement;
272
+ btn.setAttribute('name', 'stackblitz');
273
+ btn.setAttribute('collection', FOOTER_ICON_COLLECTION);
274
+ btn.setAttribute('variant', 'flat');
266
275
  btn.setAttribute('aria-label', 'Edit in StackBlitz');
267
276
  btn.className = 'stackblitz-btn igd-edit-in-btn';
268
- btn.innerHTML = stackblitzSvg;
269
277
  btn.addEventListener('click', onStackblitz);
270
- footer.appendChild(btn);
278
+ actions.appendChild(btn);
271
279
  }
272
280
 
273
281
  // CodeSandbox hidden, re-enable when https://github.com/codesandbox/codesandbox-client/issues/8884 is fixed.
@@ -283,15 +291,10 @@ function addFooter(
283
291
  // footer.appendChild(btn);
284
292
  // }
285
293
 
286
- if (themingBar) {
287
- themingBar.hidden = false;
288
- footer.appendChild(themingBar);
289
- }
290
-
291
294
  const fsBtn = document.createElement('igc-icon-button') as HTMLElement;
292
- fsBtn.setAttribute('name', 'open-link-blank');
293
- fsBtn.setAttribute('collection', 'docs');
294
- fsBtn.setAttribute('variant', 'outlined');
295
+ fsBtn.setAttribute('name', 'open-external');
296
+ fsBtn.setAttribute('collection', FOOTER_ICON_COLLECTION);
297
+ fsBtn.setAttribute('variant', 'flat');
295
298
  fsBtn.setAttribute('aria-label', 'Open in full screen');
296
299
  fsBtn.className = 'igd-full-screen-btn igd-edit-in-btn';
297
300
  if (iframeSrc) {
@@ -299,7 +302,13 @@ function addFooter(
299
302
  fsBtn.setAttribute('href', fullscreenSrc);
300
303
  fsBtn.setAttribute('target', '_blank');
301
304
  }
302
- footer.appendChild(fsBtn);
305
+ actions.appendChild(fsBtn);
306
+ footer.appendChild(actions);
307
+
308
+ if (themingBar) {
309
+ themingBar.hidden = false;
310
+ footer.appendChild(themingBar);
311
+ }
303
312
 
304
313
  widget.appendChild(footer);
305
314
  }