igniteui-astro-components 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/package.json +7 -5
- package/src/assets/icons/open-link-blank.svg +1 -1
- package/src/assets/logos/code-sandbox.svg +14 -0
- package/src/assets/logos/stackblitz.svg +13 -0
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +1 -1
- package/src/components/DocsSidebar/DocsSidebar.astro +15 -8
- package/src/components/DocsSidebar/DocsSidebar.scss +152 -2
- package/src/components/DocsSidebar/SidebarFilterInput.scss +7 -3
- package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
- package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
- package/src/components/DocsSubHeader/DocsSubHeader.astro +119 -302
- package/src/components/DocsSubHeader/DocsSubHeader.scss +111 -11
- package/src/components/DocsToc/DocsToc.astro +5 -2
- package/src/components/DocsToc/toTreeNodes.ts +1 -1
- package/src/components/DocsTree/DocsTree.astro +9 -0
- package/src/components/DocsTree/docs-tree.scss +139 -118
- package/src/components/GlobalFooter/GlobalFooter.astro +12 -62
- package/src/components/GlobalFooter/README.md +7 -10
- package/src/components/GlobalNavBar/GlobalNavBar.astro +8 -193
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -6
- package/src/components/GlobalNavBar/README.md +8 -15
- package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
- package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
- package/src/components/Search/Search.astro +34 -15
- package/src/components/Search/Search.scss +10 -42
- package/src/components/SearchAdvanced/SearchAdvanced.astro +202 -366
- package/src/components/SearchAdvanced/SearchAdvanced.scss +177 -0
- package/src/components/ThemingWidget/ThemingWidget.astro +5 -10
- package/src/components/mdx/ApiRef/README.md +1 -1
- package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
- package/src/components/mdx/DocsAside/DocsAside.scss +123 -35
- package/src/components/mdx/Sample/Sample.astro +55 -45
- package/src/components/mdx/Sample/Sample.scss +173 -30
- package/src/content.config.ts +1 -1
- package/src/integration.ts +25 -141
- package/src/layouts/DocsLayout/DocsLayout.astro +61 -20
- package/src/layouts/DocsLayout/DocsLayout.scss +51 -6
- package/src/lib/nav-helpers.ts +11 -4
- package/src/lib/sidebar/helpers.ts +14 -1
- package/src/lib/sidebar/types.ts +5 -7
- package/src/platform.ts +9 -16
- package/src/plugins/rehype-heading-anchors.ts +74 -0
- package/src/plugins/rehype-table-wrapper.ts +49 -0
- package/src/plugins/remark-docfx.ts +0 -368
- package/src/plugins/remark-env-vars.ts +110 -0
- package/src/plugins/remark-html-transforms.ts +32 -0
- package/src/plugins/remark-md-links.ts +75 -0
- package/src/scripts/sample-widget.ts +107 -116
- package/src/sidebar.ts +6 -7
- package/src/styles/global/_breakpoints.scss +4 -4
- package/src/styles/global/_code-blocks.scss +1 -1
- package/src/styles/global/_component-themes.scss +118 -18
- package/src/styles/global/_index.scss +2 -2
- package/src/styles/global/_markdown.scss +444 -32
- package/src/styles/global/_palette.scss +7 -0
- package/src/styles/global/_search-shared.scss +273 -0
- package/src/styles/global/_variables.scss +58 -3
- package/src/styles/theme.scss +80 -11
- package/src/virtual-modules.d.ts +1 -13
- package/src/assets/icons/copy-clipboard.svg +0 -3
- package/src/assets/icons/filter-clear.svg +0 -1
- package/src/styles/custom.scss +0 -20
|
@@ -2,56 +2,25 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* GlobalNavBar
|
|
4
4
|
*
|
|
5
|
-
* Renders the
|
|
6
|
-
* light DOM. Platform is driven by `siteMetaIntegration({ platform })` in
|
|
7
|
-
* astro.config.ts (exported from the virtual module) and can be overridden
|
|
8
|
-
* per-instance via the `theme` prop.
|
|
9
|
-
*
|
|
10
|
-
* Platforms:
|
|
11
|
-
* igniteui / angular / react / blazor / web-components / slingshot
|
|
12
|
-
* → IG global nav (infragistics.com). Prebuild path uses virtual module
|
|
13
|
-
* headerHtml. Static fallback renders the minimal nav server-side.
|
|
14
|
-
* appbuilder
|
|
15
|
-
* → AppBuilder nav (appbuilder.dev). Prebuild uses abHeaderHtml.
|
|
16
|
-
* Runtime fallback uses the XHR includeContent pattern.
|
|
5
|
+
* Renders the IG global navigation bar directly in the light DOM.
|
|
17
6
|
*
|
|
18
7
|
* CDN styles/scripts for each platform are already injected into <head> by
|
|
19
8
|
* getPlatformHead() in astro.config.ts — not repeated here.
|
|
20
9
|
*/
|
|
21
|
-
import {
|
|
22
|
-
platform as virtualPlatform,
|
|
23
|
-
navLang as virtualNavLang,
|
|
24
|
-
abPrefetched,
|
|
25
|
-
abHeaderHtml,
|
|
26
|
-
} from 'virtual:docs-template/nav-html';
|
|
27
10
|
import { fetchIgNav } from '../../lib/nav-helpers.ts';
|
|
28
11
|
import styles from './GlobalNavBar.module.scss';
|
|
29
|
-
import type { NavLang
|
|
12
|
+
import type { NavLang } from '../../platform.ts';
|
|
30
13
|
|
|
31
14
|
interface Props {
|
|
32
|
-
|
|
33
|
-
theme?: NavTheme;
|
|
34
|
-
/** Override the locale. Defaults to virtual module navLang. */
|
|
35
|
-
lang?: NavLang;
|
|
15
|
+
lang: NavLang;
|
|
36
16
|
}
|
|
37
17
|
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
// Props override the virtual module values (allows per-page overrides)
|
|
41
|
-
const resolvedPlatform = theme ?? virtualPlatform ?? 'igniteui';
|
|
42
|
-
const resolvedLang = (lang ?? virtualNavLang ?? 'en') as NavLang;
|
|
43
|
-
|
|
44
|
-
const isJa = resolvedLang === 'jp';
|
|
45
|
-
const isKr = resolvedLang === 'kr';
|
|
46
|
-
const isAppBuilder = resolvedPlatform === 'appbuilder';
|
|
47
|
-
// All IG-family platforms share the same global nav
|
|
48
|
-
const isIgPlatform = !isAppBuilder;
|
|
18
|
+
const { lang } = Astro.props as Props;
|
|
49
19
|
|
|
50
|
-
const
|
|
20
|
+
const resolvedLang = lang;
|
|
51
21
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
const igNav = isIgPlatform ? await fetchIgNav(resolvedLang) : null;
|
|
22
|
+
// Fetch nav HTML directly (cached per locale per build).
|
|
23
|
+
const igNav = await fetchIgNav(resolvedLang);
|
|
55
24
|
---
|
|
56
25
|
|
|
57
26
|
{/* ============================================================
|
|
@@ -60,159 +29,5 @@ const igNav = isIgPlatform ? await fetchIgNav(resolvedLang) : null;
|
|
|
60
29
|
============================================================ */}
|
|
61
30
|
<div class={styles.navBar} transition:persist="global-nav-bar">
|
|
62
31
|
{/* IG nav — fetched directly via fetchIgNav(); falls back to static markup */}
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
{/* Static fallback — rendered when the fetch is unavailable (offline build) */}
|
|
66
|
-
{isIgPlatform && !igNav?.prefetched && (
|
|
67
|
-
<header id="header" class="globalnav" data-nav-auto-init="false">
|
|
68
|
-
<section id="header-wrap" class="globalnav__container" data-default-height="175" data-sticky-height="60">
|
|
69
|
-
<section class="globalnav__primary clearfix">
|
|
70
|
-
<div class="globalnav__wrapper">
|
|
71
|
-
<div class="globalnav__brand">
|
|
72
|
-
<a href={igBase}>
|
|
73
|
-
<img class="globalnav__logo" src="https://static.infragistics.com/marketing/Website/products/ignite-ui/ignite-ui-logo.svg" alt="Infragistics Logo" />
|
|
74
|
-
</a>
|
|
75
|
-
</div>
|
|
76
|
-
<nav class="globalnav__nav">
|
|
77
|
-
{isJa ? (
|
|
78
|
-
<ul class="globalnav__menu">
|
|
79
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/products">製品</a></li>
|
|
80
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/community/blogs">ブログ</a></li>
|
|
81
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/support">サポート</a></li>
|
|
82
|
-
</ul>
|
|
83
|
-
) : isKr ? (
|
|
84
|
-
<ul class="globalnav__menu">
|
|
85
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/products">제품</a></li>
|
|
86
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/community/blogs">블로그</a></li>
|
|
87
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/support">지원</a></li>
|
|
88
|
-
</ul>
|
|
89
|
-
) : (
|
|
90
|
-
<ul class="globalnav__menu">
|
|
91
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/products">Products</a></li>
|
|
92
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/community/blogs">Blog</a></li>
|
|
93
|
-
<li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/support">Support</a></li>
|
|
94
|
-
</ul>
|
|
95
|
-
)}
|
|
96
|
-
</nav>
|
|
97
|
-
<div class="globalnav__overlay"></div>
|
|
98
|
-
</div>
|
|
99
|
-
</section>
|
|
100
|
-
</section>
|
|
101
|
-
</header>
|
|
102
|
-
)}
|
|
103
|
-
|
|
104
|
-
{/* ============================================================
|
|
105
|
-
AppBuilder nav
|
|
106
|
-
============================================================ */}
|
|
107
|
-
{isAppBuilder && (
|
|
108
|
-
<>
|
|
109
|
-
{/* Prebuild path — AB header HTML captured at build time */}
|
|
110
|
-
{abPrefetched && (
|
|
111
|
-
<>
|
|
112
|
-
<Fragment set:html={abHeaderHtml} />
|
|
113
|
-
<script is:inline>
|
|
114
|
-
window.addEventListener('load', function () {
|
|
115
|
-
// Fix language-bar links (depends on current page URL at runtime)
|
|
116
|
-
var langBar = document.querySelector('.mega-lang-bar');
|
|
117
|
-
if (langBar) {
|
|
118
|
-
langBar.innerHTML =
|
|
119
|
-
'<a class="mega-custom-icon mega-menu-link" href="#" aria-expanded="false" tabindex="0" aria-label="LangBar">' +
|
|
120
|
-
'<span class="mega-indicator" aria-hidden="true"></span></a>' +
|
|
121
|
-
'<ul class="mega-sub-menu"><li class="mega-menu-item" id="mega-menu-item-8148"><div class="wovn-languages">' +
|
|
122
|
-
'<a href="' + window.location.href.replace('/ja/help/', '/help/') + '" style="display:block;padding-left:10px;color:gray;font-weight:300;">English</a>' +
|
|
123
|
-
'<a href="' + window.location.href.replace('/help/', '/ja/help/') + '" style="display:block;padding-left:10px;color:gray;font-weight:300;">日本語</a>' +
|
|
124
|
-
'</div></li></ul>';
|
|
125
|
-
}
|
|
126
|
-
// Initialise mega menu
|
|
127
|
-
if (window.jQuery && typeof window.jQuery('.max-mega-menu').maxmegamenu === 'function') {
|
|
128
|
-
window.jQuery('.max-mega-menu').maxmegamenu();
|
|
129
|
-
}
|
|
130
|
-
// Search toggle
|
|
131
|
-
var searchIcon = document.querySelector('.mega-search .search-icon');
|
|
132
|
-
var searchInput = document.querySelector('.mega-search input[type=text]');
|
|
133
|
-
if (searchIcon) searchIcon.onclick = function () { _abSearchToggle(); };
|
|
134
|
-
if (searchInput) searchInput.onblur = function () { _abSearchToggle(); };
|
|
135
|
-
|
|
136
|
-
function _abSearchToggle() {
|
|
137
|
-
var form = document.querySelector('.mega-search');
|
|
138
|
-
var inp = document.querySelector('.mega-search input[type=text]');
|
|
139
|
-
if (!form) return;
|
|
140
|
-
if (form.classList.contains('mega-search-open')) {
|
|
141
|
-
form.classList.replace('mega-search-open', 'mega-search-closed');
|
|
142
|
-
if (inp) { inp.setAttribute('placeholder', ''); inp.value = ''; inp.setAttribute('tabindex', '0'); }
|
|
143
|
-
} else {
|
|
144
|
-
form.classList.replace('mega-search-closed', 'mega-search-open');
|
|
145
|
-
if (inp) { inp.setAttribute('placeholder', 'Search...'); inp.focus(); inp.setAttribute('tabindex', '-1'); }
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
</script>
|
|
150
|
-
</>
|
|
151
|
-
)}
|
|
152
|
-
|
|
153
|
-
{/*
|
|
154
|
-
Runtime fallback — XHR fetch of AB header at page load.
|
|
155
|
-
---------------------------------------------------------
|
|
156
|
-
This path executes when the build-time prefetch of
|
|
157
|
-
https://www.appbuilder.dev/header-footer-export was unavailable
|
|
158
|
-
(abPrefetched === false).
|
|
159
|
-
|
|
160
|
-
It fires a client-side XHR on window load and injects the returned
|
|
161
|
-
headerHtml into #ab-nav-container. The footerHtml is appended to
|
|
162
|
-
document.getElementById('footer'), which may conflict with the
|
|
163
|
-
GlobalFooter component rendered by CustomPageFrame.
|
|
164
|
-
|
|
165
|
-
Known downsides:
|
|
166
|
-
- Visible layout shift: header appears only after the page load event.
|
|
167
|
-
- Requires the client to reach appbuilder.dev at runtime (cross-origin).
|
|
168
|
-
- The footer injection target (#footer) is fragile and couples
|
|
169
|
-
this component to the DOM shape of GlobalFooter.
|
|
170
|
-
|
|
171
|
-
TODO: Consider removing this fallback entirely. If the build-time
|
|
172
|
-
prefetch is consistently reliable, this branch is never reached. A static
|
|
173
|
-
minimal fallback or a clear error state would be more predictable than a
|
|
174
|
-
delayed XHR-driven render.
|
|
175
|
-
*/}
|
|
176
|
-
{!abPrefetched && (
|
|
177
|
-
<>
|
|
178
|
-
<div id="ab-nav-container"></div>
|
|
179
|
-
<script is:inline>
|
|
180
|
-
(function () {
|
|
181
|
-
var includeContent = {
|
|
182
|
-
settings: {
|
|
183
|
-
url: 'https://www.appbuilder.dev/header-footer-export',
|
|
184
|
-
selector: '#header-container',
|
|
185
|
-
},
|
|
186
|
-
processInclude: function () {
|
|
187
|
-
var self = this;
|
|
188
|
-
var xhr = new XMLHttpRequest();
|
|
189
|
-
xhr.open('GET', self.settings.url, true);
|
|
190
|
-
xhr.onreadystatechange = function () {
|
|
191
|
-
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
192
|
-
try {
|
|
193
|
-
var data = JSON.parse(xhr.responseText);
|
|
194
|
-
var header = data.headerHtml || '';
|
|
195
|
-
var footer = data.footerHtml || '';
|
|
196
|
-
var container = document.getElementById('ab-nav-container');
|
|
197
|
-
if (container) container.innerHTML = header;
|
|
198
|
-
var footerEl = document.getElementById('footer');
|
|
199
|
-
if (footerEl) footerEl.innerHTML += footer;
|
|
200
|
-
} catch (e) {
|
|
201
|
-
/* no-op – nav unavailable */
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
xhr.send();
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
window.addEventListener('load', function () {
|
|
209
|
-
includeContent.processInclude();
|
|
210
|
-
});
|
|
211
|
-
})();
|
|
212
|
-
</script>
|
|
213
|
-
</>
|
|
214
|
-
)}
|
|
215
|
-
</>
|
|
216
|
-
)}
|
|
217
|
-
|
|
32
|
+
{igNav?.prefetched && <Fragment set:html={igNav.headerHtml} />}
|
|
218
33
|
</div>
|
|
@@ -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(
|
|
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) {
|
|
@@ -166,11 +175,6 @@
|
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
|
|
169
|
-
:global(.docfx-nav-header) {
|
|
170
|
-
display: flex;
|
|
171
|
-
justify-content: space-between;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
178
|
:global(.logo-breadcrumb) {
|
|
175
179
|
display: flex;
|
|
176
180
|
align-items: center;
|
|
@@ -186,6 +190,12 @@
|
|
|
186
190
|
padding: 0;
|
|
187
191
|
}
|
|
188
192
|
|
|
193
|
+
:global(.globalnav__brand) {
|
|
194
|
+
@media (max-width: #{$bp-tablet-max}) {
|
|
195
|
+
margin-inline-start: 0;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
189
199
|
@media only screen and (min-width: 961px) {
|
|
190
200
|
[data-mega-menu='true'] :global(.globalnav__primary) :global(.globalnav__wrapper) {
|
|
191
201
|
position: static;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# GlobalNavBar
|
|
2
2
|
|
|
3
|
-
Renders the
|
|
3
|
+
Renders the global navigation bar in the light DOM. Supports IG-family platforms (`angular`, `react`, `blazor`, `web-components`, `slingshot`, `igniteui`).
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
|
|
@@ -10,17 +10,15 @@ import GlobalNavBar from 'igniteui-astro-components/components/GlobalNavBar.astr
|
|
|
10
10
|
|
|
11
11
|
## Props
|
|
12
12
|
|
|
13
|
-
| Prop | Type |
|
|
14
|
-
|
|
15
|
-
| `
|
|
16
|
-
| `lang` | `NavLang` | virtual module value | Override the locale (`'en'` \| `'jp'` \| `'kr'`). |
|
|
13
|
+
| Prop | Type | Description |
|
|
14
|
+
|------|------|-------------|
|
|
15
|
+
| `lang` | `NavLang` | **Required.** Locale — `'en'` \| `'jp'` \| `'kr'`. |
|
|
17
16
|
|
|
18
|
-
`
|
|
17
|
+
`NavLang`: `'en' | 'jp' | 'kr'`
|
|
19
18
|
|
|
20
19
|
## Behaviour
|
|
21
20
|
|
|
22
|
-
-
|
|
23
|
-
- **Static fallback** — when pre-fetched HTML is unavailable (local dev), a minimal server-side nav is rendered.
|
|
21
|
+
- Fetches the IG header HTML at build time via `fetchIgNav(lang)`.
|
|
24
22
|
- The nav bar is marked `transition:persist="global-nav-bar"` so it does not re-render during Astro View Transitions navigation.
|
|
25
23
|
|
|
26
24
|
## Example
|
|
@@ -29,20 +27,15 @@ import GlobalNavBar from 'igniteui-astro-components/components/GlobalNavBar.astr
|
|
|
29
27
|
---
|
|
30
28
|
import GlobalNavBar from 'igniteui-astro-components/components/GlobalNavBar.astro';
|
|
31
29
|
---
|
|
32
|
-
|
|
33
|
-
<GlobalNavBar />
|
|
34
|
-
|
|
35
|
-
<!-- Override per-page -->
|
|
36
|
-
<GlobalNavBar theme="react" lang="en" />
|
|
30
|
+
<GlobalNavBar lang="en" />
|
|
37
31
|
```
|
|
38
32
|
|
|
39
33
|
## Configuration
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
`lang` is provided automatically by `DocsLayout` from the `navLang` value in the `virtual:docs-template/site-meta` virtual module, which is set in `astro.config.ts`:
|
|
42
36
|
|
|
43
37
|
```ts
|
|
44
38
|
createDocsSite({
|
|
45
|
-
platform: 'angular',
|
|
46
39
|
navLang: 'en',
|
|
47
40
|
// …
|
|
48
41
|
});
|
|
@@ -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
|
+
)}
|
|
@@ -17,10 +17,12 @@ import './Search.scss';
|
|
|
17
17
|
class="search-trigger"
|
|
18
18
|
aria-label="Search documentation"
|
|
19
19
|
title="Search (Ctrl+K)"
|
|
20
|
+
commandfor="search-dialog"
|
|
21
|
+
command="show-modal"
|
|
20
22
|
>
|
|
21
23
|
<igc-icon name="search" collection="docs" aria-hidden="true"></igc-icon>
|
|
22
24
|
<span class="search-trigger__label">Search</span>
|
|
23
|
-
<
|
|
25
|
+
<kbd class="search-trigger__hint" style="display:none;"><kbd>Ctrl</kbd><kbd>K</kbd></kbd>
|
|
24
26
|
</button>
|
|
25
27
|
|
|
26
28
|
<script>
|
|
@@ -30,7 +32,8 @@ import './Search.scss';
|
|
|
30
32
|
</script>
|
|
31
33
|
|
|
32
34
|
<dialog id="search-dialog" class="search-dialog" aria-label="Search">
|
|
33
|
-
<div class="search-
|
|
35
|
+
<div class="igd-search-shell">
|
|
36
|
+
<div class="igd-search-status" aria-live="polite"></div>
|
|
34
37
|
<div id="search-pagefind"></div>
|
|
35
38
|
</div>
|
|
36
39
|
</dialog>
|
|
@@ -43,13 +46,10 @@ import './Search.scss';
|
|
|
43
46
|
// State is kept on `window` so it survives re-executions.
|
|
44
47
|
const _w = window as any;
|
|
45
48
|
|
|
46
|
-
async function
|
|
49
|
+
async function loadAndMountPagefind() {
|
|
47
50
|
const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
|
|
48
51
|
if (!dialog) return;
|
|
49
52
|
|
|
50
|
-
// Load pagefind-ui.js only once — it's an IIFE that sets window.PagefindUI.
|
|
51
|
-
// Checking window.PagefindUI avoids appending a duplicate <script> tag whose
|
|
52
|
-
// onload never fires (cached scripts don't re-trigger onload).
|
|
53
53
|
if (!_w.PagefindUI) {
|
|
54
54
|
try {
|
|
55
55
|
const link = Object.assign(document.createElement('link'), {
|
|
@@ -69,12 +69,10 @@ import './Search.scss';
|
|
|
69
69
|
console.error('[Search] pagefind failed to load:', err);
|
|
70
70
|
const el = document.getElementById('search-pagefind');
|
|
71
71
|
if (el) el.textContent = 'Search index not available — run a production build first.';
|
|
72
|
-
dialog.showModal();
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
// Mount the UI if the container is empty (first open, or after DOM swap).
|
|
78
76
|
const container = document.getElementById('search-pagefind');
|
|
79
77
|
if (container && !container.firstChild) {
|
|
80
78
|
try {
|
|
@@ -91,21 +89,41 @@ import './Search.scss';
|
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
dialog.showModal();
|
|
95
92
|
requestAnimationFrame(() => {
|
|
96
93
|
(dialog.querySelector('input') as HTMLInputElement | null)?.focus();
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
async function openSearch() {
|
|
98
|
+
const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
|
|
99
|
+
if (!dialog) return;
|
|
100
|
+
await loadAndMountPagefind();
|
|
101
|
+
dialog.showModal();
|
|
102
|
+
}
|
|
103
|
+
|
|
103
104
|
if (!_w.__searchListeners) {
|
|
104
105
|
_w.__searchListeners = true;
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
107
|
+
function updateSearchHint() {
|
|
108
|
+
const hint = document.querySelector<HTMLElement>('kbd.search-trigger__hint');
|
|
109
|
+
if (!hint) return;
|
|
110
|
+
const isMac = /Mac|iPhone|iPod|iPad/i.test(navigator.userAgent);
|
|
111
|
+
const modKey = hint.querySelector('kbd');
|
|
112
|
+
if (modKey) modKey.textContent = isMac ? '\u2318' : 'Ctrl';
|
|
113
|
+
const btn = document.getElementById('search-trigger');
|
|
114
|
+
btn?.setAttribute('aria-keyshortcuts', isMac ? 'Meta+K' : 'Control+K');
|
|
115
|
+
btn?.setAttribute('title', isMac ? 'Search (\u2318K)' : 'Search (Ctrl+K)');
|
|
116
|
+
hint.style.display = '';
|
|
117
|
+
}
|
|
118
|
+
updateSearchHint();
|
|
119
|
+
|
|
120
|
+
// Declarative show-modal via commandfor fires a `command` event on the dialog —
|
|
121
|
+
// use it to load page find and focus the input.
|
|
122
|
+
document.addEventListener('command', async (e: Event) => {
|
|
123
|
+
const ce = e as CommandEvent;
|
|
124
|
+
if (ce.target instanceof HTMLDialogElement && ce.target.id === 'search-dialog') {
|
|
125
|
+
await loadAndMountPagefind();
|
|
126
|
+
}
|
|
109
127
|
});
|
|
110
128
|
|
|
111
129
|
// Keyboard shortcut
|
|
@@ -127,6 +145,7 @@ import './Search.scss';
|
|
|
127
145
|
document.addEventListener('astro:page-load', () => {
|
|
128
146
|
const dialog = document.getElementById('search-dialog') as HTMLDialogElement | null;
|
|
129
147
|
dialog?.close();
|
|
148
|
+
updateSearchHint();
|
|
130
149
|
});
|
|
131
150
|
}
|
|
132
151
|
</script>
|
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
@use '../../styles/global/
|
|
2
|
-
@use 'igniteui-theming/sass/typography' as *;
|
|
1
|
+
@use '../../styles/global/search-shared' as *;
|
|
3
2
|
|
|
4
|
-
.search-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
max-width: rem(330px);
|
|
9
|
-
display: flex;
|
|
10
|
-
height: 100%;
|
|
11
|
-
align-items: center;
|
|
3
|
+
.search-dialog {
|
|
4
|
+
@include search-dialog-base-styles;
|
|
5
|
+
background: var(--igd-layout-sections-bg);
|
|
6
|
+
color: inherit;
|
|
12
7
|
border: none;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
gap: rem(8px);
|
|
16
|
-
white-space: nowrap;
|
|
17
|
-
|
|
18
|
-
// Override native button styles
|
|
19
|
-
background-color: transparent;
|
|
20
|
-
box-shadow: none;
|
|
21
|
-
|
|
8
|
+
padding: 0;
|
|
9
|
+
|
|
22
10
|
&:focus-visible {
|
|
23
11
|
outline: none;
|
|
24
|
-
box-shadow: inset 0 0 0 1px var(--igd-accent);
|
|
25
12
|
}
|
|
26
|
-
}
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
margin-inline-start: auto;
|
|
36
|
-
|
|
37
|
-
span {
|
|
38
|
-
@include type-style('detail-1', false) {
|
|
39
|
-
margin: 0;
|
|
40
|
-
};
|
|
14
|
+
&::backdrop {
|
|
15
|
+
@include search-dialog-backdrop;
|
|
16
|
+
@include search-dialog-backdrop-open;
|
|
41
17
|
}
|
|
42
18
|
}
|
|
43
|
-
|
|
44
|
-
.search-trigger__label {
|
|
45
|
-
@include type-style('body-2') {
|
|
46
|
-
margin: 0;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
color: var(--ig-gray-600);
|
|
50
|
-
}
|