igniteui-astro-components 0.0.7 → 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/package.json +4 -2
- 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/DocsTree/DocsTree.astro +9 -0
- package/src/components/DocsTree/docs-tree.scss +139 -118
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -1
- 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 +182 -355
- package/src/components/SearchAdvanced/SearchAdvanced.scss +177 -0
- 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/integration.ts +7 -0
- package/src/layouts/DocsLayout/DocsLayout.astro +58 -16
- package/src/layouts/DocsLayout/DocsLayout.scss +51 -6
- package/src/lib/sidebar/helpers.ts +14 -1
- package/src/lib/sidebar/types.ts +5 -7
- 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 -0
- package/src/scripts/sample-widget.ts +107 -114
- 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/assets/icons/copy-clipboard.svg +0 -3
- package/src/assets/icons/filter-clear.svg +0 -1
- package/src/styles/custom.scss +0 -20
|
@@ -1,32 +1,175 @@
|
|
|
1
|
+
@use 'igniteui-theming/sass/typography' as *;
|
|
2
|
+
|
|
3
|
+
igc-tabs {
|
|
4
|
+
position: relative;
|
|
5
|
+
z-index: 0;
|
|
6
|
+
width: 100%;
|
|
7
|
+
|
|
8
|
+
&::part(inner) {
|
|
9
|
+
flex-grow: 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
--item-text-color: var(--ig-gray-800);
|
|
13
|
+
--item-hover-color: var(--igd-accent);
|
|
14
|
+
--item-background: var(--igd-layout-sections-bg);
|
|
15
|
+
--item-hover-background: var(--igd-layout-sections-bg);
|
|
16
|
+
|
|
17
|
+
--item-active-color: var(--igd-accent);
|
|
18
|
+
--item-active-hover-color: var(--igd-accent);
|
|
19
|
+
--item-active-background: var(--igd-layout-sections-bg);
|
|
20
|
+
--item-active-hover-background: var(--igd-layout-sections-bg);
|
|
21
|
+
--indicator-color: var(--igd-accent);
|
|
22
|
+
|
|
23
|
+
--button-color: var(--ig-gray-800);
|
|
24
|
+
--button-hover-color: var(--igd-accent);
|
|
25
|
+
--button-background: var(--igd-layout-sections-bg);
|
|
26
|
+
--button-hover-background: var(--igd-layout-sections-bg);
|
|
27
|
+
|
|
28
|
+
.igd-code-view__header-actions {
|
|
29
|
+
border-block: rem(1px) solid var(--ig-gray-300);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.igd-sample-container {
|
|
33
|
+
border-inline: none;
|
|
34
|
+
border-block-end: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// TODO THIS IS A COMPONENT BUG LOG IT
|
|
39
|
+
igc-tab::part(start-scroll-button) {
|
|
40
|
+
inset-inline-start: -1px;
|
|
41
|
+
}
|
|
42
|
+
igc-tab::part(end-scroll-button) {
|
|
43
|
+
inset-inline-end: -1px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
igc-tab {
|
|
47
|
+
.code-wrapper {
|
|
48
|
+
position: relative;
|
|
49
|
+
border-radius: 0;
|
|
50
|
+
margin: 0;
|
|
51
|
+
border: none;
|
|
52
|
+
border-top: rem(1px) solid var(--ig-gray-300);
|
|
53
|
+
max-height: rem(400px);
|
|
54
|
+
overflow: auto;
|
|
55
|
+
overscroll-behavior: contain;
|
|
56
|
+
|
|
57
|
+
pre {
|
|
58
|
+
margin: 0;
|
|
59
|
+
border: none;
|
|
60
|
+
padding: 0;
|
|
61
|
+
border-radius: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cv-hljs-code-copy {
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: rem(16px);
|
|
67
|
+
right: rem(16px);
|
|
68
|
+
opacity: 0;
|
|
69
|
+
transition: opacity 0.2s ease;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:hover .cv-hljs-code-copy,
|
|
74
|
+
&:focus-within .cv-hljs-code-copy {
|
|
75
|
+
opacity: 1;
|
|
76
|
+
pointer-events: auto;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// TODO Log issue in the component this is not suppose to be affected by the ig-typography
|
|
82
|
+
igc-tab::part(content) {
|
|
83
|
+
@include type-style('subtitle-1') {
|
|
84
|
+
margin: 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
igc-tab::part(tab-header) {
|
|
89
|
+
min-height: 72px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.igd-code-view {
|
|
93
|
+
width: 100%;
|
|
94
|
+
border: rem(1px) solid var(--ig-gray-300);
|
|
95
|
+
margin-block-end: rem(26px);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.igd-code-view__inner {
|
|
99
|
+
position: relative;
|
|
100
|
+
display: flex;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.igd-sample-container {
|
|
104
|
+
--sample-container-header-height: #{rem(66px)};
|
|
105
|
+
|
|
106
|
+
position: relative;
|
|
107
|
+
border: rem(1px) solid var(--ig-gray-300);
|
|
108
|
+
min-height: rem(320px);
|
|
109
|
+
max-height: rem(800px);
|
|
110
|
+
overflow: hidden auto;
|
|
111
|
+
|
|
112
|
+
iframe {
|
|
113
|
+
display: block;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.sample-loading-indicator {
|
|
117
|
+
position: absolute;
|
|
118
|
+
inset: var(--sample-container-header-height, 0px) 0 0 0;
|
|
119
|
+
margin: auto;
|
|
120
|
+
width: 60px;
|
|
121
|
+
height: 60px;
|
|
122
|
+
z-index: 1;
|
|
123
|
+
opacity: 0;
|
|
124
|
+
pointer-events: none;
|
|
125
|
+
transition: opacity 0.2s ease;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&.loading .sample-loading-indicator {
|
|
129
|
+
opacity: 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
1
133
|
.full-screen-btn {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.igd-code-view__footer-actions {
|
|
139
|
+
border-block-start: rem(1px) solid var(--ig-gray-300);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.igd-code-view__header-actions,
|
|
143
|
+
.igd-code-view__footer-actions {
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: flex-end;
|
|
147
|
+
position: relative;
|
|
148
|
+
padding: rem(16px) rem(26px);
|
|
149
|
+
gap: rem(16px);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.igd-code-view__header-actions {
|
|
153
|
+
position: sticky;
|
|
154
|
+
inset-block-end: 0;
|
|
155
|
+
height: var(--sample-container-header-height);
|
|
156
|
+
border-block-start: rem(1px) solid var(--ig-gray-300);
|
|
157
|
+
background-color: var(--igd-layout-sections-bg);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
igc-button {
|
|
161
|
+
&::part(base) {
|
|
162
|
+
padding-inline: rem(16px);
|
|
163
|
+
gap: rem(4px);
|
|
164
|
+
|
|
165
|
+
@include type-style('caption') {
|
|
166
|
+
margin: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.editing-label {
|
|
172
|
+
@include type-style('body-2') {
|
|
173
|
+
margin: 0;
|
|
174
|
+
}
|
|
32
175
|
}
|
package/src/integration.ts
CHANGED
|
@@ -62,6 +62,10 @@ import { buildSidebarFromToc } from './sidebar';
|
|
|
62
62
|
import { getPlatformHead } from './platform';
|
|
63
63
|
import type { HeadEntry, PlatformKey, NavLang } from './platform.ts';
|
|
64
64
|
import { remarkEnvVars } from './plugins/remark-env-vars';
|
|
65
|
+
export { rehypeTableWrapper } from './plugins/rehype-table-wrapper';
|
|
66
|
+
import { rehypeTableWrapper } from './plugins/rehype-table-wrapper';
|
|
67
|
+
import { rehypeHeadingAnchors } from './plugins/rehype-heading-anchors';
|
|
68
|
+
export { rehypeHeadingAnchors } from './plugins/rehype-heading-anchors';
|
|
65
69
|
import { remarkMdLinks } from './plugins/remark-md-links';
|
|
66
70
|
import { remarkHtmlTransforms } from './plugins/remark-html-transforms';
|
|
67
71
|
|
|
@@ -705,6 +709,9 @@ export function createDocsSite(options: CreateDocsSiteOptions = {} as CreateDocs
|
|
|
705
709
|
...((astroExtra as any).markdown?.remarkPlugins ?? []),
|
|
706
710
|
],
|
|
707
711
|
rehypePlugins: [
|
|
712
|
+
rehypeCodeView,
|
|
713
|
+
rehypeTableWrapper,
|
|
714
|
+
rehypeHeadingAnchors,
|
|
708
715
|
...((astroExtra as any).markdown?.rehypePlugins ?? []),
|
|
709
716
|
],
|
|
710
717
|
},
|
|
@@ -8,11 +8,11 @@ import GlobalNavBar from '../../components/GlobalNavBar/GlobalNavBar.astro';
|
|
|
8
8
|
import GlobalFooter from '../../components/GlobalFooter/GlobalFooter.astro';
|
|
9
9
|
import DocsSubHeader from '../../components/DocsSubHeader/DocsSubHeader.astro';
|
|
10
10
|
import DocsBreadcrumb from '../../components/DocsBreadcrumb/DocsBreadcrumb.astro';
|
|
11
|
+
import LicenseIndicator from '../../components/LicenseIndicator/LicenseIndicator.astro';
|
|
11
12
|
import MobileSidebarToggle from '../../components/MobileSidebarToggle/MobileSidebarToggle.astro';
|
|
12
13
|
import { widgetScriptSrc, platform as virtualPlatform } from 'virtual:docs-template/nav-html';
|
|
13
14
|
import { title as siteTitle, headEntries, navLang } from 'virtual:docs-template/site-meta';
|
|
14
15
|
import '../../styles/theme.scss';
|
|
15
|
-
import '../../styles/custom.scss';
|
|
16
16
|
import './DocsLayout.scss';
|
|
17
17
|
|
|
18
18
|
export interface Props {
|
|
@@ -28,18 +28,16 @@ export interface Props {
|
|
|
28
28
|
* Useful when consuming without `siteMetaIntegration`.
|
|
29
29
|
*/
|
|
30
30
|
siteTitle?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Value of the `license` frontmatter field from the MDX page.
|
|
33
|
+
* 'commercial' → Premium badge, 'MIT' → Open Source badge, omit → no badge.
|
|
34
|
+
*/
|
|
35
|
+
license?: string;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
const {
|
|
34
|
-
title,
|
|
35
|
-
description,
|
|
36
|
-
keywords,
|
|
37
|
-
hasToc = true,
|
|
38
|
-
hasSidebar = true,
|
|
39
|
-
currentSlug = '',
|
|
40
|
-
siteTitle: siteTitleProp,
|
|
41
|
-
} = Astro.props;
|
|
38
|
+
const { title, description, keywords, hasToc = true, hasSidebar = true, currentSlug = '', siteTitle: siteTitleProp, license } = Astro.props;
|
|
42
39
|
const resolvedSiteTitle = siteTitleProp ?? siteTitle;
|
|
40
|
+
const licenseType = license === 'commercial' ? 'premium' : license === 'MIT' ? 'opensource' : false;
|
|
43
41
|
const navTheme = (virtualPlatform ?? import.meta.env.VITE_NAV_THEME ?? 'igniteui') as string;
|
|
44
42
|
const showGlobalNav = navTheme !== 'none';
|
|
45
43
|
const pageTitle = title ? `${title} | ${resolvedSiteTitle}` : resolvedSiteTitle;
|
|
@@ -69,7 +67,42 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
69
67
|
document.documentElement.setAttribute('data-theme', 'light');
|
|
70
68
|
});
|
|
71
69
|
|
|
72
|
-
//
|
|
70
|
+
// Enable smooth scrolling only after the page is fully loaded so the
|
|
71
|
+
// browser's scroll-position restoration on refresh is instant (no visible
|
|
72
|
+
// animated scroll). Remove it before a View Transition swap so navigation
|
|
73
|
+
// between pages is also instant, then re-enable after the new page loads.
|
|
74
|
+
document.addEventListener('astro:page-load', function () {
|
|
75
|
+
document.documentElement.style.scrollBehavior = 'smooth';
|
|
76
|
+
});
|
|
77
|
+
document.addEventListener('astro:before-swap', function () {
|
|
78
|
+
document.documentElement.style.removeProperty('scroll-behavior');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Root cause: Sample.astro SSR-renders an <igc-tab selected>. During Astro's
|
|
82
|
+
// client-side swap, <igc-tabs> connects and Lit runs firstUpdated() after
|
|
83
|
+
// Astro's moveToLocation() has already called scrollTo(0,0), but before
|
|
84
|
+
// astro:page-load. IgcTabsComponent then applies the selected tab and calls
|
|
85
|
+
// scrollIntoView() for its tab header, which can move the page down to the
|
|
86
|
+
// sample widget.
|
|
87
|
+
//
|
|
88
|
+
// Re-apply scroll-to-top on astro:page-load inside rAF, after Lit microtasks
|
|
89
|
+
// and selected-tab scrollIntoView() have settled. Do not override hash
|
|
90
|
+
// navigation, because hash fragments should keep their anchor behavior.
|
|
91
|
+
document.addEventListener('astro:page-load', function () {
|
|
92
|
+
if (!location.hash) {
|
|
93
|
+
requestAnimationFrame(function () {
|
|
94
|
+
if (!location.hash && window.scrollY > 0) {
|
|
95
|
+
window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Preserve dynamically-injected <style> tags across View Transitions.
|
|
102
|
+
// Only styles added by JS at runtime (e.g. the IG nav widget) need
|
|
103
|
+
// preserving — Astro re-injects its own component styles on every page
|
|
104
|
+
// automatically. Tagging the initial styles caused duplicates: the
|
|
105
|
+
// preserved copy + the freshly-injected copy from the new page.
|
|
73
106
|
var _styleIndex = 0;
|
|
74
107
|
function tagStyle(style) {
|
|
75
108
|
var isAstroStyle = Array.from(style.attributes).some(function (a) { return a.name.startsWith('data-astro'); });
|
|
@@ -77,7 +110,6 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
77
110
|
style.setAttribute('data-vt-preserved', String(++_styleIndex));
|
|
78
111
|
}
|
|
79
112
|
}
|
|
80
|
-
document.head.querySelectorAll('style').forEach(tagStyle);
|
|
81
113
|
new MutationObserver(function (mutations) {
|
|
82
114
|
mutations.forEach(function (m) {
|
|
83
115
|
m.addedNodes.forEach(function (node) {
|
|
@@ -123,9 +155,15 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
123
155
|
var rafId = 0;
|
|
124
156
|
function update() {
|
|
125
157
|
var footerTop = footer.getBoundingClientRect().top;
|
|
158
|
+
// Footer is off-screen below — sidebar needs no clamping.
|
|
159
|
+
if (footerTop >= window.innerHeight) {
|
|
160
|
+
if (sidebar.style.maxHeight) sidebar.style.maxHeight = '';
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
126
163
|
var sidebarTop = sidebar.getBoundingClientRect().top;
|
|
127
|
-
var maxH = Math.min(window.innerHeight - sidebarTop, footerTop - sidebarTop);
|
|
128
|
-
|
|
164
|
+
var maxH = Math.max(0, Math.min(window.innerHeight - sidebarTop, footerTop - sidebarTop));
|
|
165
|
+
var next = maxH + 'px';
|
|
166
|
+
if (sidebar.style.maxHeight !== next) sidebar.style.maxHeight = next;
|
|
129
167
|
}
|
|
130
168
|
function schedule() {
|
|
131
169
|
if (rafId) return;
|
|
@@ -136,7 +174,7 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
136
174
|
// covers viewport-only changes such as DevTools docking/undocking.
|
|
137
175
|
window.addEventListener('resize', schedule, { passive: true });
|
|
138
176
|
var ro = new ResizeObserver(schedule);
|
|
139
|
-
ro.observe(
|
|
177
|
+
ro.observe(footer);
|
|
140
178
|
schedule();
|
|
141
179
|
_cleanupSidebarHeights = function() {
|
|
142
180
|
window.removeEventListener('scroll', schedule);
|
|
@@ -166,7 +204,7 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
166
204
|
<!-- TODO: WE DONT NEED TO CALCULAtE THE IG HEADER HEIGHT ANYMORE - REMOVE IT -->
|
|
167
205
|
<!-- <DocsSubHeader style={ `--docs-global-nav-height: ${ showGlobalNav ? '4.7rem': '0' }` } data-nav-height-wrapper/> -->
|
|
168
206
|
<slot name="subheader">
|
|
169
|
-
<DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp}
|
|
207
|
+
<DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp} />
|
|
170
208
|
</slot>
|
|
171
209
|
|
|
172
210
|
|
|
@@ -175,10 +213,14 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
175
213
|
<slot name="sidebar"/>
|
|
176
214
|
) }
|
|
177
215
|
|
|
216
|
+
<!-- Mobile TOC trigger row — only visible on mobile, provided by the page -->
|
|
217
|
+
<slot name="mobile-toc" />
|
|
218
|
+
|
|
178
219
|
<div class="igd-main-content">
|
|
179
220
|
<div class="igd-main-content__inner">
|
|
180
221
|
<div class="igd-main-content__page">
|
|
181
222
|
<main class="igd-main-content__markdown">
|
|
223
|
+
<LicenseIndicator license={licenseType} />
|
|
182
224
|
<DocsBreadcrumb pageTitle={ title } currentSlug={ currentSlug } siteTitle={ siteTitleProp }/>
|
|
183
225
|
<slot/>
|
|
184
226
|
</main>
|
|
@@ -9,13 +9,37 @@
|
|
|
9
9
|
margin: 0;
|
|
10
10
|
z-index: 0;
|
|
11
11
|
|
|
12
|
+
@media (max-width: #{$bp-tablet-max}) {
|
|
13
|
+
--igd-page-layout-grid: 1fr;
|
|
14
|
+
--igd-page-padding: #{rem(38px)};
|
|
15
|
+
|
|
16
|
+
.search-trigger__lable,
|
|
17
|
+
.search-trigger__hint {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.search-trigger {
|
|
22
|
+
border-inline-end: var(--igd-app-outline);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
@media (min-width: #{$bp-tablet-min}) {
|
|
13
27
|
justify-content: center;
|
|
14
28
|
padding-inline: 0;
|
|
29
|
+
|
|
30
|
+
.igd-docs-subheader {
|
|
31
|
+
--igd-page-layout-grid: auto 1fr;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (min-width: #{$bp-desktop-min}) {
|
|
36
|
+
.igd-docs-subheader {
|
|
37
|
+
--igd-page-layout-grid: #{minmax(rem(300px), rem(400px)) 1fr};
|
|
38
|
+
}
|
|
15
39
|
}
|
|
16
40
|
|
|
17
41
|
@media (max-width: #{$bp-mobile-horizontal-max}) {
|
|
18
|
-
padding-inline:
|
|
42
|
+
padding-inline: 0;
|
|
19
43
|
}
|
|
20
44
|
|
|
21
45
|
&:not(:has(.igd-right-sidebar)) {
|
|
@@ -37,7 +61,7 @@
|
|
|
37
61
|
}
|
|
38
62
|
|
|
39
63
|
@media (max-width: #{$bp-mobile-horizontal-max}) {
|
|
40
|
-
padding-inline:
|
|
64
|
+
padding-inline: 0;
|
|
41
65
|
}
|
|
42
66
|
|
|
43
67
|
&:not(:has(.igd-right-sidebar)) {
|
|
@@ -104,6 +128,14 @@
|
|
|
104
128
|
border-inline: var(--igd-app-outline);
|
|
105
129
|
width: clamp(rem(300px), 100%, rem(940px));
|
|
106
130
|
margin-inline-start: auto;
|
|
131
|
+
|
|
132
|
+
@media (max-width: #{$bp-mobile-horizontal-max}) {
|
|
133
|
+
border: none;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.igd-main-content__page + aside {
|
|
138
|
+
margin-inline-end: auto;
|
|
107
139
|
}
|
|
108
140
|
|
|
109
141
|
.igd-main-content__inner {
|
|
@@ -111,15 +143,28 @@
|
|
|
111
143
|
gap: rem(70px);
|
|
112
144
|
padding-inline: rem(70px) rem(32px);
|
|
113
145
|
position: relative;
|
|
146
|
+
|
|
147
|
+
@media (max-width: #{$bp-sidebar-max}) {
|
|
148
|
+
padding-inline: rem(34px) rem(16px);
|
|
149
|
+
gap: rem(24px);
|
|
150
|
+
}
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
|
|
152
|
+
@media (max-width: #{$bp-tablet-max}) {
|
|
153
|
+
padding-inline: rem(16px);
|
|
154
|
+
gap: rem(16px)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media (max-width: #{$bp-mobile-horizontal-max}) {
|
|
158
|
+
padding: 0;
|
|
159
|
+
|
|
160
|
+
aside {
|
|
161
|
+
display: none;
|
|
162
|
+
}
|
|
117
163
|
}
|
|
118
164
|
}
|
|
119
165
|
|
|
120
166
|
.content {
|
|
121
167
|
max-width: 60rem;
|
|
122
168
|
margin: 0 auto;
|
|
123
|
-
padding
|
|
124
|
-
padding-block-end: var(--igd-page-padding);
|
|
169
|
+
padding: 0;
|
|
125
170
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shared by the SSR components and any consumer that walks the tree.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { SidebarEntry, SidebarGroup } from './types';
|
|
6
|
+
import type { SidebarEntry, SidebarGroup, SidebarLink } from './types';
|
|
7
7
|
|
|
8
8
|
export const isGroup = (e: SidebarEntry): e is SidebarGroup => 'items' in e;
|
|
9
9
|
|
|
@@ -69,6 +69,19 @@ export const getActiveLabel = (items: SidebarEntry[], currentSlug: string): stri
|
|
|
69
69
|
return '';
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
/** Returns the active SidebarLink for the current slug, or null if not found. */
|
|
73
|
+
export const getActiveLink = (items: SidebarEntry[], currentSlug: string): SidebarLink | null => {
|
|
74
|
+
for (const item of items) {
|
|
75
|
+
if (isGroup(item)) {
|
|
76
|
+
const found = getActiveLink(item.items, currentSlug);
|
|
77
|
+
if (found) return found;
|
|
78
|
+
} else if (isActive(item.slug, currentSlug)) {
|
|
79
|
+
return item;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
|
|
72
85
|
/**
|
|
73
86
|
* Breadcrumb for the current page, starting **below** the root group (root is
|
|
74
87
|
* dropped — UI shows the site title there) and ending with the active item's
|
package/src/lib/sidebar/types.ts
CHANGED
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export type SidebarBadgeVariant =
|
|
10
|
-
| '
|
|
11
|
-
| '
|
|
12
|
-
| '
|
|
13
|
-
| '
|
|
14
|
-
| 'tip'
|
|
15
|
-
| 'default';
|
|
10
|
+
| 'new'
|
|
11
|
+
| 'updated'
|
|
12
|
+
| 'preview'
|
|
13
|
+
| 'premium';
|
|
16
14
|
|
|
17
15
|
export interface SidebarBadge {
|
|
18
16
|
text: string;
|
|
@@ -22,7 +20,7 @@ export interface SidebarBadge {
|
|
|
22
20
|
export interface SidebarLink {
|
|
23
21
|
label: string;
|
|
24
22
|
slug: string;
|
|
25
|
-
|
|
23
|
+
badges?: SidebarBadge[];
|
|
26
24
|
attrs?: Record<string, string | number | boolean | undefined>;
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import Slugger from 'github-slugger';
|
|
3
|
+
|
|
4
|
+
const HEADING_TAGS = new Set(['h2', 'h3', 'h4', 'h5', 'h6']);
|
|
5
|
+
|
|
6
|
+
// Extract the text content of a hast node (ignores child elements, reads text/raw nodes).
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
function textContent(node: any): string {
|
|
9
|
+
let text = '';
|
|
10
|
+
visit(node, (child) => {
|
|
11
|
+
if (child.type === 'text' || child.type === 'raw') text += child.value ?? '';
|
|
12
|
+
});
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Rehype plugin that appends a copy-link icon button to every heading
|
|
18
|
+
* (h2–h6).
|
|
19
|
+
*
|
|
20
|
+
* Runs before Astro's internal `rehypeHeadingIds` pass so it must
|
|
21
|
+
* generate its own slug using the same `github-slugger` algorithm.
|
|
22
|
+
* If the heading already has an `id` (e.g. set in raw HTML), it is reused.
|
|
23
|
+
* Headings without an existing id get one assigned here — `rehypeHeadingIds`
|
|
24
|
+
* will then see the id already present and skip re-assigning it, ensuring
|
|
25
|
+
* the button href and the heading's id always match.
|
|
26
|
+
*/
|
|
27
|
+
export function rehypeHeadingAnchors() {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
return (tree: any) => {
|
|
30
|
+
const slugger = new Slugger();
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
visit(tree, 'element', (node: any) => {
|
|
34
|
+
if (!HEADING_TAGS.has(node.tagName)) return;
|
|
35
|
+
|
|
36
|
+
node.properties ??= {};
|
|
37
|
+
|
|
38
|
+
// Reuse an existing id or generate one from heading text.
|
|
39
|
+
if (typeof node.properties.id !== 'string') {
|
|
40
|
+
node.properties.id = slugger.slug(textContent(node));
|
|
41
|
+
} else {
|
|
42
|
+
// Keep slugger in sync so it doesn't generate duplicate ids.
|
|
43
|
+
slugger.slug(node.properties.id);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const id = node.properties.id as string;
|
|
47
|
+
|
|
48
|
+
const iconButton = {
|
|
49
|
+
type: 'element',
|
|
50
|
+
tagName: 'igc-icon-button',
|
|
51
|
+
properties: {
|
|
52
|
+
class: 'igd-anchor-link',
|
|
53
|
+
href: `#${id}`,
|
|
54
|
+
variant: 'flat',
|
|
55
|
+
'aria-label': 'Link to this section',
|
|
56
|
+
tabIndex: 0,
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
type: 'element',
|
|
61
|
+
tagName: 'igc-icon',
|
|
62
|
+
properties: {
|
|
63
|
+
name: 'link',
|
|
64
|
+
collection: 'docs',
|
|
65
|
+
},
|
|
66
|
+
children: [],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
node.children.push(iconButton);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
|
|
3
|
+
let _counter = 0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Rehype plugin that wraps every <table> in a scroll container div.
|
|
7
|
+
* The wrapper is fully accessible per the recommendations in:
|
|
8
|
+
* https://piccalil.li/blog/styling-tables-the-modern-css-way/
|
|
9
|
+
*
|
|
10
|
+
* - role="region" + aria-labelledby pointing to the <caption> (or a generated id)
|
|
11
|
+
* - tabindex="0" makes the scroll region keyboard-focusable
|
|
12
|
+
*/
|
|
13
|
+
export function rehypeTableWrapper() {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
return (tree: any) => {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
visit(tree, 'element', (node: any, index: number | undefined, parent: any) => {
|
|
18
|
+
if (node.tagName !== 'table' || !parent || index == null) return;
|
|
19
|
+
|
|
20
|
+
// Find an existing <caption> to use as the accessible label.
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
const caption = node.children?.find((c: any) => c.tagName === 'caption');
|
|
23
|
+
let labelId: string;
|
|
24
|
+
|
|
25
|
+
if (caption) {
|
|
26
|
+
// Reuse or assign an id on the caption element.
|
|
27
|
+
labelId = caption.properties?.id || `igd-table-caption-${++_counter}`;
|
|
28
|
+
caption.properties = { ...caption.properties, id: labelId };
|
|
29
|
+
} else {
|
|
30
|
+
// No caption — generate a unique id for the wrapper itself.
|
|
31
|
+
labelId = `igd-table-${++_counter}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const wrapper = {
|
|
35
|
+
type: 'element',
|
|
36
|
+
tagName: 'div',
|
|
37
|
+
properties: {
|
|
38
|
+
className: ['igd-table-wrapper'],
|
|
39
|
+
role: 'region',
|
|
40
|
+
'aria-labelledby': labelId,
|
|
41
|
+
tabIndex: 0,
|
|
42
|
+
},
|
|
43
|
+
children: [node],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
parent.children[index] = wrapper;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}
|
|
File without changes
|