igniteui-astro-components 1.2.1 → 1.4.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.
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Full-text tooltip for truncated sidebar labels.
3
+ *
4
+ * Leaf labels (`.docs-tree-label`) are clamped to two lines in
5
+ * DocsTree/docs-tree.scss. When a label overflows that clamp, hovering or
6
+ * focusing its row shows the complete text in a single shared <igc-tooltip>
7
+ * so the user can read it before navigating. Rows whose label fits never
8
+ * trigger the tooltip.
9
+ *
10
+ * Design:
11
+ * • One tooltip per sidebar, re-anchored to the hovered/focused row with
12
+ * `tooltip.show(row)`. Hundreds of per-item tooltips would be wasteful.
13
+ * • The tooltip's own triggers are disabled (`show-triggers=""`,
14
+ * `hide-triggers=""`); this module owns show/hide so the truncation
15
+ * check runs on every interaction and stays correct after resizes.
16
+ * • Truncation is measured, not guessed: `scrollHeight > clientHeight` on
17
+ * the clamped label. Works for -webkit-line-clamp and plain overflow.
18
+ * • Hides on pointer leave, focus leave, click (navigation), sidebar scroll
19
+ * and `astro:before-swap`.
20
+ * • Mobile/tablet (< 1280px): docs-tree.scss removes the clamp so labels
21
+ * show in full; nothing measures as truncated and the tooltip never opens.
22
+ */
23
+
24
+ import type { IgcTooltipComponent } from 'igniteui-webcomponents';
25
+
26
+ const TOOLTIP_SELECTOR = 'igc-tooltip[data-sidebar-tooltip]';
27
+ const SCROLL_SELECTOR = '[data-sidebar-scroll]';
28
+ const ITEM_SELECTOR = 'igc-tree-item';
29
+ const LABEL_SELECTOR = ':scope > [slot="label"] .docs-tree-label';
30
+
31
+ /** Delay before showing, mirrors igc-tooltip's default `show-delay`. */
32
+ const SHOW_DELAY = 200;
33
+
34
+ /** 1px tolerance for sub-pixel rounding between scrollHeight and clientHeight. */
35
+ const OVERFLOW_TOLERANCE = 1;
36
+
37
+ const isTruncated = (el: HTMLElement): boolean =>
38
+ el.scrollHeight - el.clientHeight > OVERFLOW_TOLERANCE;
39
+
40
+ /** The row's own label (not a descendant row's), or null for group rows. */
41
+ const getRowLabel = (row: Element): HTMLElement | null =>
42
+ row.querySelector<HTMLElement>(LABEL_SELECTOR);
43
+
44
+ export class SidebarTooltip {
45
+ private readonly host: HTMLElement;
46
+ private readonly tooltip: IgcTooltipComponent;
47
+ private readonly abort = new AbortController();
48
+ private pendingTimer: ReturnType<typeof setTimeout> | undefined;
49
+ private currentRow: Element | null = null;
50
+ /**
51
+ * Row the user just clicked. Clicking focuses the row (see DocsTree.astro),
52
+ * and that focusin must not re-open the tooltip over a page that is about
53
+ * to navigate. Cleared once the pointer leaves the row.
54
+ */
55
+ private suppressedRow: Element | null = null;
56
+
57
+ constructor(host: HTMLElement, tooltip: IgcTooltipComponent) {
58
+ this.host = host;
59
+ this.tooltip = tooltip;
60
+
61
+ const { signal } = this.abort;
62
+ const opts: AddEventListenerOptions = { passive: true, signal };
63
+
64
+ host.addEventListener('pointerover', this.onPointerOver, opts);
65
+ host.addEventListener('pointerout', this.onPointerOut, opts);
66
+ // igc-tree-item delegates focus to the slotted <a> and calls
67
+ // stopPropagation() on focusin/focusout inside its shadow root, so the
68
+ // host only ever sees these events in the capture phase.
69
+ host.addEventListener('focusin', this.onFocusIn, { capture: true, ...opts });
70
+ host.addEventListener('focusout', this.onFocusOut, { capture: true, ...opts });
71
+ host.addEventListener('click', this.onClick, { capture: true, ...opts });
72
+ host.querySelector(SCROLL_SELECTOR)?.addEventListener('scroll', this.hide, opts);
73
+ // The host is replaced on client-side navigation; drop everything then.
74
+ document.addEventListener('astro:before-swap', () => this.destroy(), { signal });
75
+ }
76
+
77
+ destroy(): void {
78
+ this.hide();
79
+ this.abort.abort();
80
+ }
81
+
82
+ // ── Event handlers ────────────────────────────────────────────────────────
83
+
84
+ private onPointerOver = (e: PointerEvent): void => {
85
+ const row = (e.target as Element | null)?.closest(ITEM_SELECTOR);
86
+ if (!row || row === this.currentRow) return;
87
+ if (row !== this.suppressedRow) this.suppressedRow = null;
88
+ this.scheduleShow(row);
89
+ };
90
+
91
+ private onPointerOut = (e: PointerEvent): void => {
92
+ const row = (e.target as Element | null)?.closest(ITEM_SELECTOR);
93
+ if (!row) return;
94
+ // Still inside the same row (moved between its child elements)?
95
+ const to = e.relatedTarget as Element | null;
96
+ if (to && row.contains(to) && to.closest(ITEM_SELECTOR) === row) return;
97
+ if (row === this.suppressedRow) this.suppressedRow = null;
98
+ if (row === this.currentRow) this.hide();
99
+ };
100
+
101
+ private onClick = (e: MouseEvent): void => {
102
+ this.suppressedRow = (e.target as Element | null)?.closest(ITEM_SELECTOR) ?? null;
103
+ this.hide();
104
+ };
105
+
106
+ private onFocusIn = (e: FocusEvent): void => {
107
+ const row = (e.target as Element | null)?.closest(ITEM_SELECTOR);
108
+ if (!row) return;
109
+ this.scheduleShow(row);
110
+ };
111
+
112
+ private onFocusOut = (e: FocusEvent): void => {
113
+ const to = e.relatedTarget as Element | null;
114
+ if (to && to.closest(ITEM_SELECTOR) === this.currentRow) return;
115
+ this.hide();
116
+ };
117
+
118
+ // ── Show / hide ───────────────────────────────────────────────────────────
119
+
120
+ private scheduleShow(row: Element): void {
121
+ this.cancelPending();
122
+ if (row === this.suppressedRow) return;
123
+ const label = getRowLabel(row);
124
+ if (!label || !isTruncated(label)) {
125
+ // Moving from a truncated row to a non-truncated one: drop the old tooltip.
126
+ if (this.currentRow && this.currentRow !== row) this.hide();
127
+ return;
128
+ }
129
+
130
+ const text = label.textContent?.trim() ?? '';
131
+ if (!text) return;
132
+
133
+ this.currentRow = row;
134
+ this.pendingTimer = setTimeout(() => {
135
+ this.pendingTimer = undefined;
136
+ if (this.currentRow !== row) return;
137
+ this.tooltip.message = text;
138
+ void this.tooltip.show(row);
139
+ }, SHOW_DELAY);
140
+ }
141
+
142
+ private hide = (): void => {
143
+ this.cancelPending();
144
+ this.currentRow = null;
145
+ if (this.tooltip.open) void this.tooltip.hide();
146
+ };
147
+
148
+ private cancelPending(): void {
149
+ if (this.pendingTimer !== undefined) {
150
+ clearTimeout(this.pendingTimer);
151
+ this.pendingTimer = undefined;
152
+ }
153
+ }
154
+ }
155
+
156
+ // ── Bootstrap ───────────────────────────────────────────────────────────────
157
+
158
+ const instances = new WeakMap<HTMLElement, SidebarTooltip>();
159
+
160
+ /** Attach a SidebarTooltip to every sidebar on the page that has one declared. */
161
+ export function initSidebarTooltips(root: ParentNode = document): void {
162
+ root.querySelectorAll<IgcTooltipComponent>(TOOLTIP_SELECTOR).forEach((tooltip) => {
163
+ const host = tooltip.closest<HTMLElement>('sidebar-filter');
164
+ if (!host || instances.has(host)) return;
165
+ instances.set(host, new SidebarTooltip(host, tooltip));
166
+ });
167
+ }
168
+
169
+ const bootstrap = () => {
170
+ customElements.whenDefined('igc-tooltip').then(() => initSidebarTooltips());
171
+ };
172
+
173
+ bootstrap();
174
+ document.addEventListener('astro:page-load', bootstrap);
@@ -10,12 +10,18 @@
10
10
  * Sets `data-tree-id`, `data-depth`, and `data-has-children` (when applicable).
