igniteui-astro-components 1.7.0 → 1.8.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.
- package/README.md +322 -158
- package/llms-full.txt +3216 -0
- package/llms.txt +103 -0
- package/package.json +17 -5
- package/src/assets/icons/figma-logo.svg +10 -0
- package/src/code-theme/README.md +77 -0
- package/src/code-theme/index.ts +76 -0
- package/src/components/CopyCode/CopyCode.astro +6 -1
- package/src/components/CopyCode/README.md +38 -0
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +28 -30
- package/src/components/DocsSidebar/README.md +58 -30
- package/src/components/DocsSidebar/SidebarLabel.astro +34 -36
- package/src/components/DocsSubHeader/README.md +24 -31
- package/src/components/DocsToc/DocsToc.astro +12 -14
- package/src/components/DocsToc/README.md +7 -7
- package/src/components/DocsTree/DocsTree.astro +9 -11
- package/src/components/DocsTree/DocsTreeItem.astro +36 -40
- package/src/components/DocsTree/README.md +12 -9
- package/src/components/GlobalFooter/GlobalFooter.astro +6 -8
- package/src/components/GlobalNavBar/GlobalNavBar.astro +2 -4
- package/src/components/LicenseIndicator/LicenseIndicator.astro +6 -8
- package/src/components/MobileTocToggle/MobileTocToggle.astro +31 -33
- package/src/components/MobileTocToggle/README.md +45 -0
- package/src/components/Search/README.md +10 -10
- package/src/components/Search/Search.astro +12 -6
- package/src/components/SearchAdvanced/README.md +15 -8
- package/src/components/SearchAdvanced/SearchAdvanced.astro +17 -15
- package/src/components/ThemingWidget/ThemingWidget.astro +62 -60
- package/src/components/mdx/Anatomy/Anatomy.scss +1 -1
- package/src/components/mdx/Anatomy/README.md +40 -0
- package/src/components/mdx/ApiLink/ApiLink.astro +7 -9
- package/src/components/mdx/ApiLink/README.md +1 -0
- package/src/components/mdx/ApiRef/ApiRef.astro +7 -9
- package/src/components/mdx/ApiRef/README.md +1 -1
- package/src/components/mdx/Badge/Badge.astro +3 -1
- package/src/components/mdx/Badge/README.md +1 -3
- package/src/components/mdx/DocsAside/DocsAside.astro +3 -5
- package/src/components/mdx/DocsAside/README.md +47 -29
- package/src/components/mdx/Faq/Faq.astro +11 -13
- package/src/components/mdx/Faq/FaqItem.astro +20 -26
- package/src/components/mdx/FigmaUiKits/FigmaUiKits.astro +126 -0
- package/src/components/mdx/FigmaUiKits/FigmaUiKits.scss +165 -0
- package/src/components/mdx/FigmaUiKits/README.md +115 -0
- package/src/components/mdx/FigmaUiKits/kits.ts +26 -0
- package/src/components/mdx/PlatformBlock/README.md +5 -18
- package/src/components/mdx/Sample/README.md +71 -50
- package/src/components/mdx/Sample/Sample.astro +108 -33
- package/src/components/mdx/Sample/Sample.scss +38 -17
- package/src/integration.ts +6 -21
- package/src/layouts/DocsLayout/README.md +63 -28
- package/src/lib/warn-once.ts +8 -0
- package/src/scripts/copy-status.ts +35 -0
- package/src/scripts/icon-manifest.ts +1 -0
- package/src/scripts/sample-widget.ts +162 -42
- package/src/styles/global/_code-blocks.scss +58 -36
- package/src/styles/global/_copy-button.scss +18 -25
- package/src/styles/global/_markdown.scss +15 -8
- package/src/styles/global/_variables.scss +57 -0
- package/src/styles/theme.scss +4 -1
- package/src/virtual-modules.d.ts +1 -1
|
@@ -10,25 +10,55 @@ import Sample from 'igniteui-astro-components/components/mdx/Sample.astro';
|
|
|
10
10
|
|
|
11
11
|
## Props
|
|
12
12
|
|
|
13
|
-
| Prop | Type | Default
|
|
14
|
-
| ----------------- | -------------------------------- |
|
|
15
|
-
| `src` | `string` | _(required)_
|
|
16
|
-
| `height` | `number` | `150` (`50` if `fitContent`)
|
|
17
|
-
| `alt` | `string` | `''`
|
|
18
|
-
| `lob` | `boolean` | `false`
|
|
19
|
-
| `dv` | `boolean` | `false`
|
|
20
|
-
| `crm` | `boolean` | `false`
|
|
21
|
-
| `wc` | `boolean` | `false`
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `fitContent` | `boolean` | `false`
|
|
26
|
-
| `spacing` | `'none' \| 'sm' \| 'md' \| 'lg'` | `'none'`
|
|
27
|
-
| `position` | `string` | —
|
|
28
|
-
| `resizable` | `boolean` | `false`
|
|
29
|
-
| `noBorder` | `boolean` | `true`
|
|
30
|
-
| `noBackground` | `boolean` | `true`
|
|
31
|
-
| `whiteBackground` | `boolean` | `false`
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| ----------------- | -------------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `src` | `string` | _(required)_ | Sample path relative to the demos base URL, e.g. `"/charts/data-chart/axis-crossing"`. |
|
|
16
|
+
| `height` | `number` | `150` (`50` if `fitContent`) | iframe height in pixels. With `fitContent` it is only the loading placeholder / cross-origin fallback. |
|
|
17
|
+
| `alt` | `string` | `''` | `title` attribute for the iframe (accessibility). |
|
|
18
|
+
| `lob` | `boolean` | `false` | Use `lobDemosBaseUrl` instead of `demosBaseUrl` (LOB/grid-dynamic demos). |
|
|
19
|
+
| `dv` | `boolean` | `false` | Force use of `dvDemosBaseUrl` (data-viz demos). Auto-detected for paths starting with `charts/`, `gauges/`, `maps/`, `excel/`. |
|
|
20
|
+
| `crm` | `boolean` | `false` | Use `crmDemoBaseUrl` (CRM demo samples). |
|
|
21
|
+
| `wc` | `boolean` | `false` | Load the sample from the Web Components samples browser (`wcDemosBaseUrl`) on every platform's docs, for demos the platforms share. Falls back to `demosBaseUrl`. Code tabs and live editing follow it. |
|
|
22
|
+
| `chrome` | `'widget' \| 'demo' \| 'bare'` | `'widget'` | What the widget draws around the demo. `widget`: the EXAMPLE and code tabs, and a footer with the live-edit and full-screen buttons. `demo`: the widget's frame without the tabs and the code viewer; the footer carries only the theme picker, and without one there is no footer. For demos whose code is not a usage example, e.g. ones that fake interaction states. `bare`: only the iframe, in a plain container. See [Chrome](#chrome). |
|
|
23
|
+
| `showThemePicker` | `boolean` | `false` | Add the in-sample theme picker to the footer. Its initial theme comes from the site, not from the usage. `widget` and `demo` only: `bare` has no footer to put it in. |
|
|
24
|
+
| `fullscreenBtn` | `boolean` | `false` | Render a "View in full screen" button below the iframe. `bare` only: the `widget` footer already has one, and `demo` leaves full screen out on purpose. |
|
|
25
|
+
| `fitContent` | `boolean` | `false` | Size the iframe to fit its content — the embedded page dictates the size. Same-origin demos are measured directly; cross-origin demos must report via `postMessage`. Demos with ink overflow (shadows, glows, focus rings) must reserve room for it in their own layout, since an iframe clips at its edge. |
|
|
26
|
+
| `spacing` | `'none' \| 'sm' \| 'md' \| 'lg'` | `'none'` | Padding around the iframe inside the container: `none` = 0, `sm` = 8px, `md` = 16px, `lg` = 32px. Applied by the host container, never inside the embedded page. |
|
|
27
|
+
| `position` | `string` | — | Where the iframe sits inside the container when it doesn't fill it. Accepts a horizontal token (`start`, `center`, `end`) and/or a vertical token (`top`, `center`, `bottom`), space-separated in any order — e.g. `"center"`, `"start top"`, `"end bottom"`. |
|
|
28
|
+
| `resizable` | `boolean` | `false` | Show a drag handle on the right edge that resizes the iframe's width so responsive demos can be previewed at different widths. Left/right arrow keys resize it when focused. Combines with `fitContent`: the drag owns the width, the content keeps dictating the height. |
|
|
29
|
+
| `noBorder` | `boolean` | `true` | Drop the 1px border drawn around the iframe/container. Pass `noBorder={false}` to draw it — recommended whenever the tabs, the footer or the `fullscreenBtn` bar render. |
|
|
30
|
+
| `noBackground` | `boolean` | `true` (`false` with a theme picker) | Hide the grid-pattern backdrop drawn behind the iframe, keeping the container fully transparent. Pass `noBackground={false}` to show it. Defaults to `false` when a theme picker renders (`showThemePicker` with `widget` or `demo`), so a demo whose theme and mode the reader can switch has a surface of its own. An explicit value always wins. |
|
|
31
|
+
| `whiteBackground` | `boolean` | `false` | Paint the backdrop behind the iframe pure white (`#fff`) instead of the default light gray. Only the light side changes — dark mode (the site's, or the in-sample theming widget's) is left as is. Implies a painted background, so it also overrides the transparency `noBackground` leaves behind in light mode. |
|
|
32
|
+
| `iframeOnly` | `boolean` | `false` | **Deprecated**, removed in 2.0.0. Use `chrome="bare"`. See [Deprecated props](#deprecated-props). |
|
|
33
|
+
| `hideCode` | `boolean` | `false` | **Deprecated**, removed in 2.0.0. Use `chrome="demo"`. See [Deprecated props](#deprecated-props). |
|
|
34
|
+
|
|
35
|
+
## Chrome
|
|
36
|
+
|
|
37
|
+
`chrome` picks what surrounds the demo, and `showThemePicker` and `fullscreenBtn` add to it where they apply:
|
|
38
|
+
|
|
39
|
+
| `chrome` | Tabs and code | Footer | `showThemePicker` | `fullscreenBtn` |
|
|
40
|
+
| -------------------- | ------------- | -------------------------------------- | ----------------- | --------------- |
|
|
41
|
+
| `widget` _(default)_ | Yes | Live-edit and full-screen buttons | Yes | No |
|
|
42
|
+
| `demo` | No | Only the theme picker, if there is one | Yes | No |
|
|
43
|
+
| `bare` | No | None | No | Yes |
|
|
44
|
+
|
|
45
|
+
A modifier the chrome ignores, or a `chrome` value that is not one of the three, logs a build warning. The types only reject an unknown `chrome` value: they accept every modifier with every chrome, as MDX, where most samples live, is not type-checked anyway.
|
|
46
|
+
|
|
47
|
+
### Deprecated props
|
|
48
|
+
|
|
49
|
+
`iframeOnly` and `hideCode`, the 1.x spellings of `chrome="bare"` and `chrome="demo"`, still work, but they are deprecated and 2.0.0 removes them. Editors strike them through, and each sample that uses one logs a build warning, once per build, that names the replacement:
|
|
50
|
+
|
|
51
|
+
| Deprecated | Use instead |
|
|
52
|
+
| -------------------------- | ----------------------------- |
|
|
53
|
+
| `iframeOnly` | `chrome="bare"` |
|
|
54
|
+
| `iframeOnly fullscreenBtn` | `chrome="bare" fullscreenBtn` |
|
|
55
|
+
| `hideCode` | `chrome="demo"` |
|
|
56
|
+
|
|
57
|
+
As in 1.x, `iframeOnly` wins over `hideCode`. A valid `chrome` wins over both, and the warning says the deprecated prop is ignored. A `chrome` that is not one of the three is ignored itself, so the deprecated prop still applies.
|
|
58
|
+
|
|
59
|
+
## Clicks beside the demo
|
|
60
|
+
|
|
61
|
+
The iframe does not always fill the sample area: `position` leaves slack around it, `spacing` pads it, and a centered `fitContent` iframe has margins beside it. A `click` or `pointerdown` on that empty part of the area is forwarded to a same-origin demo as an untrusted event on its `<html>` element, so the demo's outside-click handling runs and open popups (a picker, a dropdown, a combo) close. The forwarded event carries no coordinates. A cross-origin demo cannot be reached, so its behavior is unchanged.
|
|
32
62
|
|
|
33
63
|
## Examples
|
|
34
64
|
|
|
@@ -47,32 +77,33 @@ import Sample from 'igniteui-astro-components/components/mdx/Sample.astro';
|
|
|
47
77
|
|
|
48
78
|
{/* Web Components sample shared by every platform's docs */}
|
|
49
79
|
|
|
50
|
-
<Sample src="/themes/palettes/scales" wc fitContent
|
|
80
|
+
<Sample src="/themes/palettes/scales" wc fitContent chrome="bare" />
|
|
51
81
|
|
|
52
82
|
{/* Bare iframe for embedding */}
|
|
53
83
|
|
|
54
|
-
<Sample src="/charts/bar-chart/overview"
|
|
84
|
+
<Sample src="/charts/bar-chart/overview" chrome="bare" height={300} />
|
|
55
85
|
|
|
56
86
|
{/* Bare iframe + fullscreen link */}
|
|
57
87
|
|
|
58
|
-
<Sample src="/charts/bar-chart/overview"
|
|
88
|
+
<Sample src="/charts/bar-chart/overview" chrome="bare" fullscreenBtn height={300} />
|
|
59
89
|
|
|
60
90
|
{/* Demo only, with the theme picker: no code tabs or live-edit buttons */}
|
|
61
91
|
|
|
62
|
-
<Sample src="/inputs/radio/interaction-state"
|
|
92
|
+
<Sample src="/inputs/radio/interaction-state" chrome="demo" showThemePicker height={400} />
|
|
63
93
|
```
|
|
64
94
|
|
|
65
95
|
## Environment configuration
|
|
66
96
|
|
|
67
|
-
The base URLs are
|
|
97
|
+
The base URLs are read from `Astro.locals.envVars`, a plain `Record<string, string>` that the host site's middleware must set (the docs sites load it from their `environment.json`; the root README's Quick start step 3 shows a minimal version). The platform (`Astro.locals.platformContext`) comes from the same middleware:
|
|
68
98
|
|
|
69
|
-
| Key
|
|
70
|
-
|
|
|
71
|
-
| `demosBaseUrl`
|
|
72
|
-
| `dvDemosBaseUrl`
|
|
73
|
-
| `lobDemosBaseUrl`
|
|
74
|
-
| `crmDemoBaseUrl`
|
|
75
|
-
| `wcDemosBaseUrl`
|
|
99
|
+
| Key | Used by |
|
|
100
|
+
| -------------------- | ------------------------------------------------------------------------------------ |
|
|
101
|
+
| `demosBaseUrl` | Default demos |
|
|
102
|
+
| `dvDemosBaseUrl` | Charts / gauges / maps / excel |
|
|
103
|
+
| `lobDemosBaseUrl` | LOB / grids |
|
|
104
|
+
| `crmDemoBaseUrl` | CRM demos |
|
|
105
|
+
| `wcDemosBaseUrl` | `wc` samples, on any platform |
|
|
106
|
+
| `defaultSampleTheme` | Starting theme of the code tabs and theme picker; falls back to the platform default |
|
|
76
107
|
|
|
77
108
|
Outside the Web Components site, a `wc` sample needs `wcDemosBaseUrl`: without it the sample falls back to `demosBaseUrl`, the page's own platform browser, and the build logs a warning. Leave unused keys out rather than setting them to `""`: an empty string doesn't fall back, it produces a relative URL.
|
|
78
109
|
|
|
@@ -80,26 +111,16 @@ Outside the Web Components site, a `wc` sample needs `wcDemosBaseUrl`: without i
|
|
|
80
111
|
|
|
81
112
|
Code tabs are syntax-highlighted client-side using [Shiki](https://shiki.style/) (lazy-loaded via dynamic import and pre-warmed at widget init). Supported languages: `typescript`, `tsx`, `javascript`, `html`, `css`, `scss`, `csharp`, `razor`.
|
|
82
113
|
|
|
83
|
-
The theme
|
|
84
|
-
|
|
85
|
-
```js
|
|
86
|
-
// astro.config.mjs
|
|
87
|
-
export default defineConfig({
|
|
88
|
-
vite: {
|
|
89
|
-
define: {
|
|
90
|
-
__IGD_SAMPLE_CODE_THEME__: JSON.stringify('github-dark'),
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Any [Shiki bundled theme](https://shiki.style/themes) name is accepted. If the define is absent the default `dark-plus` is used.
|
|
114
|
+
The tabs use the package's brand code theme (`igCodeTheme`, the same one `createDocsSite()` applies to fenced blocks), so a code tab and a fenced block look identical. See [`src/code-theme/README.md`](../../../code-theme/README.md).
|
|
97
115
|
|
|
98
|
-
|
|
116
|
+
## Registering in MDX
|
|
99
117
|
|
|
100
|
-
|
|
118
|
+
Nothing is registered automatically. Either import the component at the top of
|
|
119
|
+
each MDX file (the convention in the docs repos):
|
|
101
120
|
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
export { default as Sample } from 'igniteui-astro-components/components/mdx/Sample.astro';
|
|
121
|
+
```mdx
|
|
122
|
+
import Sample from 'igniteui-astro-components/components/mdx/Sample.astro';
|
|
105
123
|
```
|
|
124
|
+
|
|
125
|
+
or pass it through the `components` map of a `<Content />` render when the MDX
|
|
126
|
+
is authored without imports (CMS content, for example).
|
|
@@ -15,16 +15,21 @@
|
|
|
15
15
|
* when a separate demosBaseUrl is present in the environment config.
|
|
16
16
|
*/
|
|
17
17
|
import type { PlatformContext } from '../../../lib/types.ts';
|
|
18
|
+
import { warnOnce } from '../../../lib/warn-once.ts';
|
|
18
19
|
import ThemingWidget from '../../ThemingWidget/ThemingWidget.astro';
|
|
19
20
|
import './Sample.scss';
|
|
20
21
|
|
|
22
|
+
type SampleChrome = 'widget' | 'demo' | 'bare';
|
|
23
|
+
|
|
21
24
|
interface Props {
|
|
25
|
+
/** Sample path relative to the demos base URL, e.g. `/charts/data-chart/axis-crossing`. */
|
|
22
26
|
src: string;
|
|
23
27
|
/**
|
|
24
28
|
* Iframe height in px. Default 150. With `fitContent` it is only the
|
|
25
29
|
* loading placeholder / cross-origin fallback and defaults to 50.
|
|
26
30
|
*/
|
|
27
31
|
height?: number;
|
|
32
|
+
/** `title` of the iframe, for accessibility. Defaults to "<platform> Example". */
|
|
28
33
|
alt?: string;
|
|
29
34
|
/** Use lobDemosBaseUrl instead of demosBaseUrl (for LOB/grid-dynamic demos). */
|
|
30
35
|
lob?: boolean;
|
|
@@ -39,23 +44,30 @@ interface Props {
|
|
|
39
44
|
* browser on the Web Components site. Code tabs and live editing follow it.
|
|
40
45
|
*/
|
|
41
46
|
wc?: boolean;
|
|
42
|
-
/** Render only the iframe — no navbar, no code tabs, no live-edit footer. */
|
|
43
|
-
iframeOnly?: boolean;
|
|
44
|
-
/** When used with iframeOnly, also render a "View in full screen" button below. */
|
|
45
|
-
fullscreenBtn?: boolean;
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* What the widget draws around the demo. Defaults to `widget`.
|
|
49
|
+
* - `widget`: the EXAMPLE and code tabs, and a footer with the live-edit and
|
|
50
|
+
* full-screen buttons (and the theme picker, with `showThemePicker`).
|
|
51
|
+
* - `demo`: the widget's frame and the demo, without the tabs and the code
|
|
52
|
+
* viewer. The footer carries only the theme picker, and without one there is
|
|
53
|
+
* no footer. For demos whose code is not a usage example, e.g. ones that fake
|
|
54
|
+
* interaction states for display.
|
|
55
|
+
* - `bare`: the iframe in a plain container (see `fullscreenBtn`).
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
chrome?: SampleChrome;
|
|
54
58
|
/**
|
|
55
59
|
* Opt in to the in-sample theme picker for this sample. Its initial theme is
|
|
56
60
|
* resolved from the site (see `defaultTheme` below), not passed per usage.
|
|
61
|
+
* `widget` and `demo` only: `bare` has no footer to put it in, so there it is
|
|
62
|
+
* ignored, with a build warning.
|
|
57
63
|
*/
|
|
58
64
|
showThemePicker?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Render a "View in full screen" button below the iframe. `bare` only: the
|
|
67
|
+
* `widget` footer already has one and `demo` leaves full screen out on
|
|
68
|
+
* purpose, so there it is ignored, with a build warning.
|
|
69
|
+
*/
|
|
70
|
+
fullscreenBtn?: boolean;
|
|
59
71
|
/**
|
|
60
72
|
* Size the iframe to fit its content: the embedded page dictates the
|
|
61
73
|
* iframe's size. `height` serves only as the placeholder/fallback — shown
|
|
@@ -99,10 +111,11 @@ interface Props {
|
|
|
99
111
|
* container is fully transparent, so a demo without a background of its own
|
|
100
112
|
* sits directly on the page.
|
|
101
113
|
*
|
|
102
|
-
* Defaults to `false` when
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* background. An explicit
|
|
114
|
+
* Defaults to `false` when a theme picker renders (`showThemePicker` with the
|
|
115
|
+
* `widget` or `demo` chrome): a sample whose theme — and mode — the reader
|
|
116
|
+
* can switch needs a surface of its own to switch against, otherwise a
|
|
117
|
+
* dark-mode demo would sit on the page's own light background. An explicit
|
|
118
|
+
* value always wins.
|
|
106
119
|
*/
|
|
107
120
|
noBackground?: boolean;
|
|
108
121
|
/**
|
|
@@ -113,6 +126,10 @@ interface Props {
|
|
|
113
126
|
* overrides the transparency `noBackground` leaves behind (in light mode).
|
|
114
127
|
*/
|
|
115
128
|
whiteBackground?: boolean;
|
|
129
|
+
/** @deprecated Use `chrome="bare"` instead. Will be removed in 2.0.0. */
|
|
130
|
+
iframeOnly?: boolean;
|
|
131
|
+
/** @deprecated Use `chrome="demo"` instead. Will be removed in 2.0.0. */
|
|
132
|
+
hideCode?: boolean;
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
const {
|
|
@@ -122,9 +139,7 @@ const {
|
|
|
122
139
|
dv = false,
|
|
123
140
|
crm = false,
|
|
124
141
|
wc = false,
|
|
125
|
-
iframeOnly = false,
|
|
126
142
|
fullscreenBtn = false,
|
|
127
|
-
hideCode = false,
|
|
128
143
|
showThemePicker = false,
|
|
129
144
|
fitContent = false,
|
|
130
145
|
spacing = 'none',
|
|
@@ -134,9 +149,62 @@ const {
|
|
|
134
149
|
whiteBackground = false,
|
|
135
150
|
} = Astro.props;
|
|
136
151
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
|
|
152
|
+
// `chrome` is checked first. A value that is not one of the three is ignored,
|
|
153
|
+
// as if it were not set, so a deprecated prop next to a mistyped `chrome` still
|
|
154
|
+
// applies.
|
|
155
|
+
const CHROMES: SampleChrome[] = ['widget', 'demo', 'bare'];
|
|
156
|
+
const explicitChrome = CHROMES.find((value) => value === Astro.props.chrome);
|
|
157
|
+
|
|
158
|
+
// `iframeOnly` and `hideCode` are the deprecated 1.x spellings of
|
|
159
|
+
// `chrome="bare"` and `chrome="demo"`. They keep working until 2.0.0 removes
|
|
160
|
+
// them, with a build warning for each sample that uses them, so the docs can
|
|
161
|
+
// move at their own pace. `iframeOnly` comes first so that it wins over
|
|
162
|
+
// `hideCode`, as in 1.x, and a valid `chrome` wins over both.
|
|
163
|
+
const DEPRECATED_PROPS = { iframeOnly: 'bare', hideCode: 'demo' } as const;
|
|
164
|
+
let deprecatedChrome: SampleChrome | undefined;
|
|
165
|
+
for (const prop of ['iframeOnly', 'hideCode'] as const) {
|
|
166
|
+
if (!Astro.props[prop]) continue;
|
|
167
|
+
const replacement = DEPRECATED_PROPS[prop];
|
|
168
|
+
const ignored = explicitChrome
|
|
169
|
+
? ` chrome="${explicitChrome}" is set, so ${prop} is ignored.`
|
|
170
|
+
: '';
|
|
171
|
+
warnOnce(
|
|
172
|
+
`[Sample] ${src}: ${prop} is deprecated and will be removed in igniteui-astro-components 2.0.0. Use chrome="${replacement}" instead.${ignored}`,
|
|
173
|
+
);
|
|
174
|
+
deprecatedChrome ??= replacement;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const chrome = explicitChrome ?? deprecatedChrome ?? 'widget';
|
|
178
|
+
if (Astro.props.chrome != null && !explicitChrome) {
|
|
179
|
+
warnOnce(
|
|
180
|
+
`[Sample] ${src}: chrome="${Astro.props.chrome}" is not one of ${CHROMES.join(', ')}, so it is ignored, and the sample renders as chrome="${chrome}".`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const isBare = chrome === 'bare';
|
|
184
|
+
const isDemo = chrome === 'demo';
|
|
185
|
+
|
|
186
|
+
// A modifier that doesn't apply to the chosen chrome would do nothing without a
|
|
187
|
+
// word, so say so at build time.
|
|
188
|
+
if (showThemePicker && isBare) {
|
|
189
|
+
warnOnce(
|
|
190
|
+
`[Sample] ${src}: showThemePicker has no effect with chrome="bare", which renders no footer for the picker.`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (fullscreenBtn && !isBare) {
|
|
194
|
+
warnOnce(
|
|
195
|
+
`[Sample] ${src}: fullscreenBtn only applies to chrome="bare". ${
|
|
196
|
+
isDemo
|
|
197
|
+
? 'chrome="demo" leaves full screen out on purpose.'
|
|
198
|
+
: 'The widget footer already has a full-screen button.'
|
|
199
|
+
}`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
const hasThemePicker = showThemePicker && !isBare;
|
|
203
|
+
const hasFullscreenBtn = fullscreenBtn && isBare;
|
|
204
|
+
|
|
205
|
+
// The theme picker implies a painted backdrop (see the prop's doc), so the
|
|
206
|
+
// default flips when a picker renders. An explicitly passed value still wins.
|
|
207
|
+
const noBackground = Astro.props.noBackground ?? !hasThemePicker;
|
|
140
208
|
|
|
141
209
|
// Fixed samples default to 150px. In fitContent mode `height` is only the
|
|
142
210
|
// loading placeholder, so an unspecified one defaults lower (50px) to avoid
|
|
@@ -170,8 +238,8 @@ const spacingVal = ['none', 'sm', 'md', 'lg'].includes(spacing) ? spacing : 'non
|
|
|
170
238
|
const containerStyle = fitContent ? undefined : `height: ${height}px`;
|
|
171
239
|
// The fullscreen bar sits inside the container, so it is added on top of
|
|
172
240
|
// `height` — the iframe keeps the height it was given.
|
|
173
|
-
const
|
|
174
|
-
fitContent || !
|
|
241
|
+
const bareContainerStyle =
|
|
242
|
+
fitContent || !hasFullscreenBtn
|
|
175
243
|
? containerStyle
|
|
176
244
|
: `height: calc(${height}px + var(--sample-container-header-height))`;
|
|
177
245
|
const iframeStyle = fitContent ? `width: 100%; height: ${height}px;` : 'width: 100%; height: 100%;';
|
|
@@ -210,7 +278,7 @@ const baseUrl = wc
|
|
|
210
278
|
// Outside the Web Components site, `demosBaseUrl` is the page's own platform
|
|
211
279
|
// browser, so a `wc` sample without `wcDemosBaseUrl` silently loads the wrong one.
|
|
212
280
|
if (wc && !env.wcDemosBaseUrl && name !== 'WebComponents') {
|
|
213
|
-
|
|
281
|
+
warnOnce(
|
|
214
282
|
`[Sample] ${src}: wc is set but wcDemosBaseUrl is not configured, so this sample won't load from the Web Components samples browser.`,
|
|
215
283
|
);
|
|
216
284
|
}
|
|
@@ -221,9 +289,12 @@ const githubSrc = srcNoSlash;
|
|
|
221
289
|
// Stable, unique element ID derived from the sample path.
|
|
222
290
|
const widgetId = 'cw' + src.replace(/[^a-z0-9]/gi, '-');
|
|
223
291
|
const exampleTabId = `${widgetId}-example`;
|
|
292
|
+
// Anchor for the iframeOnly fullscreen button's tooltip. The random suffix keeps
|
|
293
|
+
// it unique when the same demo is embedded more than once on a page.
|
|
294
|
+
const fullscreenBtnId = `${widgetId}-fullscreen-${Math.random().toString(36).slice(2, 9)}`;
|
|
224
295
|
|
|
225
|
-
// The
|
|
226
|
-
//
|
|
296
|
+
// The widget's demo pane, shared by its two chromes: inside the EXAMPLE tab
|
|
297
|
+
// (`widget`), or on its own without the tabs (`demo`).
|
|
227
298
|
const samplePaneClass = [
|
|
228
299
|
'igd-sample-container',
|
|
229
300
|
'loading',
|
|
@@ -258,7 +329,7 @@ const sampleIframeAttrs = {
|
|
|
258
329
|
};
|
|
259
330
|
---
|
|
260
331
|
|
|
261
|
-
{
|
|
332
|
+
{isBare ? (
|
|
262
333
|
<>
|
|
263
334
|
<div
|
|
264
335
|
class:list={[
|
|
@@ -280,7 +351,7 @@ const sampleIframeAttrs = {
|
|
|
280
351
|
aria-label={
|
|
281
352
|
isResizable ? 'Resizable sample — use the left and right arrow keys to resize' : undefined
|
|
282
353
|
}
|
|
283
|
-
style={
|
|
354
|
+
style={bareContainerStyle}
|
|
284
355
|
>
|
|
285
356
|
<div class="igd-sample-frame">
|
|
286
357
|
<iframe
|
|
@@ -292,9 +363,10 @@ const sampleIframeAttrs = {
|
|
|
292
363
|
/>
|
|
293
364
|
{isResizable && <div class="igd-sample-resize-handle" aria-hidden="true" />}
|
|
294
365
|
</div>
|
|
295
|
-
{
|
|
366
|
+
{hasFullscreenBtn && (
|
|
296
367
|
<div class="igd-code-view__header-actions">
|
|
297
368
|
<igc-icon-button
|
|
369
|
+
id={fullscreenBtnId}
|
|
298
370
|
name="open-link-blank"
|
|
299
371
|
collection="docs"
|
|
300
372
|
variant="outlined"
|
|
@@ -303,6 +375,9 @@ const sampleIframeAttrs = {
|
|
|
303
375
|
target="_blank"
|
|
304
376
|
aria-label="Open in full screen"
|
|
305
377
|
/>
|
|
378
|
+
<igc-tooltip anchor={fullscreenBtnId} class="igd-sample-action-tooltip" with-arrow>
|
|
379
|
+
Open in full screen
|
|
380
|
+
</igc-tooltip>
|
|
306
381
|
</div>
|
|
307
382
|
)}
|
|
308
383
|
</div>
|
|
@@ -310,16 +385,16 @@ const sampleIframeAttrs = {
|
|
|
310
385
|
) : (
|
|
311
386
|
<>
|
|
312
387
|
<div
|
|
313
|
-
class:list={['igd-code-view', { 'igd-code-view--
|
|
388
|
+
class:list={['igd-code-view', { 'igd-code-view--demo': isDemo }]}
|
|
314
389
|
id={widgetId}
|
|
315
390
|
data-iframe-src={iframeSrc}
|
|
316
391
|
data-demos-base-url={baseUrl}
|
|
317
392
|
data-github-src={githubSrc}
|
|
318
393
|
data-platform={wc ? 'wc' : lower}
|
|
319
|
-
data-
|
|
394
|
+
data-chrome={chrome}
|
|
320
395
|
>
|
|
321
396
|
<div class="igd-code-view__inner">
|
|
322
|
-
{
|
|
397
|
+
{isDemo ? (
|
|
323
398
|
<div class:list={samplePaneClass} {...samplePaneAttrs}>
|
|
324
399
|
<igc-circular-progress
|
|
325
400
|
indeterminate
|
|
@@ -349,7 +424,7 @@ const sampleIframeAttrs = {
|
|
|
349
424
|
</igc-tabs>
|
|
350
425
|
)}
|
|
351
426
|
</div>
|
|
352
|
-
{
|
|
427
|
+
{hasThemePicker && (
|
|
353
428
|
<div class="igd-sample-theming" hidden>
|
|
354
429
|
<ThemingWidget selectedTheme={defaultTheme} />
|
|
355
430
|
</div>
|
|
@@ -363,8 +438,8 @@ const sampleIframeAttrs = {
|
|
|
363
438
|
// astro:page-load fires after every client-router navigation AND on the initial
|
|
364
439
|
// page load, so using it as the sole trigger handles both cases without
|
|
365
440
|
// double-initialization.
|
|
366
|
-
// Placed outside the
|
|
367
|
-
// registered (needed for igc-icon-button even
|
|
441
|
+
// Placed outside the chrome conditional so components and icons are always
|
|
442
|
+
// registered (needed for igc-icon-button even with chrome="bare" + fullscreenBtn).
|
|
368
443
|
import { initSampleWidgets } from '../../../scripts/sample-widget';
|
|
369
444
|
document.addEventListener('astro:page-load', initSampleWidgets);
|
|
370
445
|
</script>
|
|
@@ -58,27 +58,21 @@ igc-tab {
|
|
|
58
58
|
overflow: hidden auto;
|
|
59
59
|
overscroll-behavior: contain;
|
|
60
60
|
|
|
61
|
+
// The <pre> carries `igd-code`, so surface, font and token colours come
|
|
62
|
+
// from the shared code-snippet rules (_code-blocks.scss) and match the
|
|
63
|
+
// page's fenced blocks. Only the frame differs: the tab draws the border.
|
|
61
64
|
pre {
|
|
62
65
|
margin: 0;
|
|
63
66
|
border: none;
|
|
64
|
-
// Same spacing token the EXAMPLE pane uses for `md`, so the code
|
|
65
|
-
// and the demo share the same breathing room (and both follow an
|
|
66
|
-
// --igd-sample-spacing-md override).
|
|
67
|
-
padding: var(--igd-sample-spacing-md, #{rem(16px)});
|
|
68
67
|
border-radius: 0;
|
|
69
|
-
white-space: pre-wrap;
|
|
70
|
-
word-break: break-word;
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// dark (single dark Shiki theme) while the button's default colors
|
|
76
|
-
// follow the site theme, so without the palette the icon was invisible
|
|
77
|
-
// in light mode until hovered.
|
|
70
|
+
// Same affordance as the page-level CopyCode button (.copy-btn): flat
|
|
71
|
+
// variant, same corner offset, same `--igd-code-copy-*` palette.
|
|
78
72
|
.cv-hljs-code-copy {
|
|
79
73
|
position: absolute;
|
|
80
|
-
inset-block-start:
|
|
81
|
-
inset-inline-end:
|
|
74
|
+
inset-block-start: var(--igd-code-copy-inset);
|
|
75
|
+
inset-inline-end: var(--igd-code-copy-inset);
|
|
82
76
|
opacity: 0;
|
|
83
77
|
transition: opacity 0.2s ease;
|
|
84
78
|
pointer-events: none;
|
|
@@ -91,6 +85,14 @@ igc-tab {
|
|
|
91
85
|
opacity: 1;
|
|
92
86
|
pointer-events: auto;
|
|
93
87
|
}
|
|
88
|
+
|
|
89
|
+
// Always shows the copy button on touch devices.
|
|
90
|
+
@media (hover: none) {
|
|
91
|
+
.cv-hljs-code-copy {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
pointer-events: auto;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -122,9 +124,9 @@ igc-tab::part(tab-header) {
|
|
|
122
124
|
display: flex;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
// `
|
|
126
|
-
// own frame, which already draws the border, and takes its top corners.
|
|
127
|
-
.igd-code-view--
|
|
127
|
+
// `chrome="demo"`: no tabs header, so the demo pane sits directly in the
|
|
128
|
+
// widget's own frame, which already draws the border, and takes its top corners.
|
|
129
|
+
.igd-code-view--demo {
|
|
128
130
|
.igd-sample-container {
|
|
129
131
|
flex: 1 1 0;
|
|
130
132
|
min-width: 0;
|
|
@@ -148,7 +150,7 @@ igc-tab::part(tab-header) {
|
|
|
148
150
|
|
|
149
151
|
display: grid;
|
|
150
152
|
// The iframe frame takes all the space left over; anything after it (the
|
|
151
|
-
// fullscreen bar
|
|
153
|
+
// fullscreen bar with chrome="bare") keeps its own height.
|
|
152
154
|
grid-template-rows: minmax(0, 1fr);
|
|
153
155
|
position: relative;
|
|
154
156
|
border: rem(1px) solid var(--ig-gray-300);
|
|
@@ -463,6 +465,25 @@ igc-tab::part(tab-header) {
|
|
|
463
465
|
}
|
|
464
466
|
}
|
|
465
467
|
|
|
468
|
+
// Names the icon-only action buttons (StackBlitz, full screen, copy code) on
|
|
469
|
+
// hover/focus. Same look as the theme picker's mode tooltips, which share the
|
|
470
|
+
// footer with these buttons.
|
|
471
|
+
.igd-sample-action-tooltip {
|
|
472
|
+
--ig-tooltip-background: rgb(52 75 101 / 90%);
|
|
473
|
+
--ig-tooltip-text-color: var(--ig-gray-50);
|
|
474
|
+
--ig-tooltip-border-radius: #{rem(4px)};
|
|
475
|
+
|
|
476
|
+
&::part(base) {
|
|
477
|
+
min-height: rem(24px);
|
|
478
|
+
padding: rem(4px) rem(8px);
|
|
479
|
+
font-family: var(--igd-font-sans);
|
|
480
|
+
font-size: rem(10px);
|
|
481
|
+
font-weight: 500;
|
|
482
|
+
letter-spacing: rem(0.33px);
|
|
483
|
+
line-height: rem(16px);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
466
487
|
.igd-code-view__header-actions {
|
|
467
488
|
height: var(--sample-container-header-height);
|
|
468
489
|
border-block-start: rem(1px) solid var(--ig-gray-300);
|
package/src/integration.ts
CHANGED
|
@@ -78,6 +78,7 @@ import { igChrome, type IgChromeOptions } from './chrome/integration';
|
|
|
78
78
|
export { igChrome, type IgChromeOptions } from './chrome/integration';
|
|
79
79
|
import { remarkMdLinks } from './plugins/remark-md-links';
|
|
80
80
|
import { remarkHtmlTransforms } from './plugins/remark-html-transforms';
|
|
81
|
+
import { igShikiConfig } from './code-theme';
|
|
81
82
|
|
|
82
83
|
/** Build / deployment mode. Drives env-var `DOCS_BUILD_MODE`. */
|
|
83
84
|
export type DocsMode = 'development' | 'staging' | 'production';
|
|
@@ -212,8 +213,8 @@ export const navLang = ${JSON.stringify(navLang)};
|
|
|
212
213
|
prerender: true,
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
// Configure Sass loadPaths so bare
|
|
216
|
-
//
|
|
216
|
+
// Configure Sass loadPaths so bare package imports in the platform
|
|
217
|
+
// theme files resolve from node_modules.
|
|
217
218
|
updateConfig({
|
|
218
219
|
vite: {
|
|
219
220
|
css: {
|
|
@@ -659,24 +660,6 @@ export function createDocsSite(
|
|
|
659
660
|
? getPlatformHead(platform, navLang, { legacyChrome: !chrome || navLang === 'jp' })
|
|
660
661
|
: [];
|
|
661
662
|
|
|
662
|
-
// highlight.js for code-tab syntax highlighting inside code-view widgets.
|
|
663
|
-
const codeViewHead: HeadEntry[] = [
|
|
664
|
-
{
|
|
665
|
-
tag: 'link',
|
|
666
|
-
attrs: {
|
|
667
|
-
rel: 'stylesheet',
|
|
668
|
-
href: 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/vs2015.min.css',
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
tag: 'script',
|
|
673
|
-
attrs: {
|
|
674
|
-
src: 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js',
|
|
675
|
-
defer: true,
|
|
676
|
-
},
|
|
677
|
-
},
|
|
678
|
-
];
|
|
679
|
-
|
|
680
663
|
// Auto-configure a Vite dev-server proxy so sample-widget.ts can fetch
|
|
681
664
|
// /code-viewer/*.json from the local demos server without CORS issues.
|
|
682
665
|
const devProxy: Record<string, object> = {};
|
|
@@ -734,6 +717,8 @@ export function createDocsSite(
|
|
|
734
717
|
},
|
|
735
718
|
},
|
|
736
719
|
markdown: {
|
|
720
|
+
// Brand Shiki theme; a consumer's own `markdown.shikiConfig` replaces it.
|
|
721
|
+
shikiConfig: igShikiConfig,
|
|
737
722
|
...(astroExtra as any).markdown,
|
|
738
723
|
// Astro 7 renders Markdown/MDX with Sätteri instead of remark/rehype.
|
|
739
724
|
// MDAST plugins run before HAST plugins, matching the old
|
|
@@ -764,7 +749,7 @@ export function createDocsSite(
|
|
|
764
749
|
mode,
|
|
765
750
|
llmsSets,
|
|
766
751
|
productLinks,
|
|
767
|
-
head: [...platformHead, ...
|
|
752
|
+
head: [...platformHead, ...head],
|
|
768
753
|
}),
|
|
769
754
|
mdx(),
|
|
770
755
|
...(chrome ? [igChrome(chrome)] : []),
|