igniteui-astro-components 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/package.json +4 -2
  2. package/src/assets/icons/open-link-blank.svg +1 -1
  3. package/src/assets/logos/code-sandbox.svg +14 -0
  4. package/src/assets/logos/stackblitz.svg +13 -0
  5. package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +3 -3
  6. package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +13 -4
  7. package/src/components/DocsSidebar/DocsSidebar.astro +19 -8
  8. package/src/components/DocsSidebar/DocsSidebar.scss +140 -3
  9. package/src/components/DocsSidebar/SidebarFilterInput.astro +3 -4
  10. package/src/components/DocsSidebar/SidebarFilterInput.scss +9 -6
  11. package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
  12. package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
  13. package/src/components/DocsSubHeader/DocsSubHeader.astro +128 -302
  14. package/src/components/DocsSubHeader/DocsSubHeader.scss +115 -18
  15. package/src/components/DocsToc/DocsToc.astro +15 -7
  16. package/src/components/DocsToc/DocsToc.scss +10 -11
  17. package/src/components/DocsTree/DocsTree.astro +9 -0
  18. package/src/components/DocsTree/docs-tree.scss +146 -118
  19. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -1
  20. package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
  21. package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
  22. package/src/components/MobileTocToggle/MobileTocToggle.astro +96 -0
  23. package/src/components/MobileTocToggle/MobileTocToggle.scss +74 -0
  24. package/src/components/Search/Search.astro +45 -15
  25. package/src/components/Search/Search.scss +21 -40
  26. package/src/components/SearchAdvanced/SearchAdvanced.astro +196 -355
  27. package/src/components/SearchAdvanced/SearchAdvanced.scss +208 -0
  28. package/src/components/mdx/ApiRef/README.md +1 -1
  29. package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
  30. package/src/components/mdx/DocsAside/DocsAside.scss +106 -35
  31. package/src/components/mdx/Sample/Sample.astro +55 -45
  32. package/src/components/mdx/Sample/Sample.scss +173 -30
  33. package/src/integration.ts +7 -0
  34. package/src/layouts/DocsLayout/DocsLayout.astro +81 -21
  35. package/src/layouts/DocsLayout/DocsLayout.scss +251 -46
  36. package/src/lib/sidebar/helpers.ts +14 -1
  37. package/src/lib/sidebar/types.ts +5 -7
  38. package/src/plugins/rehype-heading-anchors.ts +74 -0
  39. package/src/plugins/rehype-table-wrapper.ts +49 -0
  40. package/src/plugins/remark-docfx.ts +0 -0
  41. package/src/scripts/sample-widget.ts +107 -114
  42. package/src/styles/global/_breakpoints.scss +15 -37
  43. package/src/styles/global/_code-blocks.scss +1 -1
  44. package/src/styles/global/_component-themes.scss +99 -18
  45. package/src/styles/global/_index.scss +2 -2
  46. package/src/styles/global/_markdown.scss +552 -78
  47. package/src/styles/global/_palette.scss +8 -0
  48. package/src/styles/global/_search-shared.scss +272 -0
  49. package/src/styles/global/_type-scale.scss +2 -2
  50. package/src/styles/global/_variables.scss +55 -13
  51. package/src/styles/theme.scss +98 -11
  52. package/src/assets/icons/copy-clipboard.svg +0 -3
  53. package/src/assets/icons/filter-clear.svg +0 -1
  54. package/src/styles/custom.scss +0 -20
@@ -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: light-dark(var(--ig-gray-900), var(--ig-gray-50));
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: light-dark(var(--ig-gray-900), var(--ig-gray-50));
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 light-dark(var(--ig-gray-300), var(--ig-gray-200));
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
- display: inline-flex;
3
- align-items: center;
4
- font-size: 0.8rem;
5
- font-weight: 400;
6
- color: #fff;
7
- border: 0;
8
- text-transform: uppercase;
9
- padding: 0.5rem 1rem;
10
- margin: 1.5rem 0;
11
- outline-style: none;
12
- transition: all 0.25s ease-out;
13
- background: #0099ff;
14
- cursor: pointer;
15
-
16
- &:hover,
17
- &:focus {
18
- color: white;
19
- box-shadow: 0 5px 5px -3px rgba(0,0,0,.26), 0 8px 10px 1px rgba(0,0,0,.12), 0 3px 14px 2px rgba(0,0,0,.08);
20
- }
21
-
22
- &::before {
23
- content: "";
24
- display: inline-block;
25
- width: 1.75rem;
26
- height: 1.75rem;
27
- margin-right: 0.5rem;
28
- background-image: url("/images/general/fullscreen-white-18dp.svg");
29
- background-size: 100%;
30
- background-repeat: no-repeat;
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
  }