11
11
  * Any extra `data-*` attributes come from `node.itemData` (kebab-cased keys).
12
12
  *
13
+ * The expand/collapse chevron is rendered in the label slot *before* the
14
+ * text (leading position), never in igc-tree-item's native `indicator` part,
15
+ * which is hidden globally via `::part(indicator)`. Nesting is expressed with
16
+ * the native `indentation` part (see `--igc-tree-indentation-size` in
17
+ * docs-tree.scss), so a nested group's chevron sits in its parent's label
18
+ * column.
19
+ *
13
20
  * The `active` attribute is intentionally NOT set on <igc-tree-item>:
14
21
  * setting it triggers IgcTreeItemComponent.activeChange() synchronously
15
22
  * during defineComponents(), before the tree is upgraded, crashing on
16
23
  * `this.tree?.expandToItem`. Active-row highlight is CSS-driven via
17
24
  * `igc-tree-item:has(a[aria-current])` instead.
18
- * The default expand indicator is hidden globally via `::part(indicator)`.
19
25
  */
20
26
  import type { TreeNode, TreeVariant } from './types';
21
27
 
@@ -60,21 +66,21 @@ if (node.itemData) {
60
66
  class="docs-tree-link"
61
67
  {...node.linkAttrs}
62
68
  />
69
+ {hasChildren && <igc-icon name="chevron" collection="docs" class="tree-expand-icon" />}
63
70
  {RenderLabel ? (
64
71
  <RenderLabel node={node} depth={depth} isLeaf={isLeaf} isActive={isActive} />
65
72
  ) : (
66
73
  <span class="docs-tree-label">{node.label}</span>
67
74
  )}
68
- {hasChildren && <igc-icon name="chevron" collection="docs" class="tree-expand-icon" />}
69
75
  </div>
70
76
  ) : (
71
77
  <div slot="label" class="docs-tree-group">
78
+ <igc-icon name="chevron" collection="docs" class="tree-expand-icon" />
72
79
  {RenderLabel ? (
73
80
  <RenderLabel node={node} depth={depth} isLeaf={isLeaf} isActive={isActive} />
74
81
  ) : (
75
82
  <span class="docs-tree-label">{node.label}</span>
76
83
  )}
77
- <igc-icon name="chevron" collection="docs" class="tree-expand-icon" />
78
84
  </div>
79
85
  )
