@tenphi/cookbook 0.26.0 → 0.27.0
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/docs/authoring.mdx +49 -6
- package/docs/component-styles.md +2 -1
- package/package.json +3 -3
package/docs/authoring.mdx
CHANGED
|
@@ -154,6 +154,49 @@ shows each inlined file as a `<script src>` tag. Every preview embeds its own
|
|
|
154
154
|
copy, so keep demo bundles small. A missing file or a path outside the public
|
|
155
155
|
directory fails the build.
|
|
156
156
|
|
|
157
|
+
The frame is at least `10rem` tall, and content outside it is clipped. Give a
|
|
158
|
+
demo with an overlay, such as a listbox, a popover, or a modal dialog, more
|
|
159
|
+
room with `height`, the frame's minimum height as a CSS length such as `18rem`
|
|
160
|
+
or `320px`. Any other value, including a percentage or `calc()`, fails the
|
|
161
|
+
build. To change every preview, style `theme.styles.Preview.Frame` instead.
|
|
162
|
+
|
|
163
|
+
```mdx
|
|
164
|
+
<Preview
|
|
165
|
+
title="Library select"
|
|
166
|
+
height="18rem"
|
|
167
|
+
html={"<acme-select label='Fruit'></acme-select>"}
|
|
168
|
+
scripts={["/demo/select.js"]}
|
|
169
|
+
/>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Forms in a preview can be submitted. To show what a form sends, call
|
|
173
|
+
`event.preventDefault()` in a `submit` listener and read its `FormData`;
|
|
174
|
+
otherwise the submission navigates the frame away from the demo. The
|
|
175
|
+
documentation page itself is never navigated, and the frame keeps its separate
|
|
176
|
+
origin.
|
|
177
|
+
|
|
178
|
+
```mdx
|
|
179
|
+
<Preview
|
|
180
|
+
title="Form data"
|
|
181
|
+
html={
|
|
182
|
+
'<form><label>Name <input name="name" value="Ada"></label> <button>Send</button></form><output></output>'
|
|
183
|
+
}
|
|
184
|
+
javascript={
|
|
185
|
+
"document.querySelector('form').addEventListener('submit', (event) => { event.preventDefault(); document.querySelector('output').value = JSON.stringify(Object.fromEntries(new FormData(event.target))); });"
|
|
186
|
+
}
|
|
187
|
+
/>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
<Preview
|
|
191
|
+
title="Form data"
|
|
192
|
+
html={
|
|
193
|
+
'<form><label>Name <input name="name" value="Ada"></label> <button>Send</button></form><output></output>'
|
|
194
|
+
}
|
|
195
|
+
javascript={
|
|
196
|
+
"document.querySelector('form').addEventListener('submit', (event) => { event.preventDefault(); document.querySelector('output').value = JSON.stringify(Object.fromEntries(new FormData(event.target))); });"
|
|
197
|
+
}
|
|
198
|
+
/>
|
|
199
|
+
|
|
157
200
|
## Cookbook logo
|
|
158
201
|
|
|
159
202
|
`Logo` renders the Cookbook mark. Use `label` when it carries meaning or
|
|
@@ -173,12 +216,12 @@ markers remain visible independently of their theme-aware backgrounds:
|
|
|
173
216
|
|
|
174
217
|
## Component props
|
|
175
218
|
|
|
176
|
-
| Component | Props and behavior
|
|
177
|
-
| --------- |
|
|
178
|
-
| `Card` | Optional `title` and `href`; renders an article or link with slot content
|
|
179
|
-
| `Steps` | Ordered list container; supply `li` elements
|
|
180
|
-
| `Logo` | Optional `label`, `decorative`, and root `class`; renders the Cookbook mark
|
|
181
|
-
| `Preview` | Required `title`; optional `html`, `css`, `javascript`,
|
|
219
|
+
| Component | Props and behavior |
|
|
220
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
221
|
+
| `Card` | Optional `title` and `href`; renders an article or link with slot content |
|
|
222
|
+
| `Steps` | Ordered list container; supply `li` elements |
|
|
223
|
+
| `Logo` | Optional `label`, `decorative`, and root `class`; renders the Cookbook mark |
|
|
224
|
+
| `Preview` | Required `title`; optional `html`, `css`, `javascript`, public-file `scripts`, and frame `height`; isolates examples in a sandboxed iframe |
|
|
182
225
|
|
|
183
226
|
The public package exports each component's props type, such as `TabProps`,
|
|
184
227
|
`CalloutProps`, and `CodeGroupProps`. Styles and all named sub-elements are
|
package/docs/component-styles.md
CHANGED
|
@@ -474,7 +474,8 @@ shadow-root templates), and non-Tasty stylesheets throughout documentation HTML.
|
|
|
474
474
|
It parses actual markup, so escaped examples and strings in scripts are allowed.
|
|
475
475
|
The explicit exception is the separate document in a sandboxed `Preview` iframe;
|
|
476
476
|
it cannot access its parent's origin. Configure its size with
|
|
477
|
-
`theme.styles.Preview.Frame
|
|
477
|
+
`theme.styles.Preview.Frame`, or one preview's minimum height with its `height`
|
|
478
|
+
prop. The documentation shell supports the CSP directive
|
|
478
479
|
`style-src-attr 'none'`. A host's CSP may also restrict the preview document; when
|
|
479
480
|
using that directive, authored previews must use style blocks rather than style
|
|
480
481
|
attributes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/cookbook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Repository-native static documentation for Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"author": "Andrey Yamanov",
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@tenphi/docs": "0.
|
|
72
|
-
"@tenphi/renderer": "0.
|
|
71
|
+
"@tenphi/docs": "0.27.0",
|
|
72
|
+
"@tenphi/renderer": "0.27.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"astro": "^7.3.2"
|