igniteui-astro-components 0.0.7 → 0.0.9

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 (54) hide show
  1. package/package.json +4 -2
  2. package/src/assets/icons/open-link-blank.svg +1 -1
  3. package/src/assets/logos/code-sandbox.svg +14 -0
  4. package/src/assets/logos/stackblitz.svg +13 -0
  5. package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +3 -3
  6. package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +13 -4
  7. package/src/components/DocsSidebar/DocsSidebar.astro +19 -8
  8. package/src/components/DocsSidebar/DocsSidebar.scss +140 -3
  9. package/src/components/DocsSidebar/SidebarFilterInput.astro +3 -4
  10. package/src/components/DocsSidebar/SidebarFilterInput.scss +9 -6
  11. package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
  12. package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
  13. package/src/components/DocsSubHeader/DocsSubHeader.astro +128 -302
  14. package/src/components/DocsSubHeader/DocsSubHeader.scss +115 -18
  15. package/src/components/DocsToc/DocsToc.astro +15 -7
  16. package/src/components/DocsToc/DocsToc.scss +10 -11
  17. package/src/components/DocsTree/DocsTree.astro +9 -0
  18. package/src/components/DocsTree/docs-tree.scss +146 -118
  19. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -1
  20. package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
  21. package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
  22. package/src/components/MobileTocToggle/MobileTocToggle.astro +96 -0
  23. package/src/components/MobileTocToggle/MobileTocToggle.scss +74 -0
  24. package/src/components/Search/Search.astro +45 -15
  25. package/src/components/Search/Search.scss +21 -40
  26. package/src/components/SearchAdvanced/SearchAdvanced.astro +196 -355
  27. package/src/components/SearchAdvanced/SearchAdvanced.scss +208 -0
  28. package/src/components/mdx/ApiRef/README.md +1 -1
  29. package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
  30. package/src/components/mdx/DocsAside/DocsAside.scss +106 -35
  31. package/src/components/mdx/Sample/Sample.astro +55 -45
  32. package/src/components/mdx/Sample/Sample.scss +173 -30
  33. package/src/integration.ts +7 -0
  34. package/src/layouts/DocsLayout/DocsLayout.astro +81 -21
  35. package/src/layouts/DocsLayout/DocsLayout.scss +251 -46
  36. package/src/lib/sidebar/helpers.ts +14 -1
  37. package/src/lib/sidebar/types.ts +5 -7
  38. package/src/plugins/rehype-heading-anchors.ts +74 -0
  39. package/src/plugins/rehype-table-wrapper.ts +49 -0
  40. package/src/plugins/remark-docfx.ts +0 -0
  41. package/src/scripts/sample-widget.ts +107 -114
  42. package/src/styles/global/_breakpoints.scss +15 -37
  43. package/src/styles/global/_code-blocks.scss +1 -1
  44. package/src/styles/global/_component-themes.scss +99 -18
  45. package/src/styles/global/_index.scss +2 -2
  46. package/src/styles/global/_markdown.scss +552 -78
  47. package/src/styles/global/_palette.scss +8 -0
  48. package/src/styles/global/_search-shared.scss +272 -0
  49. package/src/styles/global/_type-scale.scss +2 -2
  50. package/src/styles/global/_variables.scss +55 -13
  51. package/src/styles/theme.scss +98 -11
  52. package/src/assets/icons/copy-clipboard.svg +0 -3
  53. package/src/assets/icons/filter-clear.svg +0 -1
  54. package/src/styles/custom.scss +0 -20
@@ -92,9 +92,11 @@ const nodes = headingsToTreeNodes(headings, tocConfig);
92
92
  this.querySelectorAll('a[aria-current]').forEach(
93
93
  (a) => a.removeAttribute('aria-current'),
94
94
  );
95
- // Clear any stale selected state on tree items.
95
+ // Clear any stale selected / active state on tree items.
96
96
  this.querySelectorAll('igc-tree-item').forEach((item) => {
97
- (item as HTMLElement & { selected: boolean }).selected = false;
97
+ const treeItem = item as HTMLElement & { selected: boolean; active: boolean };
98
+ treeItem.selected = false;
99
+ treeItem.active = false;
98
100
  });