80
86
  }
@@ -80,22 +80,23 @@ All structural and per-variant rules are in
80
80
  [`docs-tree.css`](./docs-tree.css). The file is imported once by
81
81
  `DocsTree.astro`; Astro hoists and dedupes it.
82
82
 
83
- Overridable tokens (set on `igc-tree`):
83
+ Sidebar layout tokens (set on `igc-tree[data-variant="sidebar"]`):
84
84
 
85
85
  ```
86
- --docs-tree-row-pad-y
87
- --docs-tree-row-pad-x
88
- --docs-tree-row-radius
89
- --docs-tree-row-color
90
- --docs-tree-row-hover-bg
91
- --docs-tree-row-hover-color
92
- --docs-tree-row-active-bg
93
- --docs-tree-row-active-color
94
- --docs-tree-group-color
95
- --docs-tree-nested-rule
96
- --docs-tree-nested-pad-x
86
+ --docs-tree-row-inset leading space on every row before chevron/label (6px)
87
+ --docs-tree-indent one indentation step per nesting level (16px)
88
+ --docs-tree-expand-col width of the leading chevron column (14px)
89
+ --docs-tree-expand-icon-size chevron glyph size inside the column (14px)
90
+ --docs-tree-expand-gap gap between the chevron and the group label (8px)
91
+ --docs-tree-leaf-inset extra inset of a leaf label (6px)
97
92
  ```