@@ -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;
@@ -63,13 +61,51 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
63
61
  <slot name="head" />
64
62
  <ClientRouter />
65
63
  <script is:inline>
66
- // Force light theme on load and after every View Transitions swap
67
- document.documentElement.setAttribute('data-theme', 'light');
68
- document.addEventListener('astro:after-swap', function () {
69
- document.documentElement.setAttribute('data-theme', 'light');
64
+ // Restore persisted theme (or default to light) on load and after every View Transitions swap
65
+ function applyStoredTheme() {
66
+ var stored;
67
+ try { stored = localStorage.getItem('docs-theme'); } catch (_) {}
68
+ document.documentElement.setAttribute('data-theme', stored || 'light');
69
+ }
70
+ applyStoredTheme();
71
+ document.addEventListener('astro:after-swap', applyStoredTheme);
72
+
73
+ // Enable smooth scrolling only after the page is fully loaded so the
74
+ // browser's scroll-position restoration on refresh is instant (no visible
75
+ // animated scroll). Remove it before a View Transition swap so navigation
76
+ // between pages is also instant, then re-enable after the new page loads.
77
+ document.addEventListener('astro:page-load', function () {
78
+ document.documentElement.style.scrollBehavior = 'smooth';
79
+ });
80
+ document.addEventListener('astro:before-swap', function () {
81
+ document.documentElement.style.removeProperty('scroll-behavior');
70
82
  });
71
83
 
72
- // Preserve dynamically-injected <style> tags across View Transitions
84
+ // Root cause: Sample.astro SSR-renders an <igc-tab selected>. During Astro's
85
+ // client-side swap, <igc-tabs> connects and Lit runs firstUpdated() after
86
+ // Astro's moveToLocation() has already called scrollTo(0,0), but before
87
+ // astro:page-load. IgcTabsComponent then applies the selected tab and calls
88
+ // scrollIntoView() for its tab header, which can move the page down to the
89
+ // sample widget.
90
+ //
91
+ // Re-apply scroll-to-top on astro:page-load inside rAF, after Lit microtasks
92
+ // and selected-tab scrollIntoView() have settled. Do not override hash
93
+ // navigation, because hash fragments should keep their anchor behavior.
94
+ document.addEventListener('astro:page-load', function () {
95
+ if (!location.hash) {
96
+ requestAnimationFrame(function () {
97
+ if (!location.hash && window.scrollY > 0) {
98
+ window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
99
+ }
100
+ });
101
+ }
102
+ });
103
+
104
+ // Preserve dynamically-injected <style> tags across View Transitions.
105
+ // Only styles added by JS at runtime (e.g. the IG nav widget) need
106
+ // preserving — Astro re-injects its own component styles on every page
107
+ // automatically. Tagging the initial styles caused duplicates: the
108
+ // preserved copy + the freshly-injected copy from the new page.
73
109
  var _styleIndex = 0;
74
110
  function tagStyle(style) {
75
111
  var isAstroStyle = Array.from(style.attributes).some(function (a) { return a.name.startsWith('data-astro'); });
@@ -77,7 +113,6 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
77
113
  style.setAttribute('data-vt-preserved', String(++_styleIndex));
78
114
  }
79
115
  }
80
- document.head.querySelectorAll('style').forEach(tagStyle);
81
116
  new MutationObserver(function (mutations) {
82
117
  mutations.forEach(function (m) {
83
118
  m.addedNodes.forEach(function (node) {
@@ -123,9 +158,15 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
123
158
  var rafId = 0;
124
159
  function update() {
125
160
  var footerTop = footer.getBoundingClientRect().top;
161
+ // Footer is off-screen below — sidebar needs no clamping.
162
+ if (footerTop >= window.innerHeight) {
163
+ if (sidebar.style.maxHeight) sidebar.style.maxHeight = '';
164
+ return;
165
+ }
126
166
  var sidebarTop = sidebar.getBoundingClientRect().top;
127
- var maxH = Math.min(window.innerHeight - sidebarTop, footerTop - sidebarTop);
128
- sidebar.style.maxHeight = Math.max(0, maxH) + 'px';
167
+ var maxH = Math.max(0, Math.min(window.innerHeight - sidebarTop, footerTop - sidebarTop));
168
+ var next = maxH + 'px';
169
+ if (sidebar.style.maxHeight !== next) sidebar.style.maxHeight = next;
129
170
  }
130
171
  function schedule() {
131
172
  if (rafId) return;
@@ -136,7 +177,7 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
136
177
  // covers viewport-only changes such as DevTools docking/undocking.
137
178
  window.addEventListener('resize', schedule, { passive: true });
138
179
  var ro = new ResizeObserver(schedule);
139
- ro.observe(document.documentElement);
180
+ ro.observe(footer);
140
181
  schedule();
141
182
  _cleanupSidebarHeights = function() {
142
183
  window.removeEventListener('scroll', schedule);
@@ -147,6 +188,21 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
147
188
  }
148
189
  document.addEventListener('astro:page-load', initSidebarHeights);
149
190
  initSidebarHeights();
191
+
192
+ // Toggle data-scrolled-y / data-scrolled-x on each .igd-table-wrapper
193
+ // so the sticky header/column can show a double border while scrolled.
194
+ function initTableScrollStates() {
195
+ document.querySelectorAll('.igd-table-wrapper').forEach(function(wrapper) {
196
+ function update() {
197
+ wrapper.toggleAttribute('data-scrolled-y', wrapper.scrollTop > 0);
198
+ wrapper.toggleAttribute('data-scrolled-x', wrapper.scrollLeft > 0);
199
+ }
200
+ wrapper.addEventListener('scroll', update, { passive: true });
201
+ update();
202
+ });
203
+ }
204
+ document.addEventListener('astro:page-load', initTableScrollStates);
205
+ initTableScrollStates();
150
206
  </script>
151
207
  </head>
152
208
  <body>
@@ -162,11 +218,11 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
162
218
  the .igd-page-layout not on the body.
163
219
  Any igc component rendered dynamically on body level should have .ig-typography in order to have proper type styles.
164
220
  -->
165
- <div class="igd-page-layout ig-typography">
221
+ <div class="igd-page-layout">
166
222
  <!-- TODO: WE DONT NEED TO CALCULAtE THE IG HEADER HEIGHT ANYMORE - REMOVE IT -->
167
223
  <!-- <DocsSubHeader style={ `--docs-global-nav-height: ${ showGlobalNav ? '4.7rem': '0' }` } data-nav-height-wrapper/> -->
168
224
  <slot name="subheader">
169
- <DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp} style={ `--docs-global-nav-height: ${ showGlobalNav ? '4.7rem': '0' }` } data-nav-height-wrapper />
225
+ <DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp} />
170
226
  </slot>
171
227
 
172
228
 
@@ -175,10 +231,14 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
175
231
  <slot name="sidebar"/>
176
232
  ) }
177
233
 
234
+ <!-- Mobile TOC trigger row — only visible on mobile, provided by the page -->
235
+ <slot name="mobile-toc" />
236
+
178
237
  <div class="igd-main-content">
179
238
  <div class="igd-main-content__inner">
180
239
  <div class="igd-main-content__page">
181
240
  <main class="igd-main-content__markdown">
241
+ <LicenseIndicator license={licenseType} />
182
242
  <DocsBreadcrumb pageTitle={ title } currentSlug={ currentSlug } siteTitle={ siteTitleProp }/>
183
243
  <slot/>
184
244
  </main>