99
101
 
100
102
  this.links = Array.from(this.querySelectorAll<HTMLAnchorElement>('a[href^="#"]'));
@@ -144,8 +146,11 @@ const nodes = headingsToTreeNodes(headings, tocConfig);
144
146
 
145
147
  private bindOffsetTarget() {
146
148
  const selector = this.dataset.offsetTarget ?? null;
147
- if (!selector) return;
148
- this.offsetEl = document.querySelector(selector);
149
+ // If an explicit selector is given, use it; otherwise fall back to
150
+ // the docs subheader which is always present in the layout.
151
+ this.offsetEl = (selector ? document.querySelector(selector) : null)
152
+ ?? document.querySelector('docs-subheader-menu')
153
+ ?? null;
149
154
  if (!this.offsetEl) return;
150
155
 
151
156
  this.syncScrollPadding();
@@ -209,12 +214,15 @@ const nodes = headingsToTreeNodes(headings, tocConfig);
209
214
  const next = this.links[index];
210
215
  if (!next || next === this.currentLink) return;
211
216
 
212
- const prevItem = this.currentLink?.closest<HTMLElement & { selected: boolean }>('igc-tree-item');
213
- if (prevItem) prevItem.selected = false;
217
+ const prevItem = this.currentLink?.closest<HTMLElement & { selected: boolean; active: boolean }>('igc-tree-item');
218
+ if (prevItem) {
219
+ prevItem.selected = false;
220
+ prevItem.active = false;
221
+ }
214
222
  this.currentLink?.removeAttribute('aria-current');
215
223
 
216
224
  next.setAttribute('aria-current', 'true');
217
- const nextItem = next.closest<HTMLElement & { selected: boolean }>('igc-tree-item');
225
+ const nextItem = next.closest<HTMLElement & { selected: boolean; active: boolean }>('igc-tree-item');
218
226
  if (nextItem) nextItem.selected = true;
219
227
 
220
228
  this.currentLink = next;
@@ -19,15 +19,14 @@
19
19
  background-color: var(--igd-layout-sections-bg);
20
20
  }
21
21
 
