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,66 @@
1
+ /**
2
+ * Adapter: SidebarEntry[] → TreeNode[] for the shared DocsTree component.
3
+ *
4
+ * Preserves the data-* attributes the <sidebar-filter> custom element
5
+ * relies on:
6
+ * • data-path (every item)
7
+ * • data-group-key (groups only)
8
+ * • data-label (every item)
9
+ * • data-slug (leaves only)
10
+ *
11
+ * SSR active state and group auto-expansion use the pure helpers from
12
+ * `src/lib/sidebar/helpers.ts`.
13
+ */
14
+
15
+ import type { TreeNode } from '../DocsTree/types';
16
+ import type { SidebarEntry } from '../../lib/sidebar/types';
17
+ import { isGroup, isInitiallyOpen, joinPath, normalizeSlug } from '../../lib/sidebar/helpers';
18
+
19
+ const base = import.meta.env.BASE_URL.replace(/\/$/, '');
20
+
21
+ const linkHref = (slug: string): string => {
22
+ const normalized = normalizeSlug(slug);
23
+ return normalized ? `${base}/${normalized}/` : `${base}/`;
24
+ };
25
+
26
+ const toNode = (
27
+ entry: SidebarEntry,
28
+ ancestors: string[],
29
+ currentSlug: string,
30
+ ): TreeNode => {
31
+ const path = joinPath(ancestors, entry.label);
32
+
33
+ if (isGroup(entry)) {
34
+ return {
35
+ id: path,
36
+ label: entry.label,
37
+ expanded: isInitiallyOpen(entry, currentSlug) || undefined,
38
+ children: entry.items.map((child) =>
39
+ toNode(child, [...ancestors, entry.label], currentSlug),
40
+ ),
41
+ itemData: {
42
+ path,
43
+ groupKey: path,
44
+ label: entry.label,
45
+ },
46
+ };
47
+ }
48
+
49
+ return {
50
+ id: normalizeSlug(entry.slug),
51
+ label: entry.label,
52
+ href: linkHref(entry.slug),
53
+ itemData: {
54
+ path,
55
+ label: entry.label,
56
+ slug: entry.slug,
57
+ },
58
+ linkAttrs: entry.attrs,
59
+ meta: entry.badge ? { badge: entry.badge } : undefined,
60
+ };
61
+ };
62
+
63
+ export const toTreeNodes = (
64
+ entries: SidebarEntry[],
65
+ currentSlug: string,
66
+ ): TreeNode[] => entries.map((entry) => toNode(entry, [], currentSlug));
@@ -0,0 +1,320 @@
1
+ ---
2
+ /**
3
+ * DocsSubHeader
4
+ *
5
+ * A secondary fixed header bar rendered below the GlobalNavBar.
6
+ *
7
+ * Positioning (set in DocsLayout / custom.css):
8
+ * --docs-global-nav-height height of the GlobalNavBar above (default 86px)
9
+ * --docs-subheader-height height of this bar (default 40px)
10
+ */
11
+ import { platform as virtualPlatform } from 'virtual:docs-template/nav-html';
12
+ import { productLinks, sidebar as sidebarData, title as siteTitle } from 'virtual:docs-template/site-meta';
13
+ import Search from '../Search/Search.astro';
14
+ import type { SidebarEntry } from '../../lib/sidebar/types';
15
+ import { getBreadcrumb } from '../../lib/sidebar/helpers';
16
+
17
+ interface ProductLink {
18
+ label: string;
19
+ href: string;
20
+ platform?: string;
21
+ }
22
+
23
+ interface Props {
24
+ /** Fallback title if the slug is not present in the sidebar tree. */
25
+ pageTitle?: string | null;
26
+ /** Current page slug — used to derive the breadcrumb from the sidebar tree. */
27
+ currentSlug?: string;
28
+ /**
29
+ * Override the site title shown on the left. Defaults to the virtual module value.
30
+ * Useful when consuming without `siteMetaIntegration`.
31
+ */
32
+ siteTitle?: string;
33
+ /**
34
+ * Override the cross-product navigation links. Defaults to the virtual module value.
35
+ * Useful when consuming without `siteMetaIntegration`.
36
+ */
37
+ productLinks?: ProductLink[];
38
+ /**
39
+ * Override the sidebar tree used for breadcrumb generation.
40
+ * Defaults to the virtual module value.
41
+ */
42
+ sidebarItems?: SidebarEntry[];
43
+ }
44
+
45
+ const { pageTitle = '', currentSlug = '', siteTitle: siteTitleProp, productLinks: productLinksProp, sidebarItems } = Astro.props;
46
+ const resolvedSiteTitle = siteTitleProp ?? siteTitle;
47
+ const currentPlatform = virtualPlatform ?? null;
48
+ const resolvedLinks = (productLinksProp ?? productLinks) as ProductLink[];
49
+ const filteredLinks = resolvedLinks.filter((l: ProductLink) => l.platform !== currentPlatform);
50
+
51
+ // Breadcrumb of sidebar labels for the current page (root group dropped),
52
+ // ending with the active item's own sidebar label. Falls back to `pageTitle`
53
+ // if the slug is not in the sidebar tree.
54
+ const resolvedSidebar = (sidebarItems ?? sidebarData) as SidebarEntry[];
55
+ const sidebarCrumbs = currentSlug ? getBreadcrumb(resolvedSidebar, currentSlug) : [];
56
+ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitle] : []);
57
+ ---
58
+
59
+ <docs-subheader-menu>
60
+ <div class="docs-subheader">
61
+
62
+ <!-- Left: title area, takes all free space -->
63
+ <div class="subheader-context">
64
+ {resolvedSiteTitle && <span class="subheader-site-title">{resolvedSiteTitle}</span>}
65
+ {crumbs.map((label, i) => (
66
+ <>
67
+ <span class="subheader-sep" aria-hidden="true">{i === 0 ? '-' : '/'}</span>
68
+ <span class="subheader-crumb" title={label}>{label}</span>
69
+ </>
70
+ ))}
71
+ </div>
72
+
73
+ <!-- Search -->
74
+ <Search />
75
+
76
+ <!-- Right: product links. Desktop: flex row. Mobile: absolute dropdown. -->
77
+ <div class="subheader-right" id="docs-subheader-panel">
78
+ {filteredLinks.length > 0 && (
79
+ <div class="subheader-links">
80
+ {filteredLinks.map((link, i) => (
81
+ <>
82
+ {i > 0 && <span class="product-sep" aria-hidden="true">|</span>}
83
+ <a href={link.href} class="product-link">{link.label}</a>
84
+ </>
85
+ ))}
86
+ </div>
87
+ )}
88
+ </div>
89
+
90
+ <!-- Mobile toggle (hidden on desktop) -->
91
+ <button
92
+ class="subheader-toggle"
93
+ data-docs-toggle
94
+ aria-expanded="false"
95
+ aria-controls="docs-subheader-panel"
96
+ aria-label="Toggle navigation"
97
+ >
98
+ <svg class="icon-open" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
99
+ <line x1="3" y1="6" x2="21" y2="6" />
100
+ <line x1="3" y1="12" x2="21" y2="12" />
101
+ <line x1="3" y1="18" x2="21" y2="18" />
102
+ </svg>
103
+ <svg class="icon-close" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
104
+ <line x1="18" y1="6" x2="6" y2="18" />
105
+ <line x1="6" y1="6" x2="18" y2="18" />
106
+ </svg>
107
+ </button>
108
+
109
+ </div>
110
+ </docs-subheader-menu>
111
+
112
+ <script>
113
+ if (!customElements.get('docs-subheader-menu')) {
114
+ class DocsSubHeaderMenu extends HTMLElement {
115
+ connectedCallback() {
116
+ const btn = this.querySelector<HTMLButtonElement>('[data-docs-toggle]');
117
+ if (!btn) return;
118
+
119
+ const setExpanded = (expanded: boolean) => {
120
+ this.setAttribute('aria-expanded', String(expanded));
121
+ btn.setAttribute('aria-expanded', String(expanded));
122
+ };
123
+
124
+ btn.addEventListener('click', () => {
125
+ setExpanded(this.getAttribute('aria-expanded') !== 'true');
126
+ });
127
+
128
+ document.addEventListener('keyup', (e: KeyboardEvent) => {
129
+ if (e.key === 'Escape' && this.getAttribute('aria-expanded') === 'true') {
130
+ setExpanded(false);
131
+ btn.focus();
132
+ }
133
+ });
134
+
135
+ this.addEventListener('focusout', (e: FocusEvent) => {
136
+ if (!this.contains(e.relatedTarget as Node)) setExpanded(false);
137
+ });
138
+
139
+ document.addEventListener('click', (e: MouseEvent) => {
140
+ if (!this.contains(e.target as Node)) setExpanded(false);
141
+ });
142
+ }
143
+ }
144
+
145
+ customElements.define('docs-subheader-menu', DocsSubHeaderMenu);
146
+ }
147
+ </script>
148
+
149
+ <style>
150
+ docs-subheader-menu {
151
+ display: contents;
152
+ }
153
+
154
+ /* ── Fixed bar ─────────────────────────────────────────────────────────── */
155
+
156
+ .docs-subheader {
157
+ position: fixed;
158
+ inset-inline-start: 0;
159
+ inset-block-start: var(--docs-global-nav-height, 4.7rem);
160
+ width: 100%;
161
+ height: var(--docs-subheader-height, 2.5rem);
162
+ z-index: calc(var(--sl-z-index-navbar) - 1);
163
+ display: flex;
164
+ flex-direction: row;
165
+ align-items: center;
166
+ gap: 0.75rem;
167
+ padding-inline: 1rem;
168
+ background-color: var(--sl-color-bg-nav);
169
+ border-bottom: 1px solid var(--sl-color-hairline-shade);
170
+ overflow: visible;
171
+ }
172
+
173
+ /* ── Context (left) ────────────────────────────────────────────────────── */
174
+
175
+ .subheader-context {
176
+ flex: 1;
177
+ min-width: 0;
178
+ display: flex;
179
+ flex-direction: row;
180
+ align-items: center;
181
+ gap: 0.375rem;
182
+ overflow: hidden;
183
+ }
184
+
185
+ .subheader-site-title {
186
+ flex-shrink: 0;
187
+ font-size: 0.875rem;
188
+ font-weight: 600;
189
+ color: var(--sl-color-text-accent);
190
+ white-space: nowrap;
191
+ }
192
+
193
+ .subheader-page-title {
194
+ font-size: 0.875rem;
195
+ color: var(--sl-color-text);
196
+ white-space: nowrap;
197
+ overflow: hidden;
198
+ text-overflow: ellipsis;
199
+ }
200
+
201
+ .subheader-crumb {
202
+ flex-shrink: 0;
203
+ font-size: 0.875rem;
204
+ color: var(--sl-color-gray-4);
205
+ white-space: nowrap;
206
+ overflow: hidden;
207
+ text-overflow: ellipsis;
208
+ max-width: 14rem;
209
+ }
210
+
211
+ .subheader-sep {
212
+ flex-shrink: 0;
213
+ color: var(--sl-color-gray-3);
214
+ font-size: 0.875rem;
215
+ user-select: none;
216
+ }
217
+
218
+ /* ── Right side: links ──────────────────────────────────────────────────── */
219
+
220
+ .subheader-right {
221
+ flex-shrink: 0;
222
+ display: flex;
223
+ flex-direction: row;
224
+ align-items: center;
225
+ gap: 0.5rem;
226
+ }
227
+
228
+ .subheader-links {
229
+ display: flex;
230
+ flex-direction: row;
231
+ align-items: center;
232
+ flex-wrap: nowrap;
233
+ gap: 0;
234
+ }
235
+
236
+ .product-link {
237
+ font-size: 0.75rem;
238
+ color: var(--sl-color-gray-2);
239
+ text-decoration: none;
240
+ white-space: nowrap;
241
+ padding-inline: 0.25rem;
242
+ line-height: 1;
243
+ transition: color 0.15s;
244
+ }
245
+
246
+ .product-link:hover,
247
+ .product-link:focus-visible {
248
+ color: var(--sl-color-text-accent);
249
+ text-decoration: underline;
250
+ }
251
+
252
+ .product-sep {
253
+ flex-shrink: 0;
254
+ font-size: 0.6875rem;
255
+ color: var(--sl-color-gray-4);
256
+ padding-inline: 0.125rem;
257
+ line-height: 1;
258
+ user-select: none;
259
+ }
260
+
261
+ /* ── Mobile toggle (hidden on desktop) ─────────────────────────────────── */
262
+
263
+ .subheader-toggle {
264
+ display: none;
265
+ flex-shrink: 0;
266
+ padding: 0.25rem;
267
+ background: none;
268
+ border: none;
269
+ border-radius: 0.25rem;
270
+ color: var(--sl-color-text);
271
+ cursor: pointer;
272
+ line-height: 0;
273
+ }
274
+
275
+ /* ══ Mobile (≤ 50rem) ══════════════════════════════════════════════════════ */
276
+
277
+ @media (max-width: 50rem) {
278
+ .subheader-right {
279
+ display: none;
280
+ position: absolute;
281
+ top: 100%;
282
+ left: 0;
283
+ right: 0;
284
+ flex-direction: column;
285
+ align-items: stretch;
286
+ gap: 0.5rem;
287
+ padding: 0.75rem 1rem;
288
+ background-color: var(--sl-color-bg-nav);
289
+ border-bottom: 1px solid var(--sl-color-hairline-shade);
290
+ box-shadow: var(--sl-shadow-md);
291
+ }
292
+
293
+ docs-subheader-menu[aria-expanded='true'] .subheader-right {
294
+ display: flex;
295
+ }
296
+
297
+ .subheader-links {
298
+ flex-wrap: wrap;
299
+ }
300
+
301
+ .product-link {
302
+ font-size: 0.875rem;
303
+ padding-block: 0.25rem;
304
+ }
305
+
306
+ .subheader-toggle {
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: center;
310
+ }
311
+
312
+ .subheader-toggle:hover,
313
+ .subheader-toggle:focus-visible {
314
+ background-color: var(--sl-color-hairline);
315
+ }
316
+
317
+ docs-subheader-menu[aria-expanded='true'] .subheader-toggle .icon-open { display: none; }
318
+ docs-subheader-menu:not([aria-expanded='true']) .subheader-toggle .icon-close { display: none; }
319
+ }
320
+ </style>
@@ -0,0 +1,74 @@
1
+ # DocsSubHeader
2
+
3
+ Secondary fixed header bar rendered below the `GlobalNavBar`. Contains the site title, breadcrumb trail derived from the sidebar tree, the Pagefind search button, and platform product-switch links.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ |------|------|---------|-------------|
15
+ | `pageTitle` | `string \| null` | — | Fallback label shown when `currentSlug` is not found in the sidebar tree. |
16
+ | `currentSlug` | `string` | `''` | Current page slug — used to derive the breadcrumb from the sidebar. |
17
+ | `siteTitle` | `string` | virtual module | Override the site name shown on the left. |
18
+ | `productLinks` | `{ label: string; href: string; platform?: string }[]` | virtual module | Override the cross-product navigation links. |
19
+ | `sidebarItems` | `SidebarEntry[]` | virtual module | Override the sidebar tree used for breadcrumb generation. |
20
+
21
+ ## Behaviour
22
+
23
+ - The breadcrumb is built by walking `sidebarData` (from `virtual:docs-template/site-meta`) with `getBreadcrumb()`.
24
+ - Product links from the virtual module are shown; the currently active platform link is hidden.
25
+ - The search button opens the Pagefind dialog (see `Search` component).
26
+ - CSS custom properties used for positioning:
27
+ - `--docs-global-nav-height` (default `86px`) — height of the bar above
28
+ - `--docs-subheader-height` (default `40px`) — height of this bar
29
+
30
+ ## Example
31
+
32
+ ### Prop-driven (no `siteMetaIntegration` required)
33
+
34
+ ```astro
35
+ ---
36
+ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.astro';
37
+ import type { SidebarEntry } from 'igniteui-astro-components/lib/sidebar/types';
38
+
39
+ const sidebar: SidebarEntry[] = [
40
+ { label: 'Getting Started', collapsed: false, items: [
41
+ { label: 'Introduction', slug: '' },
42
+ ]},
43
+ { label: 'Components', collapsed: false, items: [
44
+ { label: 'Toast', slug: 'components/toast' },
45
+ ]},
46
+ ];
47
+
48
+ const productLinks = [
49
+ { label: 'Angular', href: '/angular/', platform: 'angular' },
50
+ { label: 'React', href: '/react/', platform: 'react' },
51
+ { label: 'Web Components', href: '/web-components/', platform: 'web-components' },
52
+ ];
53
+ ---
54
+ <DocsSubHeader
55
+ siteTitle="My Library"
56
+ productLinks={productLinks}
57
+ sidebarItems={sidebar}
58
+ currentSlug="components/toast"
59
+ />
60
+ ```
61
+
62
+ ### With `siteMetaIntegration` (integration-driven)
63
+
64
+ All props are optional when the virtual module provides the data:
65
+
66
+ ```astro
67
+ ---
68
+ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.astro';
69
+ ---
70
+ <DocsSubHeader pageTitle="Toast" currentSlug="components/toast" />
71
+ ```
72
+
73
+ This component is used automatically inside `DocsLayout` — you only need to
74
+ mount it directly when building a custom page shell.