98
93
 
94
+ The chevron is rendered in the label slot _before_ the text; nesting uses
95
+ `igc-tree-item`'s native `indentation` part. Keep the invariant
96
+ `indent + leaf inset == expand column + gap`: it makes a leaf directly under a
97
+ root group line up with that group's label, and puts a nested group's chevron
98
+ in its parent's label column.
99
+
99
100
  ## Adapters
100
101
 
101
102
  Consumers convert their domain types to `TreeNode[]` via small adapters:
@@ -1,4 +1,5 @@
1
1
  @use 'igniteui-theming/sass/typography' as *;
2
+ @use '../../styles/global/breakpoints' as *;
2
3
 
3
4
  /*
4
5
  * if we need to modify the toc or the sidebar in any way we can use:
@@ -58,7 +59,50 @@ igc-tree {
58
59
  // anchor-name: --selected-tree-item;
59
60
  //}
60
61
 
62
+ /*
63
+ * Sidebar layout model (all values overridable):
64
+ *
65
+ * ┌ row (wrapper) ─────────────────────────────────────────────────┐
66
+ * │[indent × level][6px][▸ 14px][8px] Group label │
67
+ * │[indent × level][6px][6px] Leaf label [badges] │
68
+ * └─────────────────────────────────────────────────────────────────┘
69
+ *
70
+ * • --docs-tree-row-inset leading space on every row, before the
71
+ * chevron / label (6px)
72
+ * • --docs-tree-indent one step per nesting level (16px)
73
+ * • --docs-tree-expand-col width of the chevron column (14px)
74
+ * • --docs-tree-expand-icon-size chevron glyph size (14px)
75
+ * • --docs-tree-expand-gap gap between chevron and label (8px)
76
+ * • --docs-tree-leaf-inset extra inset of a leaf label (6px)
77
+ *
78
+ * Invariant: indent + leaf inset == chevron column + gap. That makes a leaf
79
+ * directly under a root group line up with the root group's label, and puts
80
+ * a nested group's chevron in its parent's label column.
81
+ */
61
82
  igc-tree[data-variant='sidebar'] {
83
+ --docs-tree-row-inset: #{rem(6px)};
84
+ --docs-tree-indent: #{rem(16px)};
85
+ --docs-tree-expand-col: #{rem(14px)};
86
+ --docs-tree-expand-icon-size: #{rem(14px)};
87
+ --docs-tree-expand-gap: #{rem(8px)};
88
+ --docs-tree-leaf-inset: #{rem(6px)};
89
+
90
+ igc-tree-item {
91
+ // Drives the width of igc-tree-item's native `indentation` part
92
+ // (width = level × size), which precedes the label slot in the row.
93
+ --igc-tree-indentation-size: var(--docs-tree-indent);
94
+
95
+ &::part(wrapper) {
96
+ border-radius: rem(4px);
97
+ }
98
+
99
+ // The label part is `width: 100%`, which would otherwise make the
100
+ // indentation flex item shrink and drift the columns by 1–3px per level.
101
+ &::part(indentation) {
102
+ flex-shrink: 0;
103
+ }
104
+ }
105
+
62
106
  igc-tree-item + igc-tree-item[data-has-children] {
63
107
  margin-block-start: rem(4px);
64
108
  }
@@ -70,13 +114,10 @@ igc-tree[data-variant='sidebar'] {
70
114
  }
71
115
  }
72
116
 