22
- .ig-typography {
23
- .toc-sidebar__heading {
24
- @include type-style('body-2') {
25
- margin: 0;
26
- };
27
-
28
- color: var(--ig-gray-500);
29
- padding-block-end: rem(8px);
30
- padding-inline: rem(24px) 0;
31
- text-transform: uppercase;
32
- }
22
+
23
+ .toc-sidebar__heading {
24
+ @include type-style('body-2') {
25
+ margin: 0;
26
+ };
27
+
28
+ color: var(--ig-gray-500);
29
+ padding-block-end: rem(8px);
30
+ padding-inline: rem(24px) 0;
31
+ text-transform: uppercase;
33
32
  }
@@ -77,4 +77,13 @@ const { nodes, variant, activeId, toggleNodeOnClick, ariaLabel, renderLabel } =
77
77
 
78
78
  selectActiveTreeItem();
79
79
  document.addEventListener('astro:page-load', selectActiveTreeItem);
80
+
81
+ // Suppress the active-indicator transition during window resize so the
82
+ // anchor-positioned ::before bar doesn't slowly slide to its new position.
83
+ let resizeTimer: ReturnType<typeof setTimeout>;
84
+ window.addEventListener('resize', () => {
85
+ document.body.classList.add('is-resizing');
86
+ clearTimeout(resizeTimer);
87
+ resizeTimer = setTimeout(() => document.body.classList.remove('is-resizing'), 150);
88
+ }, { passive: true });
80
89
  </script>
@@ -14,172 +14,200 @@
14
14
  */
15
15
 
16
16
  igc-tree {
17
- --ig-tree-background: transparent;
18
- --ig-size: 1;
19
-
20
- position: relative;
21
-
22
- &::before {
23
- content: '';
24
- position: absolute;
25
- position-anchor: --selected-tree-item;
26
- top: anchor(top);
27
- height: anchor-size(height);
28
- inset-inline-start: 0;
29
- width: rem(1px);
30
- background-color: var(--igd-accent);
31
- transition: top 0.2s ease, height 0.2s ease;
32
- display: none;
33
- z-index: 1;
34
- }
35
-
36
- &::after {
37
- content: '';
38
- position: absolute;
39
- width: rem(1px);
40
- inset-inline-start: 0;
41
- top: 0;
42
- z-index: 0;
43
- height: 100%;
44
- background: light-dark(var(--ig-gray-200), var(--ig-gray-300));
45
- }
46
-
47
- &:has(igc-tree-item[selected])::before {
48
- display: block;
49
- }
17
+ --ig-tree-background: transparent;
18
+ --ig-size: 1;
19
+
20
+ position: relative;
21
+
22
+ &::before {
23
+ content: '';
24
+ position: absolute;
25
+ position-anchor: --selected-tree-item;
26
+ top: anchor(top);
27
+ height: anchor-size(height);
28
+ inset-inline-start: 0;
29
+ width: rem(1px);
30
+ background-color: var(--igd-accent);
31
+ transition: top 0.2s ease, height 0.2s ease;
32
+ display: none;
33
+ z-index: 1;
34
+ }
35
+
36
+ body.is-resizing &::before {
37
+ transition: none;
38
+ }
39
+ &::after {
40
+ content: '';
41
+ position: absolute;
42
+ width: rem(1px);
43
+ inset-inline-start: 0;
44
+ top: 0;
45
+ z-index: 0;
46
+ height: 100%;
47
+ background: light-dark(var(--ig-gray-200), var(--ig-gray-300));
48
+ }
49
+
50
+ &:has(igc-tree-item[selected])::before {
51
+ display: block;
52
+ }
50
53
  }
51
54
 
52
55
  /* Sidebar: only leaf items get selected, so item height = single row */
53
56
  igc-tree[data-variant='sidebar'] igc-tree-item[selected] {
54
- anchor-name: --selected-tree-item;
57
+ anchor-name: --selected-tree-item;
55
58
  }
56
59
 
57
60
  /* TOC: groups can be selected (h2 with h3 children); anchor to the label div
58
61
  so height tracks only the row, not the expanded children below */
59
62
  igc-tree[data-variant='toc'] igc-tree-item[selected] > [slot='label'] {
60
- anchor-name: --selected-tree-item;
63
+ anchor-name: --selected-tree-item;
61
64
  }
62
65
 
63
66
  igc-tree-item {
64
- --igc-tree-indentation-size: #{rem(20px)};
65
-
66
- --background: transparent;
67
- --foreground: light-dark(var(--ig-gray-600), var(--ig-gray-500));
68
- --background-selected: transparent;
69
- --background-active: transparent;
70
- --foreground-active: var(--igd-accent);
71
- --foreground-hover: var(--igd-accent);
72
- --background-disabled: transparent;
73
- --hover-color: transparent;
74
- --hover-selected-color: transparent;
75
- --background-active-selected: transparent;
76
- --foreground-selected: var(--igd-accent);
77
- --foreground-active-selected: var(--igd-accent);
78
-
79
- a {
80
- position: absolute;
81
- inset: 0;
82
- align-items: center;
83
- color: inherit;
84
- text-decoration: none;
85
- width: 100%;
86
- height: 100%;
87
-
88
- &:focus {
89
- outline: none;
90
- }
91
- }
92
-
93
- cursor: default;
94
-
95
- &:hover,
96
- &:focus {
97
- > a {
98
- color: var(--igd-accent);
99
- }
100
- }
67
+ --igc-tree-indentation-size: #{rem(20px)};
68
+ --background: transparent;
69
+ --foreground: light-dark(var(--ig-gray-600), var(--ig-gray-400));
70
+ --background-selected: transparent;
71
+ --background-active: transparent;
72
+ --foreground-active: var(--igd-accent);
73
+ --foreground-hover: var(--igd-accent);
74
+ --background-disabled: transparent;
75
+ --hover-color: transparent;
76
+ --hover-selected-color: transparent;
77
+ --background-active-selected: transparent;
78
+ --foreground-selected: var(--igd-accent);
79
+ --foreground-active-selected: var(--igd-accent);
80
+
81
+
82
+ a {
83
+ position: absolute;
84
+ inset: 0;
85
+ align-items: center;
86
+ color: inherit;
87
+ text-decoration: none;
88
+ width: 100%;
89
+ height: 100%;
90
+
91
+ &:focus {
92
+ outline: none;
93
+ }
94
+ }
95
+
96
+ cursor: default;
97
+
98
+ &:hover,
99
+ &:focus {
100
+ > a {
101
+ color: var(--igd-accent);
102
+ }
103
+ }
101
104
  }
102
105
 
103
106
  igc-tree-item::part(wrapper) {
104
- @include type-style('body-2') {
105
- margin-block: 0;
106
- };
107
- padding-inline-start: rem(24px);
108
- padding-inline-end: rem(8px);
107
+ @include type-style('body-2') {
108
+ margin-block: 0;
109
+ }
110
+ ;
111
+ padding-inline-start: rem(24px);
112
+ padding-inline-end: rem(8px);
109
113
  }
110
114
 
111
115
  igc-tree-item::part(focused) {
112
- box-shadow: none;
116
+ box-shadow: none;
113
117
  }
114
118
 
115
119
  igc-tree-item::part(indicator) {
116
- display: none;
120
+ display: none;
117
121
  }
118
122
 
119
123
  igc-tree-item::part(label) {
120
- width: 100%;
124
+ width: 100%;
125
+ max-height: 100%;
126
+ padding-block: rem(6px);
121
127
  }
122
128
 
123
- igc-tree-item[data-has-children] > [slot='label'] {
124
- display: flex;
125
- align-items: center;
126
- width: 100%;
129
+ igc-tree-item[data-has-children] {
130
+ > [slot='label'] {
131
+ display: flex;
132
+ align-items: center;
133
+ width: 100%;
134
+ }
127
135
  }
128
136
 
129
137
  .tree-expand-icon {
130
- margin-inline-start: auto;
131
- flex-shrink: 0;
132
- color: inherit;
133
- transform: rotate(-90deg);
134
- transition: transform 0.2s ease;
138
+ margin-inline-start: auto;
139
+ //margin-inline-end: rem(4px);
140
+ flex-shrink: 0;
141
+ color: inherit;
142
+ transform: rotate(-90deg);
143
+ transition: transform 0.2s ease;
135
144
  }
136
145
 
137
- igc-tree-item[aria-expanded='true'] .tree-expand-icon {
138
- transform: rotate(0deg);
139
- color: var(--igd-accent);
146
+ igc-tree-item[aria-expanded='false'] > [slot='label'] {
147
+ .tree-expand-icon {
148
+ color: var(--igd-accent);
149
+ }
150
+ }
151
+
152
+ igc-tree-item[aria-expanded='true'] > [slot='label'] {
153
+ .tree-expand-icon {
154
+ transform: rotate(0deg);
155
+ color: light-dark(var(--ig-gray-800), var(--ig-gray-300));
156
+ }
140
157
  }
141
158
 
142
159
  igc-tree-item[data-has-children][data-depth='0'] {
143
- --igc-tree-indentation-size: 0;
160
+ --igc-tree-indentation-size: 0;
144
161
  }
145
162
 
146
163
  igc-tree-item[data-has-children] {
147
- --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-50));
148
- --foreground-selected: light-dark(var(--ig-gray-900), var(--ig-gray-50));
149
- --foreground-active-selected: light-dark(var(--ig-gray-900), var(--ig-gray-50));
150
- --foreground-active: light-dark(var(--ig-gray-900), var(--ig-gray-50));
151
- --foreground-hover: light-dark(var(--ig-gray-900), var(--ig-gray-50));
164
+ --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-600));
165
+ --foreground-selected: light-dark(var(--ig-gray-900), var(--ig-gray-600));
166
+ --foreground-active-selected: light-dark(var(--ig-gray-900), var(--ig-gray-600));
167
+ --foreground-active: light-dark(var(--ig-gray-900), var(--ig-gray-50));
168
+ --foreground-hover: light-dark(var(--ig-gray-900), var(--ig-gray-50));
152
169
  }
