igniteui-astro-components 1.6.0 → 1.8.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.
Files changed (64) hide show
  1. package/README.md +322 -158
  2. package/llms-full.txt +3207 -0
  3. package/llms.txt +103 -0
  4. package/package.json +17 -5
  5. package/src/assets/icons/figma-logo.svg +10 -0
  6. package/src/code-theme/README.md +72 -0
  7. package/src/code-theme/index.ts +57 -0
  8. package/src/components/CopyCode/CopyCode.astro +6 -1
  9. package/src/components/CopyCode/README.md +38 -0
  10. package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +28 -30
  11. package/src/components/DocsSidebar/DocsSidebar.astro +14 -2
  12. package/src/components/DocsSidebar/README.md +58 -30
  13. package/src/components/DocsSidebar/SidebarLabel.astro +34 -36
  14. package/src/components/DocsSidebar/sidebar-filter.ts +53 -5
  15. package/src/components/DocsSidebar/toTreeNodes.ts +21 -5
  16. package/src/components/DocsSubHeader/DocsSubHeader.astro +22 -9
  17. package/src/components/DocsSubHeader/README.md +37 -31
  18. package/src/components/DocsToc/DocsToc.astro +12 -14
  19. package/src/components/DocsToc/README.md +7 -7
  20. package/src/components/DocsTree/DocsTree.astro +9 -11
  21. package/src/components/DocsTree/DocsTreeItem.astro +36 -40
  22. package/src/components/DocsTree/README.md +12 -9
  23. package/src/components/GlobalFooter/GlobalFooter.astro +6 -8
  24. package/src/components/GlobalNavBar/GlobalNavBar.astro +2 -4
  25. package/src/components/LicenseIndicator/LicenseIndicator.astro +6 -8
  26. package/src/components/MobileTocToggle/MobileTocToggle.astro +31 -33
  27. package/src/components/MobileTocToggle/README.md +45 -0
  28. package/src/components/Search/README.md +10 -10
  29. package/src/components/Search/Search.astro +12 -6
  30. package/src/components/SearchAdvanced/README.md +15 -8
  31. package/src/components/SearchAdvanced/SearchAdvanced.astro +17 -15
  32. package/src/components/ThemingWidget/ThemingWidget.astro +62 -60
  33. package/src/components/mdx/Anatomy/Anatomy.scss +1 -1
  34. package/src/components/mdx/Anatomy/README.md +40 -0
  35. package/src/components/mdx/ApiLink/ApiLink.astro +7 -9
  36. package/src/components/mdx/ApiLink/README.md +1 -0
  37. package/src/components/mdx/ApiRef/ApiRef.astro +7 -9
  38. package/src/components/mdx/ApiRef/README.md +1 -1
  39. package/src/components/mdx/Badge/Badge.astro +3 -1
  40. package/src/components/mdx/Badge/README.md +1 -3
  41. package/src/components/mdx/DocsAside/DocsAside.astro +3 -5
  42. package/src/components/mdx/DocsAside/README.md +47 -29
  43. package/src/components/mdx/Faq/Faq.astro +11 -13
  44. package/src/components/mdx/Faq/FaqItem.astro +20 -26
  45. package/src/components/mdx/FigmaUiKits/FigmaUiKits.astro +126 -0
  46. package/src/components/mdx/FigmaUiKits/FigmaUiKits.scss +165 -0
  47. package/src/components/mdx/FigmaUiKits/README.md +115 -0
  48. package/src/components/mdx/FigmaUiKits/kits.ts +26 -0
  49. package/src/components/mdx/PlatformBlock/README.md +5 -18
  50. package/src/components/mdx/Sample/README.md +67 -50
  51. package/src/components/mdx/Sample/Sample.astro +108 -33
  52. package/src/components/mdx/Sample/Sample.scss +38 -17
  53. package/src/integration.ts +6 -21
  54. package/src/layouts/DocsLayout/README.md +63 -28
  55. package/src/lib/warn-once.ts +8 -0
  56. package/src/scripts/copy-status.ts +35 -0
  57. package/src/scripts/icon-manifest.ts +1 -0
  58. package/src/scripts/sample-widget.ts +109 -42
  59. package/src/styles/global/_code-blocks.scss +58 -36
  60. package/src/styles/global/_copy-button.scss +18 -25
  61. package/src/styles/global/_markdown.scss +15 -8
  62. package/src/styles/global/_variables.scss +57 -0
  63. package/src/styles/theme.scss +4 -1
  64. package/src/virtual-modules.d.ts +2 -2
@@ -20,6 +20,7 @@ import {
20
20
  IgcIconButtonComponent,
21
21
  IgcIconComponent,
22
22
  IgcCircularProgressComponent,
23
+ IgcTooltipComponent,
23
24
  registerIconFromText,
24
25
  } from 'igniteui-webcomponents';
