igniteui-astro-components 0.0.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +374 -0
  3. package/package.json +109 -0
  4. package/src/components/DocsSidebar/DocsSidebar.astro +99 -0
  5. package/src/components/DocsSidebar/README.md +166 -0
  6. package/src/components/DocsSidebar/SidebarFilterInput.astro +74 -0
  7. package/src/components/DocsSidebar/SidebarLabel.astro +40 -0
  8. package/src/components/DocsSidebar/sidebar-filter.ts +393 -0
  9. package/src/components/DocsSidebar/toTreeNodes.ts +66 -0
  10. package/src/components/DocsSubHeader/DocsSubHeader.astro +320 -0
  11. package/src/components/DocsSubHeader/README.md +74 -0
  12. package/src/components/DocsToc/DocsToc.astro +307 -0
  13. package/src/components/DocsToc/README.md +68 -0
  14. package/src/components/DocsToc/toTreeNodes.ts +57 -0
  15. package/src/components/DocsTree/DocsTree.astro +66 -0
  16. package/src/components/DocsTree/DocsTreeItem.astro +84 -0
  17. package/src/components/DocsTree/README.md +105 -0
  18. package/src/components/DocsTree/docs-tree.css +227 -0
  19. package/src/components/DocsTree/types.ts +47 -0
  20. package/src/components/GlobalFooter/GlobalFooter.astro +90 -0
  21. package/src/components/GlobalFooter/GlobalFooter.module.scss +23 -0
  22. package/src/components/GlobalFooter/README.md +35 -0
  23. package/src/components/GlobalNavBar/GlobalNavBar.astro +218 -0
  24. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +215 -0
  25. package/src/components/GlobalNavBar/README.md +49 -0
  26. package/src/components/MobileSidebarToggle/MobileSidebarToggle.astro +112 -0
  27. package/src/components/MobileSidebarToggle/README.md +31 -0
  28. package/src/components/Search/README.md +43 -0
  29. package/src/components/Search/Search.astro +222 -0
  30. package/src/components/ThemingWidget/README.md +35 -0
  31. package/src/components/ThemingWidget/ThemingWidget.astro +152 -0
  32. package/src/components/mdx/ApiLink/ApiLink.astro +121 -0
  33. package/src/components/mdx/ApiLink/README.md +68 -0
  34. package/src/components/mdx/ApiRef/ApiRef.astro +92 -0
  35. package/src/components/mdx/ApiRef/README.md +50 -0
  36. package/src/components/mdx/DocsAside/DocsAside.astro +86 -0
  37. package/src/components/mdx/DocsAside/README.md +66 -0
  38. package/src/components/mdx/DocsAside/icons/caution.svg +3 -0
  39. package/src/components/mdx/DocsAside/icons/danger.svg +3 -0
  40. package/src/components/mdx/DocsAside/icons/note.svg +3 -0
  41. package/src/components/mdx/DocsAside/icons/tip.svg +4 -0
  42. package/src/components/mdx/PlatformBlock/PlatformBlock.astro +24 -0
  43. package/src/components/mdx/PlatformBlock/README.md +57 -0
  44. package/src/components/mdx/Sample/README.md +59 -0
  45. package/src/components/mdx/Sample/Sample.astro +142 -0
  46. package/src/content-helper.ts +159 -0
  47. package/src/content.config.ts +17 -0
  48. package/src/index.ts +42 -0
  49. package/src/integration.ts +841 -0
  50. package/src/layouts/DocsLayout/DocsLayout.astro +307 -0
  51. package/src/layouts/DocsLayout/README.md +124 -0
  52. package/src/lib/nav-helpers.ts +155 -0
  53. package/src/lib/platform-context.ts +305 -0
  54. package/src/lib/sidebar/helpers.ts +81 -0
  55. package/src/lib/sidebar/types.ts +36 -0
  56. package/src/llms.ts +315 -0
  57. package/src/platform.ts +281 -0
  58. package/src/plugins/remark-docfx.ts +368 -0
  59. package/src/scripts/sample-widget.ts +516 -0
  60. package/src/sidebar.ts +167 -0
  61. package/src/styles/custom.scss +254 -0
  62. package/src/styles/ig-theme.scss +43 -0
  63. package/src/virtual-modules.d.ts +35 -0