153
170
 
154
- /* Hover accent applies to any linked item (leaf in sidebar, all items in TOC) */
155
- .docs-tree-link:hover ~ .docs-tree-label {
156
- color: var(--igd-accent);
171
+ .docs-tree-label {
172
+ white-space: normal;
157
173
  }
158
174
 
159
- igc-tree[data-variant='sidebar'] {
160
- igc-tree-item[data-has-children] {
161
- --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-50));
162
- --foreground-selected: light-dark(var(--ig-gray-900), var(--ig-gray-50));
163
- --foreground-active-selected: light-dark(var(--ig-gray-900), var(--ig-gray-50));
164
- --foreground-active: light-dark(var(--ig-gray-900), var(--ig-gray-50));
165
- --foreground-hover: light-dark(var(--ig-gray-900), var(--ig-gray-50));
166
- }
175
+ /* Hover accent applies to leaf items (sidebar) and all linked items (TOC) */
176
+ .docs-tree-link:hover ~ .docs-tree-label,
177
+ igc-tree-item:not([data-has-children]):hover .docs-tree-label {
178
+ color: var(--igd-accent);
167
179
  }
168
180
 
169
- igc-tree[data-variant='toc'] {
170
- /* No expand/collapse icons in the TOC — all items are links */
171
- .tree-expand-icon {
172
- display: none;
173
- }
181
+ igc-tree[data-variant='sidebar'] {
182
+ overflow: hidden;
183
+
184
+ igc-tree-item[data-has-children] {
185
+ --foreground: light-dark(var(--ig-gray-900), var(--ig-gray-600));
186
+ --foreground-selected: light-dark(var(--ig-gray-900), var(--ig-gray-600));
187
+ --foreground-active-selected: light-dark(var(--ig-gray-900), var(--ig-gray-600));
188
+ --foreground-active: light-dark(var(--ig-gray-900), var(--ig-gray-50));
189
+ --foreground-hover: light-dark(var(--ig-gray-900), var(--ig-gray-50));
190
+ }
174
191
  }
175
192
 
176
- /* TOC variant — active link highlighted by scroll-spy via aria-current="true". */
177
- igc-tree[data-variant='toc'] .docs-tree-link[aria-current='true'] {
178
- color: var(--igd-accent);
193
+ igc-tree[data-variant='toc'] {
194
+ /* TOC variant — active link highlighted by scroll-spy via aria-current="true". */
195
+ .docs-tree-link[aria-current='true'] {
196
+ color: var(--igd-accent);
197
+
198
+ + .docs-tree-label {
199
+ color: var(--igd-accent);
200
+ }
201
+ }
202
+
203
+ /* No expand/collapse icons in the TOC — all items are links */
204
+ .tree-expand-icon {
205
+ display: none;
206
+ }
179
207
  }
180
208
 
181
209
  /* Filter visibility — driven by <sidebar-filter>. */
182
210
  // Removing this will break the filter in the sidebar
183
211
  sidebar-filter[data-filtering] igc-tree[data-variant='sidebar'] igc-tree-item[data-path]:not([data-filter-match]) {
184
- display: none;
212
+ display: none;
185
213
  }
@@ -1,3 +1,4 @@
1
+ @use '../../styles/global/breakpoints' as *;
1
2
  @use 'igniteui-theming/sass/typography/functions' as *;
2
3
 
3
4
  /*
@@ -48,11 +49,19 @@
48
49
  }
49
50
  }
50
51
 
52
+ :global(.globalnav__mobile-menu) {
53
+ top: -1px;
54
+ }
55
+
51
56
  // Class names below come from the injected headerHtml / static fallback markup.
52
57
  // CSS Modules would hash them, breaking the match — :global() prevents that.
53
58
  :global(.globalnav__primary) {
54
- padding-inline: rem(17px);
59
+ padding-inline: rem(16px);
55
60
  border-bottom: var(--igd-app-outline) !important;
61
+
62
+ @media (max-width: #{$bp-tablet-max}) {
63
+ padding-inline-end: 0;
64
+ }
56
65
  }
57
66
 
58
67
  :global(.navbar-inverse) {
@@ -181,6 +190,12 @@
181
190
  padding: 0;
182
191
  }
183
192
 
193
+ :global(.globalnav__brand) {
194
+ @media (max-width: #{$bp-tablet-max}) {
195
+ margin-inline-start: 0;
196
+ }
197
+ }
198
+
184
199
  @media only screen and (min-width: 961px) {
185
200
  [data-mega-menu='true'] :global(.globalnav__primary) :global(.globalnav__wrapper) {
186
201
  position: static;
@@ -0,0 +1,19 @@
1
+ ---
2
+ import './LicenseIndicator.scss';
3
+
4
+ export interface Props {
5
+ /** 'premium' shows a purple Premium badge; 'opensource' shows a green Open Source badge; false/undefined hides the badge. */
6
+ license?: 'premium' | 'opensource' | false;
7
+ }
8
+
9
+ const { license } = Astro.props;
10
+ const label = license === 'premium' ? 'Premium' : 'Open Source';
11
+ ---
12
+
13
+ {license && (
14
+ <igc-badge class={`sidebar-badge ${license}`}>
15
+ <span>{label}</span>
16
+
17
+ {license === 'premium' && <igc-icon name="premium" collection="docs" class="sidebar-premium-icon" aria-hidden="true"></igc-icon>}
18
+ </igc-badge>
19
+ )}
@@ -0,0 +1,5 @@
1
+ @use 'igniteui-theming/sass/typography/functions' as *;
2
+
3
+ .sidebar-badge::part(base) {
4
+ padding-inline: rem(4px);
5
+ }
@@ -0,0 +1,96 @@
1
+ ---
2
+ /**
3
+ * MobileTocToggle
4
+ *
5
+ * Mobile-only sticky row rendered below the DocsSubHeader.
6
+ * Shows "On this page" with the current active heading and a chevron.
7
+ * Tapping it opens a dropdown containing the TOC links.
8
+ *
9
+ * Hidden on tablet and above — the full DocsToc sidebar is shown there.
10
+ */
11
+ import type { MarkdownHeading } from 'astro';
12
+ import DocsTree from '../DocsTree/DocsTree.astro';
13
+ import { headingsToTreeNodes, type TocConfig } from '../DocsToc/toTreeNodes';
14
+ import './MobileTocToggle.scss';
15
+
16
+ interface Props {
17
+ headings?: MarkdownHeading[];
18
+ tocConfig?: TocConfig;
19
+ label?: string;
20
+ }
21
+
22
+ const { headings = [], tocConfig, label = 'On this page' } = Astro.props;
23
+ const nodes = headingsToTreeNodes(headings, tocConfig);
24
+ ---
25
+
26
+ {nodes.length > 0 && (
27
+ <div class="mobile-toc">
28
+ <button
29
+ class="mobile-toc__trigger"
30
+ id="mobile-toc-trigger"
31
+ aria-expanded="false"
32
+ aria-controls="mobile-toc-dropdown"
33
+ >
34
+ <span class="mobile-toc__label">{label}</span>
35
+ <span class="mobile-toc__active" id="mobile-toc-active" aria-hidden="true"></span>
36
+ <svg class="mobile-toc__chevron" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
37
+ <polyline points="6 9 12 15 18 9"></polyline>
38
+ </svg>
39
+ </button>
40
+
41
+ <div class="mobile-toc__dropdown" id="mobile-toc-dropdown" aria-hidden="true">
42
+ <nav aria-label={label}>
43
+ <DocsTree nodes={nodes} variant="toc" />
44
+ </nav>
45
+ </div>
46
+ </div>
47
+ )}
48
+
49
+ <script>
50
+ function initMobileToc() {
51
+ const trigger = document.getElementById('mobile-toc-trigger');
52
+ const dropdown = document.getElementById('mobile-toc-dropdown');
53
+ const activeLabel = document.getElementById('mobile-toc-active');
54
+ if (!trigger || !dropdown) return;
55
+
56
+ // Toggle open/close
57
+ trigger.addEventListener('click', () => {
58
+ const isOpen = dropdown.getAttribute('aria-hidden') === 'false';
59
+ dropdown.setAttribute('aria-hidden', String(isOpen));
60
+ trigger.setAttribute('aria-expanded', String(!isOpen));
61
+ });
62
+
63
+ // Close on link click
64
+ dropdown.addEventListener('click', (e) => {
65
+ if ((e.target as Element | null)?.closest('a')) {
66
+ dropdown.setAttribute('aria-hidden', 'true');
67
+ trigger.setAttribute('aria-expanded', 'false');
68
+ }
69
+ });
70
+
71
+ // Close on Escape
72
+ document.addEventListener('keyup', (e) => {
73
+ if (e.key === 'Escape' && dropdown.getAttribute('aria-hidden') === 'false') {
74
+ dropdown.setAttribute('aria-hidden', 'true');
75
+ trigger.setAttribute('aria-expanded', 'false');
76
+ trigger.focus();
77
+ }
78
+ });
79
+
80
+ // Sync active heading text from the desktop TOC scroll-spy.
81
+ // DocsToc sets aria-current="true" on the active anchor — observe that.
82
+ const syncActive = () => {
83
+ if (!activeLabel) return;
84
+ const active = document.querySelector<HTMLAnchorElement>(
85
+ '#mobile-toc-dropdown a[aria-current="true"]'
86
+ );
87
+ activeLabel.textContent = active?.textContent?.trim() ?? '';
88
+ };
89
+
90
+ const observer = new MutationObserver(syncActive);
91
+ observer.observe(dropdown, { subtree: true, attributeFilter: ['aria-current'] });
92
+ syncActive();
93
+ }
94
+
95
+ document.addEventListener('astro:page-load', initMobileToc);
96
+ </script>
@@ -0,0 +1,74 @@
1
+ @use 'igniteui-theming/sass/typography' as *;
2
+
3
+ @layer components {
4
+
5
+ // Hidden by default. DocsLayout.scss reveals it on mobile-horizontal viewports.
6
+ .mobile-toc {
7
+ display: none;
8
+ }
9
+
10
+ .mobile-toc__trigger {
11
+ display: flex;
12
+ align-items: center;
13
+ width: 100%;
14
+ gap: rem(8px);
15
+ padding-inline: var(--igd-padding-md);
16
+ padding-block: rem(12px);
17
+ background: transparent;
18
+ border: none;
19
+ cursor: pointer;
20
+ color: light-dark(var(--ig-gray-700), var(--ig-gray-300));
21
+
22
+ &:focus-visible {
23
+ outline: none;
24
+ box-shadow: inset 0 0 0 1px var(--igd-accent);
25
+ }
26
+
27
+ &[aria-expanded='true'] .mobile-toc__chevron {
28
+ transform: rotate(180deg);
29
+ }
30
+ }
31
+
32
+ .mobile-toc__label {
33
+ @include type-style('body-2') { margin: 0; };
34
+ font-weight: 600;
35
+ flex-shrink: 0;
36
+ }
37
+
38
+ .mobile-toc__active {
39
+ @include type-style('body-2') { margin: 0; };
40
+ color: var(--igd-accent);
41
+ overflow: hidden;
42
+ text-overflow: ellipsis;
43
+ white-space: nowrap;
44
+ flex: 1;
45
+ text-align: start;
46
+
47
+ &:empty { display: none; }
48
+
49
+ &::before { content: '— '; }
50
+ }
51
+
52
+ .mobile-toc__chevron {
53
+ flex-shrink: 0;
54
+ margin-inline-start: auto;
55
+ transition: transform 200ms ease;
56
+ }
57
+
58
+ .mobile-toc__dropdown {
59
+ overflow: hidden;
60
+ max-height: 0;
61
+ transition: max-height 300ms ease;
62
+
63
+ &[aria-hidden='false'] {
64
+ max-height: 75dvh;
65
+ overflow-y: auto;
66
+ }
67
+
68
+ nav {
69
+ padding-inline: var(--igd-padding-md);
70
+ padding-block-end: rem(16px);
71
+ }
72
+ }
73
+
74
+ }