117
+ // ── Group rows ──────────────────────────────────────────────────────────
73
118
  igc-tree-item[aria-expanded] {
74
- &::part(wrapper) {
75
- border-radius: rem(4px);
76
-
77
- &:hover {
78
- background-color: var(--ig-gray-50);
79
- }
119
+ &::part(wrapper):hover {
120
+ background-color: var(--ig-gray-50);
80
121
  }
81
122
 
82
123
  .docs-tree-group {
@@ -89,6 +130,29 @@ igc-tree[data-variant='sidebar'] {
89
130
  background-color: var(--ig-gray-50);
90
131
  }
91
132
  }
133
+
134
+ // Only root groups are bold; nested groups read as regular entries.
135
+ igc-tree-item:not([data-depth='0']) > [slot='label'] .group-label-text {
136
+ font-weight: 400;
137
+ }
138
+
139
+ // ── Leaf rows ───────────────────────────────────────────────────────────
140
+ // Hover / active backgrounds live on the wrapper so they span the whole
141
+ // row (including the indentation) rather than just the label area.
142
+ igc-tree-item:not([data-has-children]) {
143
+ &::part(wrapper):hover,
144
+ &:has(.docs-tree-link:focus)::part(wrapper) {
145
+ background-color: var(--ig-gray-50);
146
+ }
147
+ }
148
+
149
+ // Leaves directly under a root group are primary entries (dark text);
150
+ // deeper leaves inherit the muted default foreground.
151
+ igc-tree-item[data-depth='1']:not([data-has-children]) {
152
+ --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-600));
153
+ --foreground-active: light-dark(var(--ig-gray-900), var(--ig-gray-50));
154
+ --foreground-hover: light-dark(var(--ig-gray-900), var(--ig-gray-50));
155
+ }
92
156
  }
93
157
 
94
158
  igc-tree[data-variant='toc'] {
@@ -202,13 +266,18 @@ igc-tree-item[data-has-children] {
202
266
  }
203
267
  }
204
268
 