@@ -0,0 +1,215 @@
1
+ /*
2
+ * GlobalNavBar — CSS Module styles
3
+ *
4
+ * Theming tokens (override from consumer CSS):
5
+ * --nav-bg header/navbar background (default: #222)
6
+ * --nav-color text / brand color (default: #fff)
7
+ * --nav-border bottom border color (default: #333)
8
+ * --nav-link nav link color (default: #fff)
9
+ * --nav-link-hover nav link hover color (default: #eee)
10
+ * --nav-btn-bg CTA button bg (default: #0099ff)
11
+ * --nav-btn-color CTA button text (default: #fff)
12
+ * --nav-btn-border CTA button border (default: #0099ff)
13
+ * --nav-btn-hover-color CTA button hover text (default: #0099ff)
14
+ * --nav-btn-hover-bg CTA button hover bg (default: transparent)
15
+ * --nav-height navbar height (default: auto)
16
+ */
17
+
18
+ .navBar {
19
+ --nav-bg: #222;
20
+ --nav-color: #fff;
21
+ --nav-border: #333;
22
+ --nav-link: #fff;
23
+ --nav-link-hover: #eee;
24
+ --nav-btn-bg: #0099ff;
25
+ --nav-btn-color: #fff;
26
+ --nav-btn-border: #0099ff;
27
+ --nav-btn-hover-color: #0099ff;
28
+ --nav-btn-hover-bg: transparent;
29
+ --nav-height: auto;
30
+ background: var(--nav-bg, inherit);
31
+ color: var(--nav-color, inherit);
32
+
33
+ // Element selectors are never hashed by CSS Modules — no :global() needed.
34
+ header {
35
+ position: fixed;
36
+ top: 0;
37
+ left: 0;
38
+ right: 0;
39
+ z-index: 1000;
40
+ font-family: aktiv-grotesk, sans-serif;
41
+
42
+ :global(.navbar) {
43
+ border-width: 0 0 1px;
44
+ border-radius: 0;
45
+ }
46
+ }
47
+
48
+ // Class names below come from the injected headerHtml / static fallback markup.
49
+ // CSS Modules would hash them, breaking the match — :global() prevents that.
50
+ :global(.navbar-inverse) {
51
+ background: var(--nav-bg, inherit);
52
+ min-height: 86px;
53
+ }
54
+
55
+ :global(.fixed_header) {
56
+ position: fixed;
57
+ width: 100%;
58
+ padding-bottom: 10px;
59
+ padding-top: 10px;
60
+ margin: 0;
61
+ top: 0;
62
+ z-index: 9999;
63
+ left: 0;
64
+ background-color: #fff;
65
+ }
66
+
67
+ :global(.navbar) {
68
+ margin-bottom: 0;
69
+ border-bottom-color: var(--nav-border, #333);
70
+ border: inset;
71
+ }
72
+
73
+ :global(.navbar-brand) {
74
+ display: flex;
75
+ align-items: center;
76
+ font-family: 'aktiv-grotesk', sans-serif;
77
+ color: var(--nav-color, #fff);
78
+ font-size: 18px;
79
+ padding: 0;
80
+
81
+ span {
82
+ color: var(--nav-color, #fff);
83
+ }
84
+ }
85
+
86
+ :global(.navbar-wrapper) {
87
+ display: flex;
88
+ justify-content: space-between;
89
+ align-items: center;
90
+ height: var(--nav-height, auto);
91
+ }
92
+
93
+ :global(.navbar) :global(.navbar-nav) {
94
+ display: inline-block;
95
+ }
96
+
97
+ :global(.navbar) :global(.nav.navbar-nav) {
98
+ width: 100%;
99
+ padding: 16px;
100
+ font-size: 0.75rem;
101
+ font-weight: 400;
102
+
103
+ li > a {
104
+ transition: all 0.25s ease-in-out;
105
+ text-align: center;
106
+ color: var(--nav-link, #fff);
107
+
108
+ &:hover,
109
+ &:focus {
110
+ color: var(--nav-link-hover, #eee);
111
+ background-color: transparent;
112
+ }
113
+ }
114
+
115
+ :global(li.active) > a {
116
+ background-color: transparent !important;
117
+ font-weight: 500;
118
+ }
119
+
120
+ :global(li.nav__cta) > a {
121
+ color: var(--nav-btn-color, #fff);
122
+ background-color: var(--nav-btn-bg, #0099ff);
123
+ text-transform: uppercase;
124
+ font-weight: bold;
125
+ font-size: inherit;
126
+ margin-left: 10px;
127
+ padding: 0.5em 1.5em;
128
+ border: 1px solid var(--nav-btn-border, #0099ff);
129
+ border-radius: 0;
130
+ transition: all 250ms ease-in-out;
131
+ white-space: nowrap;
132
+
133
+ &:hover,
134
+ &:focus {
135
+ color: var(--nav-btn-hover-color, #0099ff);
136
+ background-color: var(--nav-btn-hover-bg, transparent);
137
+ border-color: var(--nav-btn-border, #0099ff);
138
+ }
139
+ }
140
+ }
141
+
142
+ :global(.navbar-frameworks) {
143
+ display: flex;
144
+ align-items: center;
145
+
146
+ a {
147
+ padding-right: 8px;
148
+ color: #9d9d9d;
149
+ font-size: 0.875rem;
150
+ text-decoration: none;
151
+
152
+ &:hover,
153
+ &:focus {
154
+ color: #eee;
155
+ background-color: transparent;
156
+ text-decoration: none;
157
+ }
158
+ }
159
+ }
160
+
161
+ :global(.docfx-nav-header) {
162
+ display: flex;
163
+ justify-content: space-between;
164
+ }
165
+
166
+ :global(.logo-breadcrumb) {
167
+ display: flex;
168
+ align-items: center;
169
+ }
170
+
171
+ :global(.globalnav__logo) { max-height: 48px; }
172
+ :global(.globalnav__menu) { list-style: none; margin: 0; padding: 0; }
173
+
174
+ @media only screen and (min-width: 961px) {
175
+ [data-mega-menu="true"] :global(.globalnav__primary) :global(.globalnav__wrapper) {
176
+ position: static;
177
+ }
178
+
179
+ :global(.globalnav__wrapper) {
180
+ max-width: 100%;
181
+ margin: auto 15px;
182
+ padding: 0;
183
+ }
184
+
185
+ :global(.navbar) :global(.nav.navbar-nav) {
186
+ display: flex;
187
+ align-items: center;
188
+ padding: 0;
189
+ width: auto;
190
+ }
191
+ }
192
+
193
+ @media only screen and (max-width: 1200px) {
194
+ :global(.navbar-frameworks) { display: none; }
195
+ }
196
+
197
+ @media only screen and (max-width: 965px) {
198
+ :global(.navbar-frameworks) { display: none; }
199
+ }
200
+
201
+ @media only screen and (max-width: 767px) {
202
+ :global(.navbar-frameworks) {
203
+ display: flex;
204
+ justify-content: center;
205
+ padding-top: 10px;
206
+
207
+ a { font-size: 1rem !important; }
208
+ }
209
+
210
+ :global(.navbar) :global(.nav.navbar-nav) :global(li.nav__cta) > a {
211
+ margin-left: 0;
212
+ margin-top: 10px;
213
+ }
214
+ }
215
+ }
@@ -0,0 +1,49 @@
1
+ # GlobalNavBar
2
+
3
+ Renders the platform-appropriate global navigation bar in the light DOM. Supports IG-family platforms (`angular`, `react`, `blazor`, `web-components`, `slingshot`, `igniteui`) and AppBuilder.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import GlobalNavBar from 'igniteui-astro-components/components/GlobalNavBar.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ |------|------|---------|-------------|
15
+ | `theme` | `NavTheme` | virtual module value | Override the platform theme for this instance. |
16
+ | `lang` | `NavLang` | virtual module value | Override the locale (`'en'` \| `'jp'` \| `'kr'`). |
17
+
18
+ `NavTheme`: `'igniteui' | 'angular' | 'react' | 'blazor' | 'web-components' | 'slingshot' | 'appbuilder'`
19
+
20
+ ## Behaviour
21
+
22
+ - **Pre-build path** — when `siteMetaIntegration` has already fetched the header HTML, it is injected via `set:html`.
23
+ - **Static fallback** — when pre-fetched HTML is unavailable (local dev), a minimal server-side nav is rendered.
24
+ - The nav bar is marked `transition:persist="global-nav-bar"` so it does not re-render during Astro View Transitions navigation.
25
+
26
+ ## Example
27
+
28
+ ```astro
29
+ ---
30
+ import GlobalNavBar from 'igniteui-astro-components/components/GlobalNavBar.astro';
31
+ ---
32
+ <!-- Default: reads platform and locale from virtual module -->
33
+ <GlobalNavBar />
34
+
35
+ <!-- Override per-page -->
36
+ <GlobalNavBar theme="react" lang="en" />
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ Platform and locale are set once in `astro.config.ts` via `createDocsSite` / `siteMetaIntegration`:
42
+
43
+ ```ts
44
+ createDocsSite({
45
+ platform: 'angular',
46
+ navLang: 'en',
47
+ // …
48
+ });
49
+ ```
@@ -0,0 +1,112 @@
1
+ ---
2
+ /**
3
+ * MobileSidebarToggle
4
+ *
5
+ * Mobile-only fixed button that toggles the sidebar overlay.
6
+ * Props:
7
+ * label – visible button text (e.g. group name). Default: 'Components List'.
8
+ */
9
+ interface Props {
10
+ label?: string;
11
+ }
12
+ const { label = "Components List" } = Astro.props;
13
+ ---
14
+
15
+ <button
16
+ id="mobile-sidebar-toggle"
17
+ class="mobile-sidebar-toggle"
18
+ aria-expanded="false"
19
+ aria-controls="docs-sidebar"
20
+ aria-label={`Toggle ${label} sidebar`}
21
+ >
22
+ <span class="trigger-label">{label}</span>
23
+ <svg
24
+ class="mobile-sidebar-toggle_chevron"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ width="16"
27
+ height="16"
28
+ viewBox="0 0 24 24"
29
+ fill="none"
30
+ stroke="currentColor"
31
+ stroke-width="2.5"
32
+ stroke-linecap="round"
33
+ stroke-linejoin="round"
34
+ aria-hidden="true"
35
+ >
36
+ <polyline points="6 9 12 15 18 9"></polyline>
37
+ </svg>
38
+ </button>
39
+
40
+ <script>
41
+ document.addEventListener("click", (e) => {
42
+ const trigger = (e.target as Element).closest<HTMLElement>("#mobile-sidebar-toggle");
43
+ if (!trigger) return;
44
+ const expanded = trigger.getAttribute("aria-expanded") === "true";
45
+ trigger.setAttribute("aria-expanded", String(!expanded));
46
+ document.body.toggleAttribute("data-mobile-menu-expanded", !expanded);
47
+ });
48
+
49
+ document.addEventListener("keyup", (e) => {
50
+ if (e.key !== "Escape") return;
51
+ const trigger = document.getElementById("mobile-sidebar-toggle");
52
+ if (trigger && trigger.getAttribute("aria-expanded") === "true") {
53
+ trigger.setAttribute("aria-expanded", "false");
54
+ document.body.removeAttribute("data-mobile-menu-expanded");
55
+ trigger.focus();
56
+ }
57
+ });
58
+
59
+ document.addEventListener("astro:page-load", () => {
60
+ const trigger = document.getElementById("mobile-sidebar-toggle");
61
+ if (trigger) trigger.setAttribute("aria-expanded", "false");
62
+ document.body.removeAttribute("data-mobile-menu-expanded");
63
+ });
64
+ </script>
65
+
66
+ <style is:global>
67
+ .mobile-sidebar-toggle {
68
+ position: fixed;
69
+ top: var(--sl-nav-height);
70
+ inset-inline-start: 0;
71
+ z-index: calc(var(--sl-z-index-navbar) - 1);
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: space-between;
75
+ width: 100%;
76
+ height: var(--docs-mobile-toggle-height);
77
+ padding: 0 var(--sl-sidebar-pad-x, 1rem);
78
+ background: var(--sl-color-bg-sidebar);
79
+ border: none;
80
+ border-bottom: 1px solid var(--sl-color-hairline-shade);
81
+ cursor: pointer;
82
+ color: var(--sl-color-text-accent);
83
+ font-size: 0.7rem;
84
+ font-weight: 700;
85
+ letter-spacing: 0.08em;
86
+ text-transform: uppercase;
87
+ }
88
+
89
+ .mobile-sidebar-toggle_chevron {
90
+ flex-shrink: 0;
91
+ transition: transform 0.2s ease;
92
+ }
93
+
94
+ .mobile-sidebar-toggle[aria-expanded="true"]
95
+ .mobile-sidebar-toggle_chevron {
96
+ transform: rotate(180deg);
97
+ }
98
+
99
+ [data-mobile-menu-expanded] {
100
+ overflow: hidden;
101
+ }
102
+
103
+ @media (min-width: 50rem) {
104
+ .mobile-sidebar-toggle {
105
+ display: none;
106
+ }
107
+
108
+ [data-mobile-menu-expanded] {
109
+ overflow: auto;
110
+ }
111
+ }
112
+ </style>
@@ -0,0 +1,31 @@
1
+ # MobileSidebarToggle
2
+
3
+ Mobile-only fixed disclosure button that toggles the sidebar overlay. Hidden on desktop via CSS.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import MobileSidebarToggle from 'igniteui-astro-components/components/MobileSidebarToggle.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ |------|------|---------|-------------|
15
+ | `label` | `string` | `'Components List'` | Visible button text and aria-label suffix. Typically the active section name. |
16
+
17
+ ## Behaviour
18
+
19
+ - Sets `aria-expanded` and controls `#docs-sidebar` via `aria-controls`.
20
+ - The sidebar overlay open/close CSS is driven by a custom element or a script that toggles a class on the `<nav>`.
21
+
22
+ ## Example
23
+
24
+ ```astro
25
+ ---
26
+ import MobileSidebarToggle from 'igniteui-astro-components/components/MobileSidebarToggle.astro';
27
+ ---
28
+ <MobileSidebarToggle label="Components" />
29
+ ```
30
+
31
+ Used automatically inside `DocsLayout` when `hasSidebar={true}`.
@@ -0,0 +1,43 @@
1
+ # Search
2
+
3
+ Pagefind-powered full-text search modal. Renders a trigger button (`Ctrl+K`) and a `<dialog>` container that is populated client-side by the Pagefind UI library.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import Search from 'igniteui-astro-components/components/Search.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ None — the component is self-contained.
14
+
15
+ ## Behaviour
16
+
17
+ - The search index (`/pagefind/`) is generated by running `pagefind --site <outDir>` after a production build. This is wired automatically by `siteMetaIntegration`.
18
+ - In development the button renders but the dynamic Pagefind import resolves as a no-op — no runtime errors.
19
+ - Keyboard shortcut: `Ctrl+K` / `⌘K` to open, `Escape` to close.
20
+
21
+ ## Example
22
+
23
+ `Search` is included automatically inside `DocsSubHeader` / `DocsLayout`. Mount it directly if you build a custom header:
24
+
25
+ ```astro
26
+ ---
27
+ import Search from 'igniteui-astro-components/components/Search.astro';
28
+ ---
29
+ <Search />
30
+ ```
31
+
32
+ ## Build setup
33
+
34
+ Ensure Pagefind runs after `astro build`:
35
+
36
+ ```json
37
+ // package.json
38
+ {
39
+ "scripts": {
40
+ "build": "astro build && pagefind --site dist"
41
+ }
42
+ }
43
+ ```
@@ -0,0 +1,222 @@
1
+ ---
2
+ /**
3
+ * Search
4
+ *
5
+ * Pagefind-powered full-text search modal.
6
+ * The search index (/pagefind/) is generated by `pagefind --site <outDir>`
7
+ * at the end of every production build (wired in siteMetaIntegration).
8
+ *
9
+ * In development the button is rendered but the dynamic import will 404
10
+ * gracefully — no errors surface to the user.
11
+ */
12
+ ---
13
+
14
+ <button
15
+ id="search-trigger"
16
+ class="search-trigger"
17
+ aria-label="Search documentation"
18
+ title="Search (Ctrl+K)"
19
+ >
20
+ <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"
21
+ fill="none" stroke="currentColor" stroke-width="2"
22
+ stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
23
+ <circle cx="11" cy="11" r="8"/>
24
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
25
+ </svg>
26
+ <span class="search-trigger-hint">Ctrl+K</span>
27
+ </button>
28
+
29
+ <dialog id="search-dialog" class="search-dialog" aria-label="Search">
30
+ <div class="search-dialog-inner">
31
+ <div id="search-pagefind"></div>
32
+ </div>
33
+ </dialog>
34
+
35
+ <script>
36
+ // BASE_URL accounts for non-root deployments, e.g. /products/ignite-ui-angular/...
37
+ const base = import.meta.env.BASE_URL.replace(/\/$/, '');
38
+
39
+ // With ClientRouter, this script re-runs on every navigation.
40
+ // State is kept on `window` so it survives re-executions.
41
+ const _w = window as any;
42
+
43
+ async function openSearch() {
44
+ const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
45
+ if (!dialog) return;
46
+
47
+ // Load pagefind-ui.js only once — it's an IIFE that sets window.PagefindUI.
48
+ // Checking window.PagefindUI avoids appending a duplicate <script> tag whose
49
+ // onload never fires (cached scripts don't re-trigger onload).
50
+ if (!_w.PagefindUI) {
51
+ try {
52
+ const link = Object.assign(document.createElement('link'), {
53
+ rel: 'stylesheet',
54
+ href: `${base}/pagefind/pagefind-ui.css`,
55
+ });
56
+ document.head.appendChild(link);
57
+
58
+ await new Promise<void>((resolve, reject) => {
59
+ const s = document.createElement('script');
60
+ s.src = `${base}/pagefind/pagefind-ui.js`;
61
+ s.onload = () => resolve();
62
+ s.onerror = () => reject(new Error('Failed to load pagefind-ui.js'));
63
+ document.head.appendChild(s);
64
+ });
65
+ } catch (err) {
66
+ console.error('[Search] pagefind failed to load:', err);
67
+ const el = document.getElementById('search-pagefind');
68
+ if (el) el.textContent = 'Search index not available — run a production build first.';
69
+ dialog.showModal();
70
+ return;
71
+ }
72
+ }
73
+
74
+ // Mount the UI if the container is empty (first open, or after DOM swap).
75
+ const container = document.getElementById('search-pagefind');
76
+ if (container && !container.firstChild) {
77
+ try {
78
+ new _w.PagefindUI({
79
+ element: '#search-pagefind',
80
+ showSubResults: true,
81
+ showImages: false,
82
+ resetStyles: false,
83
+ baseUrl: base || '/',
84
+ bundlePath: `${base}/pagefind/`,
85
+ });
86
+ } catch (err) {
87
+ console.error('[Search] PagefindUI init failed:', err);
88
+ }
89
+ }
90
+
91
+ dialog.showModal();
92
+ requestAnimationFrame(() => {
93
+ (dialog.querySelector('input') as HTMLInputElement | null)?.focus();
94
+ });
95
+ }
96
+
97
+ // All listeners go on `document` so they survive ClientRouter DOM swaps.
98
+ // The window flag ensures they are registered only once (script runs once,
99
+ // but guard is here for safety in case the behaviour changes).
100
+ if (!_w.__searchListeners) {
101
+ _w.__searchListeners = true;
102
+
103
+ // Button click — delegate so the listener survives trigger DOM replacement.
104
+ document.addEventListener('click', (e) => {
105
+ if ((e.target as Element | null)?.closest('#search-trigger')) openSearch();
106
+ });
107
+
108
+ // Keyboard shortcut
109
+ document.addEventListener('keydown', (e: KeyboardEvent) => {
110
+ if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
111
+ e.preventDefault();
112
+ const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
113
+ if (dialog?.open) dialog.close(); else openSearch();
114
+ }
115
+ });
116
+
117
+ // Backdrop click closes the dialog
118
+ document.addEventListener('click', (e: MouseEvent) => {
119
+ const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
120
+ if (dialog && e.target === dialog) dialog.close();
121
+ });
122
+
123
+ // Close on navigation
124
+ document.addEventListener('astro:page-load', () => {
125
+ const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
126
+ dialog?.close();
127
+ });
128
+ }
129
+ </script>
130
+
131
+ <style is:global>
132
+ /* ── Trigger button ─────────────────────────────────────────────────────── */
133
+
134
+ .search-trigger {
135
+ width: 10rem;
136
+ display: flex;
137
+ align-items: center;
138
+ gap: 0.4rem;
139
+ padding: 0.25rem 0.5rem;
140
+ border: 1px solid var(--sl-color-hairline-shade);
141
+ border-radius: 0.375rem;
142
+ background: var(--sl-color-bg);
143
+ color: var(--sl-color-gray-3);
144
+ font-size: 0.75rem;
145
+ cursor: pointer;
146
+ white-space: nowrap;
147
+ transition: border-color 0.15s, color 0.15s;
148
+ }
149
+
150
+ .search-trigger:hover {
151
+ border-color: var(--sl-color-accent);
152
+ color: var(--sl-color-accent);
153
+ }
154
+
155
+ .search-trigger-hint {
156
+ font-size: 0.65rem;
157
+ opacity: 0.7;
158
+ }
159
+
160
+ @media (max-width: 50rem) {
161
+ .search-trigger-hint { display: none; }
162
+ .search-trigger { border: none; background: none; padding: 0.25rem; }
163
+ }
164
+
165
+ /* ── Modal dialog ───────────────────────────────────────────────────────── */
166
+
167
+ .search-dialog {
168
+ position: fixed;
169
+ inset: 0;
170
+ margin: 5rem auto auto;
171
+ width: 90%;
172
+ max-width: 40rem;
173
+ max-height: calc(100vh - 8rem);
174
+ padding: 0;
175
+ border: 1px solid var(--sl-color-hairline-shade);
176
+ border-radius: 0.5rem;
177
+ background: var(--sl-color-bg);
178
+ box-shadow: var(--sl-shadow-lg);
179
+ overflow: hidden;
180
+ }
181
+
182
+ .search-dialog::backdrop {
183
+ background: rgba(0, 0, 0, 0.5);
184
+ backdrop-filter: blur(2px);
185
+ }
186
+
187
+ .search-dialog-inner {
188
+ overflow-y: auto;
189
+ max-height: calc(100vh - 8rem);
190
+ }
191
+
192
+ /* ── Pagefind UI overrides — map to --sl-* tokens ───────────────────────── */
193
+
194
+ .search-dialog {
195
+ --pagefind-ui-scale: 0.9;
196
+ --pagefind-ui-primary: var(--sl-color-accent);
197
+ --pagefind-ui-text: var(--sl-color-text);
198
+ --pagefind-ui-background: var(--sl-color-bg);
199
+ --pagefind-ui-border: var(--sl-color-hairline-shade);
200
+ --pagefind-ui-tag: var(--sl-color-bg-sidebar);
201
+ --pagefind-ui-border-width: 1px;
202
+ --pagefind-ui-border-radius: 0.375rem;
203
+ --pagefind-ui-font: inherit;
204
+ }
205
+
206
+ /* Remove pagefind's built-in margin/padding on the wrapper */
207
+ #search-pagefind .pagefind-ui {
208
+ padding: 0.75rem;
209
+ }
210
+
211
+ #search-pagefind .pagefind-ui__search-input {
212
+ border-radius: 0.375rem;
213
+ }
214
+
215
+ #search-pagefind .pagefind-ui__result {
216
+ border-top: 1px solid var(--sl-color-hairline);
217
+ }
218
+
219
+ #search-pagefind .pagefind-ui__result-link {
220
+ color: var(--sl-color-accent);
221
+ }
222
+ </style>
@@ -0,0 +1,35 @@
1
+ # ThemingWidget
2
+
3
+ Renders the `<igniteui-theming-widget>` web component that lets readers switch the component theme live inside embedded sample iframes.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import ThemingWidget from 'igniteui-astro-components/components/ThemingWidget.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ |------|------|---------|-------------|
15
+ | `language` | `NavLang` | `'en'` | Locale passed to the web component (`'en'` \| `'jp'` \| `'kr'`). |
16
+
17
+ ## Behaviour
18
+
19
+ - Renders nothing when `themeApiUrl` is absent from the environment config.
20
+ - The widget container starts hidden and is revealed client-side only when at least one themeable `<iframe>` is detected on the page.
21
+ - Forwards `themeChange` events to all themeable frames via `postMessage`.
22
+ - Re-initialises on Astro View Transitions navigation (`astro:page-load`).
23
+
24
+ ## Environment variable
25
+
26
+ `themeApiUrl` is resolved at build time from `environment.json` by `siteMetaIntegration` and exposed through the `virtual:docs-template/nav-html` virtual module.
27
+
28
+ ## Example
29
+
30
+ ```astro
31
+ ---
32
+ import ThemingWidget from 'igniteui-astro-components/components/ThemingWidget.astro';
33
+ ---
34
+ <ThemingWidget language="en" />
35
+ ```