25
26
  defineComponents(
@@ -28,10 +29,12 @@ defineComponents(
28
29
  IgcIconButtonComponent,
29
30
  IgcIconComponent,
30
31
  IgcCircularProgressComponent,
32
+ IgcTooltipComponent,
31
33
  );
32
34
 
33
35
  import './icon-registry';
34
36
  import type { BundledLanguage, Highlighter } from 'shiki';
37
+ import { announceCopyStatus, clearCopyStatus } from './copy-status';
35
38
  import { ULTIMATE_UI_PLATFORMS } from '../lib/ultimate-ui-platforms';
36
39
  import footerStackblitzIcon from '../components/mdx/Sample/assets/stackblitz.svg?raw';
37
40
  import footerOpenExternalIcon from '../components/mdx/Sample/assets/open-external.svg?raw';
@@ -71,9 +74,6 @@ const SANDBOX_UNSUPPORTED_PLATFORMS = new Set(['blazor', 'winui', 'uno']);
71
74
 
72
75
  const DV_PATHS = ['gauges/', 'maps/', 'excel/', 'charts/'];
73
76
  const ASSETS_RE = /([.]{0,2}\/)*assets\//g;
74
- const DEFAULT_CODE_THEME = 'dark-plus';
75
-
76
- declare const __IGD_SAMPLE_CODE_THEME__: string | undefined;
77
77
 
78
78
  // ─── Types ────────────────────────────────────────────────────────────────────
79
79
 
@@ -187,17 +187,12 @@ const HIGHLIGHT_LANGS: ReadonlySet<string> = new Set([...SHIKI_LANGS, ...SHIKI_L
187
187
 
188
188
  let _highlighterPromise: Promise<Highlighter> | null = null;
189
189
 
190
- function getCodeTheme(): string {
191
- return typeof __IGD_SAMPLE_CODE_THEME__ === 'string' && __IGD_SAMPLE_CODE_THEME__.trim()
192
- ? __IGD_SAMPLE_CODE_THEME__
193
- : DEFAULT_CODE_THEME;
194
- }
195
-
190
+ // Shiki and the brand theme load lazily, only once a code tab exists.
196
191
  function getHighlighter(): Promise<Highlighter> {
197
192
  if (!_highlighterPromise) {
198
- _highlighterPromise = import('shiki')
199
- .then(({ createHighlighter }) =>
200
- createHighlighter({ themes: [getCodeTheme()], langs: [...SHIKI_LANGS] }),
193
+ _highlighterPromise = Promise.all([import('shiki'), import('../code-theme')])
194
+ .then(([{ createHighlighter }, { igCodeTheme }]) =>
195
+ createHighlighter({ themes: [igCodeTheme], langs: [...SHIKI_LANGS] }),
201
196
  )
202
197
  .catch((err) => {
203
198
  _highlighterPromise = null;
@@ -207,6 +202,7 @@ function getHighlighter(): Promise<Highlighter> {
207
202
  return _highlighterPromise;
208
203
  }
209
204
 
205
+ /** Highlight a code tab with the brand theme the page's fenced blocks use. */
210
206
  function highlightCode(codeEl: HTMLElement, lang: string): void {
211
207
  const safeLang = HIGHLIGHT_LANGS.has(lang) ? lang : 'text';
212
208
  getHighlighter()
@@ -217,13 +213,17 @@ function highlightCode(codeEl: HTMLElement, lang: string): void {
217
213
  const tmp = document.createElement('div');
218
214
  tmp.innerHTML = h.codeToHtml(codeEl.textContent ?? '', {
219
215
  lang: safeLang,
220
- theme: getCodeTheme(),
216
+ theme: h.getLoadedThemes()[0],
221
217
  });
222
218
  const shikiPre = tmp.firstElementChild as HTMLElement | null;
223
219
  const shikiCode = shikiPre?.querySelector('code');
224
220
  if (!shikiPre || !shikiCode) return;
225
221
  const parentPre = codeEl.parentElement;
226
- if (parentPre) parentPre.style.cssText = shikiPre.style.cssText;
222
+ if (parentPre) {
223
+ // Shiki's inline background and text colour.
224
+ parentPre.style.cssText = shikiPre.style.cssText;
225
+ parentPre.classList.add('igd-code');
226
+ }
227
227
  codeEl.innerHTML = shikiCode.innerHTML;
228
228
  })
229
229
  .catch(console.warn);
@@ -233,6 +233,70 @@ function normalizeCodeLang(lang: string | undefined): string {
233
233
  return LANG_MAP[lang ?? ''] ?? lang ?? 'text';
234
234
  }
235
235
 
236
+ // ─── Action Tooltips ──────────────────────────────────────────────────────────
237
+
238
+ const COPY_CODE_LABEL = 'Copy code';
239
+ const CODE_COPIED_LABEL = 'Code copied';
240
+
241
+ /**
242
+ * Give an icon-only action button a hover/focus tooltip that names its action.
243
+ * The text is the button's `aria-label`, so the visible and accessible names
244
+ * stay the same. Call after the button is in the DOM: the tooltip is inserted
245
+ * as its next sibling.
246
+ */
247
+ function addActionTooltip(btn: HTMLElement): IgcTooltipComponent {
248
+ const tooltip = document.createElement('igc-tooltip') as IgcTooltipComponent;
249
+ tooltip.className = 'igd-sample-action-tooltip';
250
+ tooltip.withArrow = true;
251
+ tooltip.message = btn.getAttribute('aria-label') ?? '';
252
+ tooltip.anchor = btn;
253
+ btn.after(tooltip);
254
+ return tooltip;
255
+ }
256
+
257
+ /**
258
+ * Wire a code-tab copy button: copy on click, then switch its icon,
259
+ * `aria-label` and tooltip to the "copied" state for a moment.
260
+ */
261
+ function wireCopyButton(btn: HTMLElement, getText: () => string): void {
262
+ const icon = btn.querySelector<HTMLElement>('igc-icon');
263
+ const tooltip = addActionTooltip(btn);
264
+ // `click` is a default hide trigger; drop it so the tooltip stays open to
265
+ // confirm the copy.
266
+ tooltip.hideTriggers = 'pointerleave,focusout';
267
+
268
+ const setLabel = (label: string) => {
269
+ btn.setAttribute('aria-label', label);
270
+ tooltip.message = label;
271
+ };
272
+
273
+ // Element that holds the copy-status live region.
274
+ const host = btn.parentElement ?? btn;
275
+
276
+ btn.addEventListener('click', () => {
277
+ navigator.clipboard
278
+ .writeText(getText())
279
+ .then(() => {
280
+ icon?.setAttribute('name', 'check');
281
+ setLabel(CODE_COPIED_LABEL);
282
+ announceCopyStatus(host, 'Code copied to clipboard');
283
+ // A click inside the show delay cancels the pending show; open it now.
284
+ void tooltip.show();
285
+ })
286
+ .catch(() => {
287
+ setLabel('Copy failed');
288
+ announceCopyStatus(host, 'Copy failed');
289
+ })
290
+ .then(() =>
291
+ setTimeout(() => {
292
+ icon?.setAttribute('name', 'copy');
293
+ setLabel(COPY_CODE_LABEL);
294
+ clearCopyStatus(host);
295
+ }, 1500),
296
+ );
297
+ });
298
+ }
299
+
236
300
  // ─── Code Tab Rendering ───────────────────────────────────────────────────────
237
301
 
238
302
  function addCodeTab(igcTabs: HTMLElement, file: SampleFile, useFileName = false): void {
@@ -245,6 +309,7 @@ function addCodeTab(igcTabs: HTMLElement, file: SampleFile, useFileName = false)
245
309
  wrapper.className = 'code-wrapper';
246
310
 
247
311
  const pre = document.createElement('pre');
312
+ pre.className = 'igd-code';
248
313
  const code = document.createElement('code');
249
314
  code.className = `language-${lang}`;
250
315
  code.textContent = file.content;
@@ -254,7 +319,7 @@ function addCodeTab(igcTabs: HTMLElement, file: SampleFile, useFileName = false)
254
319
  // affordances look identical.
255
320
  const copyBtn = document.createElement('igc-icon-button') as HTMLElement;
256
321
  copyBtn.setAttribute('variant', 'flat');
257
- copyBtn.setAttribute('aria-label', 'Copy code');
322
+ copyBtn.setAttribute('aria-label', COPY_CODE_LABEL);
258
323
  copyBtn.className = 'cv-hljs-code-copy';
259
324
 
260
325
  const copyIcon = document.createElement('igc-icon');
@@ -262,19 +327,9 @@ function addCodeTab(igcTabs: HTMLElement, file: SampleFile, useFileName = false)
262
327
  copyIcon.setAttribute('collection', 'docs');
263
328
  copyBtn.appendChild(copyIcon);
264
329
 
265
- copyBtn.addEventListener('click', () => {
266
- navigator.clipboard.writeText(file.content).then(() => {
267
- copyIcon.setAttribute('name', 'check');
268
- copyBtn.setAttribute('aria-label', 'Code copied');
269
- setTimeout(() => {
270
- copyIcon.setAttribute('name', 'copy');
271
- copyBtn.setAttribute('aria-label', 'Copy code');
272
- }, 1500);
273
- });
274
- });
275
-
276
330
  wrapper.appendChild(pre);
277
331
  wrapper.appendChild(copyBtn);
332
+ wireCopyButton(copyBtn, () => file.content);
278
333
  tab.appendChild(wrapper);
279
334
  igcTabs.appendChild(tab);
280
335
 
@@ -314,6 +369,7 @@ function addFooter(
314
369
  btn.className = 'stackblitz-btn igd-edit-in-btn';
315
370
  btn.addEventListener('click', onStackblitz);
316
371
  actions.appendChild(btn);
372
+ addActionTooltip(btn);
317
373
  }
318
374
 
319
375
  // CodeSandbox hidden, re-enable when https://github.com/codesandbox/codesandbox-client/issues/8884 is fixed.
@@ -341,6 +397,7 @@ function addFooter(
341
397
  fsBtn.setAttribute('target', '_blank');
342
398
  }
343
399
  actions.appendChild(fsBtn);
400
+ addActionTooltip(fsBtn);
344
401
  }
345
402
  if (actions.childElementCount) footer.appendChild(actions);
346
403
 
@@ -349,7 +406,7 @@ function addFooter(
349
406
  footer.appendChild(themingBar);
350
407
  }
351
408
 
352
- // Nothing to show (e.g. a `hideCode` sample without a theme picker): no footer.
409
+ // Nothing to show (e.g. a `chrome="demo"` sample without a theme picker): no footer.
353
410
  if (footer.childElementCount) widget.appendChild(footer);
354
411
  }
355
412
 
@@ -657,6 +714,14 @@ const FIT_CONTENT_ENABLE_MESSAGE = 'igd-sample-fit';
657
714
 
658
715
  let _fitContentMessageBound = false;
659
716
 
717
+ /**
718
+ * The document of each fit-content iframe that has reported its own size.
719
+ * Keyed by document, not set on the iframe, so that navigating the iframe to
720
+ * a page that does not report resumes direct measurement. A report that
721
+ * arrives before the new page's load event is already from the new document.
722
+ */
723
+ const _reportingDocuments = new WeakMap<HTMLIFrameElement, Document | null>();
724
+
660
725
  /**
661
726
  * Apply a measured content size to a fit-content iframe. The size goes on the
662
727
  * iframe itself; the container has `height: auto` in fit-content mode, so it
@@ -728,6 +793,9 @@ function bindFitContentMessages(): void {
728
793
  .querySelectorAll<HTMLIFrameElement>('.igd-sample-container[data-fit-content] iframe')
729
794
  .forEach((iframe) => {
730
795
  if (iframe.contentWindow !== e.source) return;
796
+ // A demo that reports its own size knows it best. Direct measurement
797
+ // of this same-origin document stops from here on (see wireFitContent).
798
+ _reportingDocuments.set(iframe, iframe.contentDocument);
731
799
  // Width only matters when the host aligns the iframe
732
800
  // horizontally (position → data-justify); otherwise the iframe
733
801
  // stays full-width and a reported width is ignored. Resizable
@@ -749,6 +817,12 @@ function bindFitContentMessages(): void {
749
817
  * in sync with a ResizeObserver on their <body>. Cross-origin demos can't be
750
818
  * read, so they must post their height (see FIT_CONTENT_MESSAGE).
751
819
  *
820
+ * A same-origin demo that also posts its height is sized by its messages
821
+ * alone. Its page may fill the iframe (`html, body { height: 100% }`), and
822
+ * then the direct measurement only echoes the iframe height back. Both paths
823
+ * writing the height race: a stale echo can land after the demo's last
824
+ * report and leave the iframe cut off.
825
+ *
752
826
  * The `height` prop is only the placeholder/fallback in fit-content mode —
753
827
  * once a size is measured/reported, the content dictates it. Measurement uses
754
828
  * the html/body offset heights (not the document scrollHeight, which is
@@ -767,6 +841,7 @@ function wireFitContent(iframe: HTMLIFrameElement): void {
767
841
  const doc = iframe.contentDocument;
768
842
  const body = doc?.body;
769
843
  if (!body) return; // cross-origin — rely on postMessage instead
844
+ if (_reportingDocuments.get(iframe) === doc) return; // the demo reports its own size
770
845
  setFitSize(iframe, {
771
846
  height: Math.max(doc!.documentElement.offsetHeight, body.offsetHeight, body.scrollHeight),
772
847
  width: measureContentWidth(iframe, body),
@@ -818,7 +893,7 @@ function wireFitContent(iframe: HTMLIFrameElement): void {
818
893
  }, 3000);
819
894
  };
820
895
 
821
- // iframeOnly renders `src` directly, so the iframe may already be loaded —
896
+ // chrome="bare" renders `src` directly, so the iframe may already be loaded —
822
897
  // and a cross-origin iframe gives no way to detect that (contentDocument is
823
898
  // null whether it's loaded or not). Run the handler once at wire time as
824
899
  // well: on a not-yet-loaded iframe the enable message is simply lost and
@@ -919,7 +994,7 @@ function initResizableSamples(): void {
919
994
  * `.ig-code-view` elements managed by code-view.js.
920
995
  */
921
996
  export function initSampleWidgets(): void {
922
- // Wire fit-content iframes (both full widgets and iframeOnly samples) up front
997
+ // Wire fit-content iframes (widgets and chrome="bare" samples alike) up front
923
998
  // so they start measuring as soon as their content loads.
924
999
  initFitContentIframes();
925
1000
 
@@ -969,8 +1044,8 @@ export function initSampleWidgets(): void {
969
1044
  const demosBaseUrl = widget.dataset.demosBaseUrl || '';
970
1045
  const githubSrc = widget.dataset.githubSrc || '';
971
1046
  const platform = normalizePlatform(widget.dataset.platform || 'angular');
972
- // `hideCode` samples render no tabs: only the demo and the theme picker.
973
- const hideCode = widget.dataset.hideCode === 'true';
1047
+ // `chrome="demo"` samples render no tabs: only the demo and the theme picker.
1048
+ const isDemo = widget.dataset.chrome === 'demo';
974
1049
 
975
1050
  if (!iframeSrc) return;
976
1051
 
@@ -978,7 +1053,7 @@ export function initSampleWidgets(): void {
978
1053
  const samplePane = widget.querySelector<HTMLElement>('.igd-sample-container');
979
1054
  const iframe = widget.querySelector<HTMLIFrameElement>('iframe');
980
1055
 
981
- if (!igcTabs && !hideCode) return;
1056
+ if (!igcTabs && !isDemo) return;
982
1057
 
983
1058
  const exampleTabId = `${widget.id}-example`;
984
1059
 
@@ -1046,19 +1121,11 @@ export function initSampleWidgets(): void {
1046
1121
  // Wire copy buttons for pre-rendered code tabs (e.g. MockSample in playground).
1047
1122
  widget.querySelectorAll<HTMLElement>('.code-wrapper').forEach((pre) => {
1048
1123
  const btn = pre.querySelector<HTMLElement>('.cv-hljs-code-copy');
1049
- const icon = btn?.querySelector<HTMLElement>('igc-icon');
1050
1124
  const code = pre.querySelector<HTMLElement>('code');
1051
1125
  if (!btn || !code) return;
1052
1126
  const codeLang = (code.className.match(/language-(\S+)/) ?? [])[1] ?? 'text';
1053
1127
  highlightCode(code, normalizeCodeLang(codeLang));
1054
- btn.addEventListener('click', () => {
1055
- navigator.clipboard.writeText(code.textContent ?? '').then(() => {
1056
- icon?.setAttribute('name', 'check');
1057
- setTimeout(() => {
1058
- icon?.setAttribute('name', 'copy');
1059
- }, 1500);
1060
- });
1061
- });
1128
+ wireCopyButton(btn, () => code.textContent ?? '');
1062
1129
  });
1063
1130
 
1064
1131
  // Enqueue iframe loading.
@@ -1082,7 +1149,7 @@ export function initSampleWidgets(): void {
1082
1149
 
1083
1150
  // No code to fetch and nothing to live-edit or open in full screen: the
1084
1151
  // footer carries only the theme picker, right away.
1085
- if (hideCode || !igcTabs) {
1152
+ if (isDemo || !igcTabs) {
1086
1153
  addFooter(widget, iframeSrc, null, null, null, false);
1087
1154
  return;
1088
1155
  }
@@ -1,55 +1,77 @@
1
- @use 'igniteui-theming' as *;
2
1
  @use 'copy-button' as *;
3
2
 
4
3
  /* ============================================================
5
- Code Blocks (Shiki dual-theme)
6
- Shiki emits CSS variables per span:
7
- --shiki-light / --shiki-light-bg (default, inline style)
8
- --shiki-dark / --shiki-dark-bg (need CSS to activate)
4
+ Code snippets: fenced blocks and <Code> (`pre.astro-code`), direct
5
+ `codeToHtml()` output (`pre.shiki`) and Sample code tabs (`pre.igd-code`).
6
+ Shiki writes the background, default text and token colours inline
7
+ (src/code-theme); these rules only shape the surface.
8
+ Surface tokens (`--igd-code-*`) live in _variables.scss.
9
9
  ============================================================ */
10
10
 
11
- .shiki {
12
- border: 1px solid var(--ig-gray-200);
13
- margin-bottom: rem(26px);
14
- }
15
-
16
- pre.shiki {
17
- overflow-x: auto;
11
+ pre.astro-code,
12
+ pre.shiki,
13
+ pre.igd-code {
14
+ // Snippets are always dark: dark scrollbars and form-control colours.
15
+ color-scheme: dark;
16
+ border: var(--igd-code-border);
17
+ border-radius: var(--igd-code-radius);
18
+ padding: var(--igd-code-padding);
19
+ margin-block: 0 var(--igd-code-margin-bottom);
20
+ font-family: var(--igd-code-font-family);
21
+ font-size: var(--igd-code-font-size);
22
+ line-height: var(--igd-code-line-height);
23
+ font-weight: 400;
24
+ tab-size: 2;
18
25
  max-width: 100%;
19
- word-wrap: break-word;
20
- white-space: pre-wrap;
21
- border-radius: var(--igd-border-radius);
22
- padding: rem(32px);
23
- }
24
-
25
- pre.shiki code {
26
+ overflow-x: auto;
26
27
  white-space: pre-wrap;
28
+ overflow-wrap: break-word;
27
29
  word-break: break-word;
28
- }
29
30
 
30
- /* ── Always use the dark theme ──────────────────────────────
31
- Single dark theme — Shiki outputs colors directly, no CSS
32
- variable switching required. */
33
- pre.shiki {
34
- background-color: var(--shiki-color-background) !important;
31
+ code {
32
+ display: block;
33
+ font: inherit;
34
+ white-space: inherit;
35
+ overflow-wrap: inherit;
36
+ word-break: inherit;
37
+ background: none;
38
+ border: 0;
39
+ padding: 0;
40
+ margin: 0;
41
+ }
35
42
  }
36
43
 
44
+ /* ── Copy button (added by CopyCode.astro around every pre.astro-code / pre.shiki) ── */
45
+
37
46
  .copy-code-wrapper {
38
47
  position: relative;
39
48
  z-index: 0;
40
- }
49
+ margin-block-end: var(--igd-code-margin-bottom);
50
+
51
+ > pre {
52
+ margin-block-end: 0;
53
+ }
54
+
55
+ > .copy-btn {
56
+ position: absolute;
57
+ inset-block-start: var(--igd-code-copy-inset);
58
+ inset-inline-end: var(--igd-code-copy-inset);
59
+ z-index: 1;
60
+ opacity: 0;
61
+ transition: opacity 0.15s ease;
41
62
 
42
- .copy-code-wrapper > .copy-btn {
43
- position: absolute;
44
- inset-block-start: rem(8px);
45
- inset-inline-end: rem(8px);
46
- opacity: 0;
47
- z-index: 1;
63
+ @include copy-button-colors;
64
+ }
48
65
 
49
- @include copy-button-colors;
66
+ &:hover > .copy-btn,
67
+ &:focus-within > .copy-btn {
68
+ opacity: 1;
69
+ }
50
70
  }
51
71
 
52
- .copy-code-wrapper:hover > .copy-btn,
53
- .copy-code-wrapper:focus-within > .copy-btn {
54
- opacity: 1;
72
+ // Always shows the copy button on touch devices.
73
+ @media (hover: none) {
74
+ .copy-code-wrapper > .copy-btn {
75
+ opacity: 1;
76
+ }
55
77
  }
@@ -1,32 +1,25 @@
1
- /// Explicit palette for copy-code icon buttons (igc-icon-button).
2
- ///
3
- /// Code panes always render the dark Shiki theme, while the icon-button's
4
- /// default colors follow the site theme — in light mode that leaves the icon
5
- /// near-invisible on the dark background until a hover state recolors it.
6
- /// Pinning the full state palette keeps the button legible in both themes.
7
- /// The success palette kicks in while the icon shows the post-copy check.
1
+ /// Palette for the copy-code icon buttons (igc-icon-button) on top of a code
2
+ /// snippet; the page-level CopyCode button and the Sample code-tab button share it.
3
+ /// The success palette applies while the icon shows the post-copy check.
8
4
  @mixin copy-button-colors {
9
- --foreground: var(--ig-primary-600-contrast);
10
- --hover-foreground: var(--ig-primary-600-contrast);
11
- --focus-foreground: var(--ig-primary-600-contrast);
12
- --active-foreground: var(--ig-primary-600-contrast);
13
- --background: var(--ig-primary-500);
14
- --hover-background: var(--ig-primary-500);
15
- --focus-background: var(--ig-primary-500);
16
- --active-background: var(--ig-primary-500);
5
+ --foreground: var(--igd-code-copy-color);
6
+ --hover-foreground: var(--igd-code-copy-hover-color);
7
+ --focus-foreground: var(--igd-code-copy-hover-color);
8
+ --active-foreground: var(--igd-code-copy-hover-color);
9
+ --background: transparent;
10
+ --hover-background: var(--igd-code-copy-hover-bg);
11
+ --focus-background: var(--igd-code-copy-hover-bg);
12
+ --active-background: var(--igd-code-copy-hover-bg);
17
13
  --border-color: transparent;
18
14
  --border-color-hover: transparent;
19
- --border-color-focus: transparent;
15
+ // Keyboard focus ring.
16
+ --focus-border-color: var(--igd-code-copy-hover-color);
17
+ --focus-visible-border-color: var(--igd-code-copy-hover-color);
20
18
 
21
19
  &:has([name='check']) {
22
- --foreground: var(--ig-success-300-contrast);
23
- --hover-foreground: var(--ig-success-300-contrast);
24
- --focus-foreground: var(--ig-success-300-contrast);
25
- --active-foreground: var(--ig-success-300-contrast);
26
-
27
- --background: var(--ig-success-300);
28
- --hover-background: var(--ig-success-300);
29
- --focus-background: var(--ig-success-300);
30
- --active-background: var(--ig-success-300);
20
+ --foreground: var(--igd-code-copy-success-color);
21
+ --hover-foreground: var(--igd-code-copy-success-color);
22
+ --focus-foreground: var(--igd-code-copy-success-color);
23
+ --active-foreground: var(--igd-code-copy-success-color);
31
24
  }
32
25
  }
@@ -89,7 +89,7 @@
89
89
  padding: var(--igd-page-padding);
90
90
  min-width: 0;
91
91
 
92
- pre:not(.astro-code) {
92
+ pre:not(.astro-code, .shiki) {
93
93
  @include type-style('code', false) {
94
94
  margin-block: 0;
95
95
  }
@@ -97,15 +97,20 @@
97
97
  margin-block-end: rem(26px);
98
98
  }
99
99
 
100
- pre,
101
100
  code {
102
101
  font-family: var(--font-mono) !important;
103
102
  margin-block-end: rem(26px);
104
103
  }
105
104
 
106
- pre.astro-code {
107
- padding: rem(24px);
108
- border-radius: rem(8px);
105
+ // Snippets read the `--igd-code-font-family` token so a consumer can retune
106
+ // them; `!important` is still needed to beat the theming typography.
107
+ pre {
108
+ font-family: var(--igd-code-font-family, var(--font-mono)) !important;
109
+ margin-block-end: rem(26px);
110
+ }
111
+
112
+ pre code {
113
+ font-family: inherit !important;
109
114
  }
110
115
 
111
116
  kbd {
@@ -163,7 +168,9 @@
163
168
  color: var(--ig-primary-500);
164
169
  }
165
170
 
166
- > .shiki {
171
+ > .astro-code,
172
+ > .shiki,
173
+ > .copy-code-wrapper {
167
174
  margin-top: rem(8px);
168
175
  }
169
176
 
@@ -236,12 +243,12 @@
236
243
 
237
244
  a {
238
245
  font-size: inherit;
239
- color: light-dark(var(--ig-primary-500), var(--ig-primary-200));
246
+ color: var(--igd-link-color);
240
247
  text-decoration: underline;
241
248
 
242
249
  &:hover,
243
250
  &:focus {
244
- color: light-dark(var(--ig-primary-600), var(--ig-primary-100));
251
+ color: var(--igd-link-hover-color);
245
252
  }
246
253
 
247
254
  &:focus,
@@ -1,5 +1,6 @@
1
1
  @use 'igniteui-theming/sass/typography' as *;
2
2
  @use 'palette' as *;
3
+ @use 'breakpoints' as *;
3
4
 
4
5
  /* ============================================================
5
6
  CSS Custom Properties
@@ -56,6 +57,10 @@
56
57
  --igd-padding-md: #{rem(24px)};
57
58
  --igd-padding-lg: #{rem(32px)};
58
59
 
60
+ // Links
61
+ --igd-link-color: light-dark(var(--ig-primary-600), var(--ig-primary-200));
62
+ --igd-link-hover-color: light-dark(var(--ig-primary-700), var(--ig-primary-100));
63
+
59
64
  --igd-updated-bg: light-dark(#eaf6fe, #0d1e38);
60
65
  --igd-updated-color: light-dark(#1151c1, #6b9fe8);
61
66
  --igd-updated-border: light-dark(#bae2f5, #1e3d6a);
@@ -146,4 +151,56 @@
146
151
 
147
152
  --igd-table-header-bg: var(--igd-layout-sections-bg);
148
153
  --igd-table-header-fg: light-dark(var(--ig-gray-900), var(--ig-gray-700));
154
+
155
+ // FIGMA UI KITS MDX
156
+ --igd-figma-kits-padding-block: #{rem(8px)};
157
+ --igd-figma-kits-padding-inline: var(--igd-padding-sm);
158
+ --igd-figma-kits-compact-padding-block: #{rem(12px)};
159
+ --igd-figma-kits-compact-padding-inline: #{rem(12px)};
160
+ --igd-figma-kits-gap: var(--igd-padding-md);
161
+ --igd-figma-kits-row-gap: #{rem(12px)};
162
+ --igd-figma-kits-item-gap: #{rem(8px)};
163
+ --igd-figma-kits-margin-bottom: #{rem(26px)};
164
+ --igd-figma-kits-radius: var(--igd-border-radius);
165
+ --igd-figma-kits-border-width: var(--igd-app-outline-size);
166
+ --igd-figma-kits-border-style: var(--igd-app-outline-style);
167
+ --igd-figma-kits-logo-size: #{rem(31px)};
168
+ --igd-figma-kits-target-size: #{rem(24px)};
169
+ --igd-figma-kits-underline-offset: #{rem(3px)};
170
+ --igd-figma-kits-focus-width: #{rem(2px)};
171
+ --igd-figma-kits-focus-offset: #{rem(2px)};
172
+ --igd-figma-kits-link-weight: 700;
173
+
174
+ --igd-figma-kits-bg: light-dark(var(--ig-gray-100), var(--ig-gray-50));
175
+ --igd-figma-kits-border-color: light-dark(var(--ig-gray-300), var(--ig-gray-200));
176
+ --igd-figma-kits-title-color: var(--ig-gray-600);
177
+ --igd-figma-kits-link-color: var(--igd-link-color);
178
+ --igd-figma-kits-link-hover-color: var(--igd-link-hover-color);
179
+ }
180
+
181
+ /* ============================================================
182
+ CODE SNIPPETS (fenced blocks, <Code>, Sample code tabs)
183
+ Background and text colours come from the Shiki theme (src/code-theme).
184
+ ============================================================ */
185
+ :root {
186
+ --igd-code-border: #{rem(1px)} solid #002b5c;
187
+ --igd-code-radius: var(--igd-border-radius);
188
+ --igd-code-padding: #{rem(36px)};
189
+ --igd-code-font-family: var(--font-mono, var(--igd-font-mono));
190
+ --igd-code-font-size: #{rem(14px)};
191
+ --igd-code-line-height: #{rem(24px)};
192
+ --igd-code-margin-bottom: #{rem(26px)};
193
+
194
+ // Copy button (igc-icon-button), revealed on hover / focus-within.
195
+ --igd-code-copy-color: #d2dbe8;
196
+ --igd-code-copy-hover-color: #0176ff;
197
+ --igd-code-copy-hover-bg: #002b5c;
198
+ --igd-code-copy-success-color: var(--ig-success-500);
199
+ --igd-code-copy-inset: #{rem(12px)};
200
+ }
201
+
202
+ @media (max-width: #{$bp-mobile-max}) {
203
+ :root {
204
+ --igd-code-padding: #{rem(20px)};
205
+ }
149
206
  }
@@ -84,7 +84,10 @@ body {
84
84
  ):not(:defined) {
85
85
  opacity: 0;
86
86
  }
87
- igc-dialog:not(:defined) {
87
+ // Dialogs and tooltips sit outside the layout flow once defined, so hide them
88
+ // entirely; otherwise a tooltip's text shows inline until it upgrades.
89
+ igc-dialog:not(:defined),
90
+ igc-tooltip:not(:defined) {
88
91
  display: none;
89
92
  }
90
93
 
@@ -26,7 +26,7 @@ declare module 'virtual:docs-template/site-meta' {
26
26
  href: string;
27
27
  platform?: string;
28
28
  }>;
29
- /** Extra <head> entries injected by siteMetaIntegration (platform CDN, highlight.js, etc.). */
29
+ /** Extra <head> entries injected by siteMetaIntegration (platform CDN, site-specific entries, etc.). */
30
30
  export const headEntries: Array<{
31
31
  tag: string;
32
32
  attrs?: Record<string, string | boolean | undefined>;
@@ -36,7 +36,7 @@ declare module 'virtual:docs-template/site-meta' {
36
36
  export const trailingSlash: 'always' | 'never' | 'ignore';
37
37
  /** Optional package switcher entries. */
38
38
  export const packages:
39
- Array<string | { label: string; value?: string; href?: string }> | undefined;
39
+ Array<string | { label: string; value?: string; href?: string; base?: string }> | undefined;
40
40
  /** Currently selected package. */
41
41
  export const selectedPackage: string | undefined;
42
42
  }