269
+ /* Leading expand/collapse chevron: a fixed-width column with the glyph
270
+ centred inside it, followed by a gap to the label. */
205
271
  .tree-expand-icon {
206
- margin-inline-start: auto;
272
+ --size: var(--docs-tree-expand-icon-size, #{rem(14px)});
273
+
207
274
  flex-shrink: 0;
275
+ width: var(--docs-tree-expand-col, #{rem(14px)});
276
+ height: var(--docs-tree-expand-col, #{rem(14px)});
277
+ margin-inline-end: var(--docs-tree-expand-gap, #{rem(8px)});
208
278
  color: inherit;
209
279
  transform: rotate(-90deg);
210
280
  transition: transform 0.2s ease;
211
- margin-inline-end: rem(1px);
212
281
  }
213
282
 
214
283
  igc-tree-item[aria-expanded='false'] > [slot='label'] {
@@ -224,10 +293,6 @@ igc-tree-item[aria-expanded='true'] > [slot='label'] {
224
293
  }
225
294
  }
226
295
 
227
- igc-tree-item[data-has-children][data-depth='0'] {
228
- --igc-tree-indentation-size: 0;
229
- }
230
-
231
296
  igc-tree-item[data-has-children] {
232
297
  --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-600));
233
298
  --foreground-selected: light-dark(var(--ig-gray-900), var(--ig-gray-600));
@@ -268,9 +333,10 @@ igc-tree-item:not([data-has-children]):hover .docs-tree-label {
268
333
 
269
334
  .igd-label-and-badge {
270
335
  position: relative;
271
- border-radius: rem(4px);
272
336
  padding-block: rem(8px);
273
- padding-inline-start: rem(12px);
337
+ padding-inline-start: calc(
338
+ var(--docs-tree-row-inset, #{rem(6px)}) + var(--docs-tree-leaf-inset, #{rem(6px)})
339
+ );
274
340
  padding-inline-end: rem(8px);
275
341
  height: 100%;
276
342
  z-index: -1;
@@ -287,37 +353,26 @@ igc-tree-item:not([data-has-children]):hover .docs-tree-label {
287
353
  //}
288
354
  }
289
355
 
290
- .docs-tree-link {
291
- &:hover,
292
- &:focus {
293
- + .igd-label-and-badge {
294
- background-color: var(--ig-gray-50);
356
+ /* Active (current page) leaf. `selected` is also set on every ancestor of
357
+ the active item (see DocsTree.astro), so restrict to leaves explicitly. */
358
+ igc-tree[data-variant='sidebar'] {
359
+ igc-tree-item[selected]:not([data-has-children]) {
360
+ // Listed explicitly (not just via inheritance from the base rule) because
361
+ // the leaf hover/focus rule above has higher specificity (`:has()`)
362
+ // and would otherwise paint the focused selected row gray.
363
+ &::part(wrapper),
364
+ &::part(wrapper):hover,
365
+ &:has(.docs-tree-link:focus)::part(wrapper) {
366
+ background-color: var(--igd-accent);
295
367
  }
296
- }
297
- }
298
368
 
299
- igc-tree-item[selected] {
300
- igc-tree-item[selected]:not([aria-expanded]) {
301
369
  .igd-label-and-badge {
302
370
  color: var(--igd-on-accent);
303
- background-color: var(--igd-accent);
304
-
305
- .docs-tree-label {
306
- color: var(--igd-on-accent);
307
- }
308
371
  }
309
372
 
310
- &:has(.igd-label-and-badge) {
311
- &:hover,
312
- &:focus {
313
- .igd-label-and-badge {
314
- background-color: var(--igd-accent);
315
-
316
- .docs-tree-label {
317
- color: #fff;
318
- }
319
- }
320
- }
373
+ .docs-tree-label,
374
+ &:hover .docs-tree-label {
375
+ color: var(--igd-on-accent);
321
376
  }
322
377
 
323
378
  .sidebar-premium-icon {
@@ -387,6 +442,18 @@ igc-tree[data-variant='toc'] {
387
442
  }
388
443
  }
389
444
 
445
+ /* Mobile + tablet (< 1280px): the sidebar is a slide-in overlay on touch-first
446
+ devices, so labels show in full instead of clamping. This also disables the
447
+ full-text tooltip, which only opens when a label measures as overflowing
448
+ (see DocsSidebar/sidebar-tooltip.ts). */
449
+ @media (max-width: #{$bp-tablet-max}) {
450
+ igc-tree[data-variant='sidebar'] .docs-tree-label {
451
+ display: block;
452
+ -webkit-line-clamp: unset;
453
+ overflow: visible;
454
+ }
455
+ }
456
+
390
457
  /* Filter visibility — driven by <sidebar-filter>. */
391
458
  // Removing this will break the filter in the sidebar
392
459
  sidebar-filter[data-filtering]
@@ -74,6 +74,8 @@ import { rehypeHeadingAnchors } from './plugins/rehype-heading-anchors';
74
74
  export { rehypeHeadingAnchors } from './plugins/rehype-heading-anchors';
75
75
  import { rehypePagefindIgnore } from './plugins/rehype-pagefind-ignore';
76
76
  export { rehypePagefindIgnore } from './plugins/rehype-pagefind-ignore';
77
+ import { igChrome, type IgChromeOptions } from './chrome/integration';
78
+ export { igChrome, type IgChromeOptions } from './chrome/integration';
77
79
  import { remarkMdLinks } from './plugins/remark-md-links';
78
80
  import { remarkHtmlTransforms } from './plugins/remark-html-transforms';
79
81
 
@@ -558,6 +560,12 @@ export interface CreateDocsSiteOptions {
558
560
  * and the build-time nav prefetch endpoint.
559
561
  */
560
562
  platform?: PlatformKey | null;
563
+ /**
564
+ * Render the header and footer from a snapshot of the marketing site's
565
+ * exported chrome instead of the legacy fetched one. See
566
+ * src/chrome/integration.ts. Japanese builds keep the legacy chrome.
567
+ */
568
+ chrome?: IgChromeOptions;
561
569
  /** Locale for the nav prefetch URL. */
562
570
  navLang?: NavLang;
563
571
  /**
@@ -621,6 +629,7 @@ export function createDocsSite(
621
629
  head = [],
622
630
  llmsSets = [] as LlmsSet[],
623
631
  integrations: extraIntegrations = [],
632
+ chrome,
624
633
  ...astroExtra
625
634
  } = options;
626
635
 
@@ -645,7 +654,10 @@ export function createDocsSite(
645
654
  }
646
655
 
647
656
  // Platform CDN entries come first so site-specific `head` entries can override.
648
- const platformHead = platform ? getPlatformHead(platform, navLang) : [];
657
+ // The legacy chrome's own CSS/JS only where that chrome renders.
658
+ const platformHead = platform
659
+ ? getPlatformHead(platform, navLang, { legacyChrome: !chrome || navLang === 'jp' })
660
+ : [];
649
661
 
650
662
  // highlight.js for code-tab syntax highlighting inside code-view widgets.
651
663
  const codeViewHead: HeadEntry[] = [
@@ -755,6 +767,7 @@ export function createDocsSite(
755
767
  head: [...platformHead, ...codeViewHead, ...head],
756
768
  }),
757
769
  mdx(),
770
+ ...(chrome ? [igChrome(chrome)] : []),
758
771
  ...(source.imagesDir ? [staticImagesIntegration(source.imagesDir)] : []),
759
772
  ...(base ? [createBasePrependIntegration(base)] : []),
760
773
  ...extraIntegrations,
@@ -75,6 +75,19 @@ const resolvedSiteTitle = siteTitleProp ?? siteTitle;
75
75
  const licenseType = license === 'commercial' ? 'premium' : license === 'MIT' ? 'opensource' : false;
76
76
  const navTheme = (virtualPlatform ?? import.meta.env.VITE_NAV_THEME ?? 'igniteui') as string;
77
77
  const showGlobalNav = navTheme !== 'none';
78
+
79
+ /**
80
+ * The Infragistics header and footer, chosen per build:
81
+ *
82
+ * 1. `navLang: 'jp'` — the legacy chrome fetched from jp.infragistics.com
83
+ * (GlobalNavBar / GlobalFooter), until a Japanese fragment is published;
84
+ * 2. the site registers igChrome({ snapshot }) — the marketing site's own
85
+ * exported chrome, from the site's snapshot (src/chrome/integration.ts).
86
+ * Nothing is fetched at build or at runtime;
87
+ * 3. otherwise — the legacy fetched chrome, unchanged.
88
+ */
89
+ const chromeSnapshot =
90
+ navLang !== 'jp' && typeof __IG_CHROME__ !== 'undefined' ? __IG_CHROME__ : null;
78
91
  const pageTitle = title ? `${title} | ${resolvedSiteTitle}` : resolvedSiteTitle;
79
92
 
80
93
  type HeadEntry = {
@@ -103,6 +116,15 @@ type HeadEntry = {
103
116
  content ? <Tag {...attrs} set:html={content} /> : <Tag {...attrs} />,
104
117
  )
105
118
  }
119
+ {
120
+ chromeSnapshot && (
121
+ <meta
122
+ name="ig-chrome"
123
+ content={`${chromeSnapshot.contract} build=${chromeSnapshot.build}`}
124
+ />
125
+ )
126
+ }
127
+ {chromeSnapshot && <Fragment set:html={chromeSnapshot.head} />}
106
128
  <slot name="head" />
107
129
  <ClientRouter />
108
130
  <script is:inline>
@@ -178,10 +200,16 @@ type HeadEntry = {
178
200
  });
179
201
  });
180
202
 
203
+ function navChildEl() {
204
+ var root = document.querySelector('[data-astro-transition-persist="global-nav-bar"]');
205
+ if (!root) return null;
206
+ // The synced header sits in a display:contents wrapper with no box of
207
+ // its own, so measure the header element itself.
208
+ return root.querySelector('header.nv') || root.firstElementChild;
209
+ }
210
+
181
211
  function updateNavHeight() {
182
- var navChild = document.querySelector(
183
- '[data-astro-transition-persist="global-nav-bar"] > *:first-child',
184
- );
212
+ var navChild = navChildEl();
185
213
  if (!navChild) return;
186
214
  var h = navChild.getBoundingClientRect().height;
187
215
  if (h > 0) {
@@ -193,9 +221,7 @@ type HeadEntry = {
193
221
  document.addEventListener('astro:page-load', updateNavHeight);
194
222
  window.addEventListener('resize', updateNavHeight);
195
223
  updateNavHeight();
196
- var _navChild = document.querySelector(
197
- '[data-astro-transition-persist="global-nav-bar"] > *:first-child',
198
- );
224
+ var _navChild = navChildEl();
199
225
  if (_navChild) new ResizeObserver(updateNavHeight).observe(_navChild);
200
226
 
201
227
  // Clamp sidebar height so it never overlaps the footer.
@@ -263,7 +289,18 @@ type HeadEntry = {
263
289
  </head>
264
290
  <body>
265
291
  <!-- INFRAGISTICS HEADER/NAVIGATION -->
266
- {showGlobalNav && <GlobalNavBar lang={navLang} />}
292
+ {
293
+ showGlobalNav &&
294
+ (chromeSnapshot ? (
295
+ /* `.nv` is `position: sticky`, so the wrapper has to be sticky too, or the
296
+ nav would stop at the bottom of a wrapper exactly its own height. */
297
+ <div transition:persist="global-nav-bar" style="position: sticky; top: 0; z-index: 50">
298
+ <Fragment set:html={chromeSnapshot.header} />
299
+ </div>
300
+ ) : (
301
+ <GlobalNavBar lang={navLang} />
302
+ ))
303
+ }
267
304
 
268
305
  <!-- MAIN PAGE GRID LAYOUT -->
269
306
  <!-- We don't set the CSS grid directly to the body -->
@@ -321,7 +358,18 @@ type HeadEntry = {
321
358
 
322
359
  <!-- Footer is inside the grid so the sidebar's sticky containing block extends through it.
323
360
  The JS initSidebarHeights() clamps sidebar max-height to prevent visual overlap. -->
324
- <GlobalFooter lang={navLang} />
361
+ {
362
+ chromeSnapshot ? (
363
+ /* Full width of the grid, found by initSidebarHeights() through
364
+ data-igd-footer, and persisted across navigations: the exported
365
+ script wires the footer's accordion once, on first load. */
366
+ <div style="grid-column: 1 / -1" data-igd-footer transition:persist="global-footer">
367
+ <Fragment set:html={chromeSnapshot.footer} />
368
+ </div>
369
+ ) : (
370
+ <GlobalFooter lang={navLang} />
371
+ )
372
+ }
325
373
  </div>
326
374
  </body>
327
375
  </html>
@@ -100,6 +100,23 @@ const slug = Astro.params.slug ?? '';
100
100
  </DocsLayout>
101
101
  ```
102
102
 
103
+ ## Header and footer
104
+
105
+ `DocsLayout` renders the Infragistics header and footer itself; which one
106
+ depends on the build:
107
+
108
+ | Build | Header / footer |
109
+ | ------------------------------------------- | ---------------------------------------------------------------- |
110
+ | the site registers `igChrome({ snapshot })` | the marketing site's exported chrome, from the site's snapshot |
111
+ | `navLang: 'jp'` | the legacy chrome fetched from `jp.infragistics.com/navigation` |
112
+ | otherwise | the legacy chrome fetched from `www.infragistics.com/navigation` |
113
+
114
+ With a snapshot, the head part goes into `<head>` (with
115
+ `<meta name="ig-chrome" content="v1 build=…">`), the header into the sticky,
116
+ persisted `global-nav-bar` wrapper, and the footer into a full-width grid cell
117
+ with `data-igd-footer`, persisted across navigations. See
118
+ [The Infragistics header and footer](../../../README.md#the-infragistics-header-and-footer).
119
+
103
120
  ## Virtual module dependencies
104
121
 
105
122
  `DocsLayout` imports from two virtual modules. When using `siteMetaIntegration`