hd-garden 0.13.3 → 0.14.2
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/.agents/skills/garden-compose/SKILL.md +24 -0
- package/.agents/skills/garden-compose/references/colors.md +11 -0
- package/.agents/skills/garden-compose/references/composition-patterns.md +162 -0
- package/.agents/skills/garden-compose/references/examples.md +55 -0
- package/.agents/skills/garden-compose/references/frames.md +7 -0
- package/.agents/skills/garden-compose/references/layout-recipes.md +84 -0
- package/.agents/skills/garden-compose/references/rendering-model.md +120 -0
- package/.agents/skills/garden-compose/references/static-play.md +19 -0
- package/.agents/skills/garden-compose/references/visual-selection.md +38 -0
- package/.agents/skills/garden-compose/references/workflow.md +27 -0
- package/.agents/skills/garden-compose/scripts/_cli.mjs +12 -0
- package/.agents/skills/garden-compose/scripts/apply.mjs +2 -0
- package/.agents/skills/garden-compose/scripts/check.mjs +2 -0
- package/.agents/skills/garden-compose/scripts/prompt.mjs +2 -0
- package/.agents/skills/garden-compose/scripts/scan.mjs +2 -0
- package/.agents/skills/garden-post-review/SKILL.md +5 -16
- package/Makefile +12 -3
- package/README.en.md +10 -5
- package/README.md +10 -5
- package/app/admin/preview/[...path]/page.tsx +4 -16
- package/app/api/admin/ui/blocks/route.ts +1 -1
- package/app/components/AdminUiPanels.tsx +6 -3
- package/app/components/GardenContentGuide.tsx +7 -8
- package/app/components/MarkdownArticle.tsx +2 -0
- package/app/components/UiStudio.tsx +29 -32
- package/app/components/garden/AuthorRich.tsx +5 -0
- package/app/components/garden/ComposePreview.tsx +9 -0
- package/app/components/garden/GardenBlock.tsx +12 -10
- package/app/components/garden/GardenFile.tsx +1 -1
- package/app/components/garden/blocks.tsx +9 -197
- package/app/components/garden/file-icons.tsx +1 -1
- package/app/components/garden/patterns.tsx +7 -65
- package/app/lib/rehype-garden-blocks.mjs +30 -0
- package/app/lib/remark-garden.mjs +0 -4
- package/app/lib/ui-model.ts +8 -9
- package/app/styles/a2.css +17 -1
- package/bin/garden.mjs +34 -35
- package/docs/handbook/ai-writing.md +19 -22
- package/docs/handbook/components/compose.md +16 -7
- package/docs/handbook/components/image.md +1 -1
- package/docs/handbook/components/link-card.md +2 -2
- package/docs/handbook/components.md +5 -213
- package/docs/handbook/deploy.md +11 -0
- package/docs/handbook/en/ai-writing.md +17 -20
- package/docs/handbook/en/components/compose.md +15 -6
- package/docs/handbook/en/components/image.md +1 -1
- package/docs/handbook/en/components/link-card.md +2 -2
- package/docs/handbook/en/components.md +7 -215
- package/docs/handbook/en/deploy.md +11 -0
- package/docs/handbook/en/index.md +29 -53
- package/docs/handbook/en/reference/compose.md +77 -148
- package/docs/handbook/en/reference.md +6 -22
- package/docs/handbook/en/start.md +1 -1
- package/docs/handbook/en/workflow.md +21 -17
- package/docs/handbook/en/writing.md +3 -3
- package/docs/handbook/index.md +26 -47
- package/docs/handbook/reference/compose.md +79 -148
- package/docs/handbook/reference.md +6 -22
- package/docs/handbook/start.md +1 -1
- package/docs/handbook/workflow.md +21 -17
- package/docs/handbook/writing.md +3 -3
- package/editors/dist/typora/main.js +324 -330
- package/editors/dist/typora/style.css +4299 -11
- package/editors/dist/vscode/garden-ui-0.14.2.vsix +0 -0
- package/eslint.config.mjs +3 -0
- package/package.json +5 -3
- package/public/images/compose-resources/resource-015b41eb0f32.svg +1 -0
- package/public/images/compose-resources/resource-ecee6b47f015.svg +1 -0
- package/public/images/compose-resources/resource-fd51121b5e8c.svg +1 -0
- package/scripts/build-content.mjs +40 -131
- package/scripts/build-ui-preview.mjs +7 -5
- package/scripts/check-post.mjs +10 -106
- package/scripts/check-site.mjs +80 -0
- package/scripts/compose-style-reference.mjs +22 -0
- package/scripts/editor-preview-css.mjs +14 -0
- package/scripts/file-preview.mjs +1 -1
- package/scripts/file-sizes.mjs +7 -7
- package/scripts/generated-cache.mjs +36 -0
- package/scripts/handbook-facts.mjs +10 -3
- package/scripts/image-sizes.mjs +6 -12
- package/scripts/link-assets.mjs +35 -10
- package/scripts/managed-skills.mjs +56 -0
- package/scripts/pack-editors.mjs +12 -1
- package/scripts/prepare-pages-output.mjs +1 -1
- package/scripts/site-guide.mjs +19 -0
- package/scripts/sync-editor-version.mjs +28 -0
- package/scripts/ui-cli.mjs +26 -33
- package/templates/garden-blocks.md +4 -180
- package/templates/garden-snippets.plist +2 -183
- package/templates/site/AGENTS.en.md +89 -0
- package/templates/site/AGENTS.md +72 -0
- package/templates/site/Makefile +12 -3
- package/templates/site/Makefile.en +12 -3
- package/templates/site/README.en.md +6 -1
- package/templates/site/README.md +6 -1
- package/templates/skills-en/garden-compose/SKILL.md +24 -0
- package/templates/skills-en/garden-post-review/SKILL.md +5 -16
- package/templates/workflows/pages.en.yml +11 -0
- package/templates/workflows/pages.yml +11 -0
- package/ui/compose/compose.css +54 -14
- package/ui/compose/contracts.mjs +16 -0
- package/ui/compose/dil.mjs +109 -48
- package/ui/compose/distribution.mjs +7 -0
- package/ui/compose/features.mjs +90 -0
- package/ui/compose/icons.mjs +8 -0
- package/ui/compose/index.mjs +2 -0
- package/ui/compose/inspect.mjs +11 -0
- package/ui/compose/markup.mjs +80 -23
- package/ui/compose/preview.mjs +13 -0
- package/ui/compose/prompt-catalog.mjs +15 -3
- package/ui/compose/render.mjs +46 -11
- package/ui/compose/scenes.mjs +10 -0
- package/ui/core/apply.mjs +12 -45
- package/ui/core/catalog.mjs +22 -32
- package/ui/core/cli-locale.mjs +8 -18
- package/ui/core/color.mjs +34 -0
- package/ui/core/compile.mjs +1 -8
- package/ui/core/demos.mjs +138 -108
- package/ui/core/fence.mjs +14 -70
- package/ui/core/fix-prompt.mjs +1 -3
- package/ui/core/garden-fence.mjs +3 -63
- package/ui/core/index.mjs +3 -5
- package/ui/core/parse.mjs +22 -8
- package/ui/core/scan.mjs +31 -43
- package/ui/core/starters.mjs +3 -3
- package/ui/core/static.mjs +36 -6
- package/ui/core/transform.mjs +64 -149
- package/ui/core/validate.mjs +20 -9
- package/ui/garden/article-content.mjs +98 -0
- package/ui/garden/catalog.mjs +21 -427
- package/ui/garden/check.mjs +18 -60
- package/ui/garden/file-block.mjs +1 -1
- package/ui/garden/file-paths.mjs +8 -6
- package/ui/garden/parse.mjs +19 -182
- package/ui/garden/relations.mjs +1 -1
- package/ui/garden/snippets.mjs +12 -153
- package/ui/garden/source-icon.mjs +17 -9
- package/ui/garden/word-count.mjs +16 -85
- package/ui/index.mjs +1 -5
- package/ui/preview/dist/garden-ui.css +4300 -11
- package/ui/preview/dist/garden-ui.esm.js +446 -418
- package/ui/preview/dist/garden-ui.iife.js +446 -418
- package/ui/preview/index.tsx +31 -98
- package/ui/preview/site-config.ts +4 -0
- package/ui/prompt/build.mjs +1 -4
- package/ui/prompt/recipes/code-walkthrough.md +17 -12
- package/ui/prompt/recipes/compare.md +14 -10
- package/ui/prompt/recipes/compose.md +3 -3
- package/ui/prompt/recipes/converter.md +17 -14
- package/ui/prompt/recipes/data-chart.md +9 -8
- package/ui/prompt/recipes/inspect-grid.md +9 -8
- package/ui/prompt/recipes/param-bench.md +17 -12
- package/ui/prompt/recipes/plan.md +4 -3
- package/ui/prompt/recipes/stepper.md +18 -16
- package/ui/prompt/recipes/trace.md +20 -18
- package/ui/prompt/rules.md +26 -133
- package/ui/prompt/studio.md +3 -18
- package/ui/react/CatalogPage.tsx +19 -21
- package/ui/react/recipes.ts +3 -3
- package/ui/react/runtime.tsx +23 -2
- package/ui/react/ui.css +17 -11
- package/vite.config.ts +16 -3
- package/.agents/skills/garden-interactive-chart/SKILL.md +0 -84
- package/.agents/skills/garden-interactive-chart/references/shell.html +0 -49
- package/.agents/skills/garden-interactive-chart/references/style.md +0 -61
- package/.agents/skills/garden-ui/SKILL.md +0 -125
- package/app/components/UiBlock.tsx +0 -23
- package/app/components/WidgetChart.tsx +0 -224
- package/app/lib/generated-content.ts +0 -385
- package/docs/handbook/components/card.md +0 -67
- package/docs/handbook/components/chart.md +0 -38
- package/docs/handbook/components/choice.md +0 -42
- package/docs/handbook/components/compare.md +0 -53
- package/docs/handbook/components/file.md +0 -29
- package/docs/handbook/components/html.md +0 -49
- package/docs/handbook/components/interactive.md +0 -48
- package/docs/handbook/components/list.md +0 -65
- package/docs/handbook/components/relations.md +0 -95
- package/docs/handbook/components/stat.md +0 -39
- package/docs/handbook/components/timeline.md +0 -37
- package/docs/handbook/en/components/card.md +0 -67
- package/docs/handbook/en/components/chart.md +0 -38
- package/docs/handbook/en/components/choice.md +0 -42
- package/docs/handbook/en/components/compare.md +0 -53
- package/docs/handbook/en/components/file.md +0 -29
- package/docs/handbook/en/components/html.md +0 -49
- package/docs/handbook/en/components/interactive.md +0 -44
- package/docs/handbook/en/components/list.md +0 -65
- package/docs/handbook/en/components/relations.md +0 -95
- package/docs/handbook/en/components/stat.md +0 -39
- package/docs/handbook/en/components/timeline.md +0 -37
- package/docs/handbook/en/reference/card.md +0 -85
- package/docs/handbook/en/reference/chart.md +0 -68
- package/docs/handbook/en/reference/choice.md +0 -69
- package/docs/handbook/en/reference/compare.md +0 -59
- package/docs/handbook/en/reference/file.md +0 -50
- package/docs/handbook/en/reference/html.md +0 -62
- package/docs/handbook/en/reference/interactive.md +0 -71
- package/docs/handbook/en/reference/list.md +0 -72
- package/docs/handbook/en/reference/relations.md +0 -113
- package/docs/handbook/en/reference/stat.md +0 -60
- package/docs/handbook/en/reference/timeline.md +0 -56
- package/docs/handbook/reference/card.md +0 -85
- package/docs/handbook/reference/chart.md +0 -68
- package/docs/handbook/reference/choice.md +0 -69
- package/docs/handbook/reference/compare.md +0 -59
- package/docs/handbook/reference/file.md +0 -50
- package/docs/handbook/reference/html.md +0 -62
- package/docs/handbook/reference/interactive.md +0 -71
- package/docs/handbook/reference/list.md +0 -72
- package/docs/handbook/reference/relations.md +0 -113
- package/docs/handbook/reference/stat.md +0 -60
- package/docs/handbook/reference/timeline.md +0 -56
- package/editors/dist/vscode/garden-ui-0.1.1.vsix +0 -0
- package/templates/skills-en/garden-interactive-chart/SKILL.md +0 -84
- package/templates/skills-en/garden-interactive-chart/references/shell.html +0 -49
- package/templates/skills-en/garden-interactive-chart/references/style.md +0 -61
- package/templates/skills-en/garden-ui/SKILL.md +0 -125
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · compare
|
|
3
|
-
navTitle: compare
|
|
4
|
-
description: 把两三种方案左右并列,或把不好的做法与更好的做法上下对照。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 3
|
|
7
|
-
badge: compare
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:并排对比](/garden/components/compare)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden compare
|
|
15
|
-
items:
|
|
16
|
-
- title: 写一句话说明改了什么
|
|
17
|
-
text: 想法块紧跟在完整代码下面,AI 把它换成 diff,页面合成「代码 / 对比上一版」。
|
|
18
|
-
- title: 手写 diff
|
|
19
|
-
text: 完整代码下面紧跟一段 diff。
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```garden compare
|
|
23
|
-
items:
|
|
24
|
-
- title: 不好的提问
|
|
25
|
-
verdict: bad
|
|
26
|
-
text: 「你读过这位作者的其他作品吗?能分享一段书评吗?」
|
|
27
|
-
- title: 更好的提问
|
|
28
|
-
verdict: good
|
|
29
|
-
text: 「你平时喜欢在什么时间读书?想先旁听一次吗?」
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 字段写法
|
|
33
|
-
|
|
34
|
-
````markdown
|
|
35
|
-
```garden compare
|
|
36
|
-
items: # 必填,建议 2–3 项
|
|
37
|
-
- title: # 方案名
|
|
38
|
-
text: # 说明
|
|
39
|
-
verdict: # 可选,good | bad
|
|
40
|
-
<key>: # 可选,其他键作标签
|
|
41
|
-
```
|
|
42
|
-
````
|
|
43
|
-
|
|
44
|
-
## 字段
|
|
45
|
-
|
|
46
|
-
围栏写 ` ```garden compare `(编辑器代码片段触发词 `;gcompare`)。YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
47
|
-
|
|
48
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
49
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
50
|
-
| `items` | 必填 | `[]` | 数组(建议至少 `2` 项、并排模式建议 `2`~`3` 项,不做校验) | 对比项列表;每项可写对象,也可写一行 `"标题:说明"` 字符串 |
|
|
51
|
-
| `items[].title` | 建议填写 | `""`(单行字符串写法取冒号前半段) | 字符串 | 对比项小标题 |
|
|
52
|
-
| `items[].text` | 建议填写 | `[]` | 字符串或字符串数组;并排模式下单格正文与附加字段合起来不超过 `60` 字,超出报 `compare-long` 错误 | 对比项说明;单行 `"标题:说明"` 写法下只计冒号后半段字数 |
|
|
53
|
-
| `items[].verdict` | 可选 | 无(默认左右并排) | `"good"` \| `"bad"` | 标为推荐做法(绿勾)或不推荐做法(红叉);任一项带 `verdict` 时整组改为上下堆叠,且不受 `60` 字 `compare-long` 限制 |
|
|
54
|
-
| `items[].<其他键>` | 可选 | 无 | 字符串或数字(并排模式下字符串值计入单格 `60` 字上限,超出报 `compare-long` 错误) | 并排模式下,除 `title`、`text`、`verdict` 外的其他键值对会在卡片底部渲染为属性标签 |
|
|
55
|
-
|
|
56
|
-
## 限制与报错
|
|
57
|
-
|
|
58
|
-
- `compare-long`:并排模式下,某一格的 `text` 和其他字符串字段合起来超过 60 字。这一格改回原文的列表或段落。
|
|
59
|
-
- 任一项带 `verdict: good | bad` 时整组上下堆叠,不检查 60 字。
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · file
|
|
3
|
-
navTitle: file
|
|
4
|
-
description: 给读者提供一份或一组可下载的文件,支持在当前页展开预览。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 9
|
|
7
|
-
badge: file
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:文件下载与预览](/garden/components/file)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden file
|
|
15
|
-
src: ./file/checklist.md
|
|
16
|
-
title: 发布前检查清单
|
|
17
|
-
note: Markdown 附件示例,可点击「预览」在当前页展开阅读,或直接下载原文件
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 字段写法
|
|
21
|
-
|
|
22
|
-
````markdown
|
|
23
|
-
```garden file
|
|
24
|
-
src: # 单文件必填,路径
|
|
25
|
-
title: # 可选,标题
|
|
26
|
-
note: # 可选,一句说明
|
|
27
|
-
files: # 多文件必填,不与 src 同写
|
|
28
|
-
- src: # 必填,路径
|
|
29
|
-
title: # 可选,默认文件名
|
|
30
|
-
note: # 可选,说明
|
|
31
|
-
```
|
|
32
|
-
````
|
|
33
|
-
|
|
34
|
-
## 字段
|
|
35
|
-
|
|
36
|
-
围栏写 ` ```garden file `(编辑器代码片段触发词 `;gfile`)。单个附件在顶层写 `src`,多个附件用 `files` 数组;YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
37
|
-
|
|
38
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
39
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
40
|
-
| `src` | 单文件必填 | 无 | 相对路径、`/public` 路径或 `https://` 网址;缺失或与 `files` 同时写报 `garden-file` 错误,本地路径越出 `content/` 目录报 `file-outside` 错误,本地文件不存在报 `missing-asset` 错误,单文件超过 `5 MB` 报 `file-large` 警告 | 附件路径 |
|
|
41
|
-
| `title` | 可选 | 单文件默认取文件名;多文件默认 `""` | 字符串 | 单文件模式下为附件显示标题;多文件模式下作为整组标题 |
|
|
42
|
-
| `note` | 可选 | `""` | 字符串(与 `files` 同时写在顶层时报 `garden-file` 错误) | 单文件模式下显示在文件名下方的简短说明 |
|
|
43
|
-
| `files` | 多文件必填 | 无 | `{ src, title?, note? }[]`(至少 `1` 项;为空、非数组、与顶层 `src`/`note` 同时写、条目缺少 `src`、含未知键名或手写 `resolved` 字段时均报 `garden-file` 错误) | 多文件列表,每项必填 `src`,可选 `title`(默认取文件名)与 `note`(默认 `""`) |
|
|
44
|
-
|
|
45
|
-
## 限制与报错
|
|
46
|
-
|
|
47
|
-
- `garden-file`:没写 `src` 也没写 `files`;`files` 为空或不是列表;`files` 和顶层 `src` / `note` 同时写;条目缺 `src` 或含未知键名;手写了 `resolved`。
|
|
48
|
-
- `file-outside`:本地路径越出 `content/` 目录。
|
|
49
|
-
- `missing-asset`:本地文件不存在。
|
|
50
|
-
- `file-large`(警告):单个文件超过 5 MB。
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · html
|
|
3
|
-
navTitle: html
|
|
4
|
-
description: 在沙盒中运行一段独立的网页小工具、画布动画或演示。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 7
|
|
7
|
-
badge: html
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:嵌入网页片段](/garden/components/html)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden html
|
|
15
|
-
title: 字符长度与预计阅读耗时小工具
|
|
16
|
-
code: |
|
|
17
|
-
<!doctype html>
|
|
18
|
-
<html lang="zh-CN">
|
|
19
|
-
<head>
|
|
20
|
-
<meta charset="utf-8" />
|
|
21
|
-
<style>
|
|
22
|
-
body { margin: 0; padding: 16px 18px; font: 14px/1.6 system-ui, sans-serif; color: #1b1a18; background: #faf9f5; }
|
|
23
|
-
input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d5d1c8; border-radius: 6px; font: inherit; background: #fff; color: #1b1a18; }
|
|
24
|
-
.meta { margin-top: 10px; color: #6e6b64; font-variant-numeric: tabular-nums; }
|
|
25
|
-
strong { color: #1b1a18; }
|
|
26
|
-
</style>
|
|
27
|
-
</head>
|
|
28
|
-
<body>
|
|
29
|
-
<input id="txt" value="把文章放在自己的 Git 仓库里,推送后自动构建。" aria-label="输入示例文本" />
|
|
30
|
-
<div class="meta">当前字符数:<strong id="count">23</strong> 字</div>
|
|
31
|
-
<script>
|
|
32
|
-
const input = document.getElementById("txt");
|
|
33
|
-
const count = document.getElementById("count");
|
|
34
|
-
input.addEventListener("input", () => { count.textContent = String(input.value.length); });
|
|
35
|
-
</script>
|
|
36
|
-
</body>
|
|
37
|
-
</html>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 字段写法
|
|
41
|
-
|
|
42
|
-
````markdown
|
|
43
|
-
```garden html
|
|
44
|
-
src: # 与 code 二选一,文件路径
|
|
45
|
-
code: | # 与 src 二选一,HTML 源码
|
|
46
|
-
title: # 建议填,框顶标题
|
|
47
|
-
```
|
|
48
|
-
````
|
|
49
|
-
|
|
50
|
-
## 字段
|
|
51
|
-
|
|
52
|
-
围栏写 ` ```garden html `(编辑器代码片段触发词 `;ghtml`)。YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
53
|
-
|
|
54
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
55
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
56
|
-
| `src` | 与 `code` 二选一 | 无 | 相对路径(如 `./demo.html`) | 引用当前文章同名子目录下的独立 `.html` 文件 |
|
|
57
|
-
| `code` | 与 `src` 二选一 | `---` 分隔线下的 HTML 正文或 `""` | 多行 HTML 字符串 | 直接内联的 HTML 源码(含 `<script>` 时运行在沙盒 `iframe` 中,并自动按内容高度调整;也可以把 HTML 放在 `---` 分隔线下方) |
|
|
58
|
-
| `title` | 建议填写 | `"HTML"` | 字符串 | 框顶标题栏与无障碍 `iframe` 标题 |
|
|
59
|
-
|
|
60
|
-
## 限制与报错
|
|
61
|
-
|
|
62
|
-
- 除通用的 `garden-yaml` 外,本组件没有专属报错代码;表里写「不做校验」的建议值不会报错。
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · interactive
|
|
3
|
-
navTitle: interactive
|
|
4
|
-
description: 让读者拖动滑杆或切换选项,实时看到公式和图表的计算结果。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 8
|
|
7
|
-
badge: interactive
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:可调公式与参数](/garden/components/interactive)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden interactive #reading-time
|
|
15
|
-
caption: 示例:按字数、阅读速度和配图数估算一篇文章的阅读时间。数字只用来演示组件,不是统计结果。
|
|
16
|
-
---
|
|
17
|
-
<State words={6000} speed={400} images={8} />
|
|
18
|
-
<Let textMinutes={round(words / speed)} />
|
|
19
|
-
<Let imageMinutes={round(images * 12 / 60)} />
|
|
20
|
-
<Let parts={[{ part: "正文", minutes: textMinutes }, { part: "配图", minutes: imageMinutes }]} />
|
|
21
|
-
|
|
22
|
-
<Slider bind="words" label="正文字数" min={1000} max={20000} step={500} unit="字" />
|
|
23
|
-
<Slider bind="speed" label="阅读速度" min={200} max={800} step={50} unit="字/分钟" />
|
|
24
|
-
<Slider bind="images" label="配图数" min={0} max={30} step={1} unit="张" />
|
|
25
|
-
|
|
26
|
-
<Stat label="示例:预计阅读时间" value={textMinutes + imageMinutes} unit="分钟" hint="配图按每张 12 秒估算" />
|
|
27
|
-
<Chart data={parts} x={part} yLabel="分钟">
|
|
28
|
-
<Bar y={minutes} label="示例" />
|
|
29
|
-
</Chart>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 字段写法
|
|
33
|
-
|
|
34
|
-
````markdown
|
|
35
|
-
```garden interactive #<id>
|
|
36
|
-
caption: # 必填,默认状态的结论
|
|
37
|
-
intent: | # 可选,作者原话
|
|
38
|
-
expect: # 可选,数值断言
|
|
39
|
-
--- # 下方写交互标签
|
|
40
|
-
<State ... /> # 必填,可调状态
|
|
41
|
-
<Let ... /> # 可选,派生值
|
|
42
|
-
<Slider bind="..." /> # 输入控件
|
|
43
|
-
<Stat ... /> # 输出展示
|
|
44
|
-
```
|
|
45
|
-
````
|
|
46
|
-
|
|
47
|
-
## 字段
|
|
48
|
-
|
|
49
|
-
围栏写 ` ```garden interactive #<id> `(编辑器代码片段触发词 `;ginteractive`)。`---` 分隔线上方是 YAML 头部字段,下方是声明式交互标签(运行 `npx garden ui catalog` 可在 `.garden/ui-catalog.html` 查看全部内部标签参考);YAML 头部语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
50
|
-
|
|
51
|
-
| 字段或标签 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
52
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
53
|
-
| `#<id>` / `id` | 必填 | 无 | 小写字母、数字与连字符 `^[a-z0-9]+(?:-[a-z0-9]+)*$`,篇内唯一;缺失或格式不合法报 `ui-id` 错误 | 写在围栏行末尾(如 `#reading-time`)或 YAML 头部 |
|
|
54
|
-
| `caption` | 必填 | 无 | 非空字符串;缺失或为空报 `ui-caption` 错误 | 图框说明,写出默认状态能看出的结论 |
|
|
55
|
-
| `intent` | 可选 | 无 | 字符串(非字符串报 `ui-header` 错误;改过原话但未重编译时报 `ui-stale` 警告) | 生成该块时的作者原始自然语言想法 |
|
|
56
|
-
| `expect` | 可选 | 无 | `{ given: {...}, <变量名>: <期望值> }[]`(非数组报 `ui-header` 错误,格式不对或断言不通过报 `ui-expect` 错误) | 数值断言列表,`npx garden ui check` 会自动验算(近似值可写 `{ value, tol }`) |
|
|
57
|
-
| `<State />` | 必填 | 无 | 小写字母开头的属性名配数字、字符串或布尔字面量(名字非法、重复或非字面量报 `ui-prop` 错误) | 声明可调状态变量及默认值,如 `<State words={6000} />` |
|
|
58
|
-
| `<Let />` | 可选 | 无 | 表达式属性(引用未知变量或禁用语法报 `ui-expr` 错误,互相依赖成环报 `ui-cycle` 错误,求值出错报 `ui-eval` 错误,全块只有一次简单乘法报 `interactive-trivial` 错误) | 由状态变量派生计算出的中间值、数组或对象 |
|
|
59
|
-
| `<Data />` | 可选 | 无 | `name`(合法标识符)与 `src`(同名子目录下的 `.csv` / `.json`;越界、缺失或解析失败报 `ui-data` 错误) | 引用随文数据文件 |
|
|
60
|
-
| `<Slider />` / `<Stepper />` / `<Toggle />` | 至少一项输入控件 | `Slider`: `scale="linear"`, `snap="none"`(对数且端点为 2 的幂时默认 `"pow2"`);`Stepper`: `step={1}` | `bind` 必须绑定已声明且类型匹配的状态(否则报 `ui-bind` 错误);`max <= min`、对数刻度 `min <= 0` 或默认值越界报 `ui-prop` 错误 | 绑定数字或布尔状态的输入控件 |
|
|
61
|
-
| `<Choice />` / `<Checklist />` / `<Button />` | 可选输入控件 | `Button`: `tone="plain"` | `<Choice>` 的 `options` 限 `2`~`8` 项(超出报 `ui-limit` 错误,默认值不在选项内报 `ui-prop` 错误);`<Checklist>` 的 `items` 限 `1`~`30` 项(超出报 `ui-limit` 错误);`<Button>` 必填且只能填 `set` 或 `reset` 之一(否则报 `ui-prop` 错误) | 选项切换、可勾选清单与状态重置按钮 |
|
|
62
|
-
| `<Stack />` / `<Columns />` / `<Tabs />` / `<Steps />` | 可选布局容器 | `Stack`: `gap={3}`, `direction="col"`;`Columns`: `gap={3}`, `min={220}`;`Steps`: `autoplay={false}` | `gap` 限 `0`~`4` 整数、`Columns.min` 限 `160`~`400`、`Steps.autoplay` 限 `false` 或 `>= 800`(违规报 `ui-prop` 错误);`<Columns>` 最多 `4` 列、`<Tabs>` 限 `2`~`6` 个 `<Tab>`、`<Steps>` 限 `2`~`24` 个 `<Step>`(超出报 `ui-limit` 错误,子元素类型不对报 `ui-children` 错误,步骤只放散文且无状态变化报 `steps-prose` 错误) | 分栏、标签页与分步容器(`<Each>` 超过 `200` 项时只显示前 `200` 项,不报 `ui-limit`;整块展开元素上限 `200` 个,超出报 `ui-limit` 错误) |
|
|
63
|
-
| `<Stat />` / `<Meter />` / `<Chart />` / `<Pie />` | 至少一项输出展示 | `Stat`: `tone="plain"`, `size="md"`;`Meter`: `tone="accent"`;`Chart`: `samples={64}`, `yScale="linear"`, `height={200}` | `<Meter>` 的 `parts` 最多 `5` 段、`<Pie>` 限 `1`~`8` 个 `<Slice>`、`<Chart>` 限 `1`~`4` 个系列子元素且 `data` 模式最多 `2000` 个数据点(超出均报 `ui-limit` 错误);`<Chart>` 的 `samples` 限 `2`~`200`、`height` 限 `120`~`480`(超出报 `ui-prop` 错误) | 实时展示随状态变化的数字、占比条、圆环图与曲线/柱状图 |
|
|
64
|
-
| `<Table />` / `<Grid />` / `<Image />` / `<Code />` / `<Diagram />` / `<Sandbox />` | 可选展示组件 | 无 | `<Table>` 最多 `50` 行、`<Grid>` 的 `cols` 最多 `16` 列且限 `1`~`16` 行、`<Image>` 最多 `12` 个 `<Hotspot>`、`<Code>` 最多 `60` 行、`<Sandbox>` 的 `html` 最多 `12000` 字且 `css` 与 `js` 各最多 `8000` 字(超出均报 `ui-limit` 错误;未知标签报 `ui-component` 错误;块内写 Markdown 标题、代码围栏、HTML 或图片语法报 `ui-markdown` 错误,JSX 语法错误报 `ui-syntax` 错误) | 数据表、检视格、热点图、代码走查、Mermaid 状态图与自包含沙盒 |
|
|
65
|
-
|
|
66
|
-
## 限制与报错
|
|
67
|
-
|
|
68
|
-
- 头部:`ui-id`(缺 id 或格式不对)、`ui-caption`(缺 caption)、`ui-header`(`intent` 不是字符串或 `expect` 不是列表)、`ui-expect`(断言格式不对或不通过)、`ui-stale`(警告:改过原话但没重新编译)。
|
|
69
|
-
- 标签:`ui-prop`、`ui-expr`、`ui-cycle`、`ui-eval`、`ui-data`、`ui-bind`、`ui-limit`、`ui-children`、`ui-component`、`ui-markdown`、`ui-syntax`,各自的触发条件见上表。
|
|
70
|
-
- 整块:`interactive-trivial`(只有一次简单乘法)、`steps-prose`(步骤只是散文,没有状态变化)。
|
|
71
|
-
- 运行 `npx garden ui check` 可以拿到修复提示词。
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · list
|
|
3
|
-
navTitle: list
|
|
4
|
-
description: 用线条图标配短句列出几条并列动作,或带小标题列出分步做法。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 11
|
|
7
|
-
badge: list
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:图标列表](/garden/components/list)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden list
|
|
15
|
-
items:
|
|
16
|
-
- icon: search
|
|
17
|
-
text: 搜索这个月的书名
|
|
18
|
-
- icon: eye
|
|
19
|
-
text: 看了 3 篇书评
|
|
20
|
-
- icon: heart
|
|
21
|
-
text: 收藏了活动页面
|
|
22
|
-
- icon: chat
|
|
23
|
-
text: 在群里问能不能只听不说
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```garden list
|
|
27
|
-
items:
|
|
28
|
-
- icon: flask
|
|
29
|
-
title: 实验一:一个月读一本是不是太多?
|
|
30
|
-
text:
|
|
31
|
-
- 前两次活动分别选一本中篇和一本长篇,记录每个人读完的比例。
|
|
32
|
-
- 读完比例明显下降时,下次改成只读前半本。
|
|
33
|
-
- icon: chat
|
|
34
|
-
title: 实验二:怎样让第一次来的人开口?
|
|
35
|
-
text:
|
|
36
|
-
- 一半活动先轮流说一句话,另一半直接自由讨论。
|
|
37
|
-
- 比较第一次来的人发言的次数。
|
|
38
|
-
- icon: bell
|
|
39
|
-
title: 实验三:提醒要提前几天发?
|
|
40
|
-
text:
|
|
41
|
-
- 分别在活动前三天和前一天发提醒,看到场人数有没有差别。
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## 字段写法
|
|
45
|
-
|
|
46
|
-
````markdown
|
|
47
|
-
```garden list
|
|
48
|
-
title: # 可选,总标题
|
|
49
|
-
items: # 必填,列表项
|
|
50
|
-
- icon: # 可选,23 个图标名之一
|
|
51
|
-
title: # 可选,写了就变步骤列表
|
|
52
|
-
text: # 建议填,说明
|
|
53
|
-
caption: # 可选,图注
|
|
54
|
-
```
|
|
55
|
-
````
|
|
56
|
-
|
|
57
|
-
## 字段
|
|
58
|
-
|
|
59
|
-
围栏写 ` ```garden list `(编辑器代码片段触发词 `;glist`)。YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
60
|
-
|
|
61
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
62
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
63
|
-
| `title` | 可选 | 无 | 字符串 | 列表上方的总标题 |
|
|
64
|
-
| `items` | 必填 | `[]` | 对象或字符串数组 | 列表项;所有条目都不带 `title` 时渲染为紧凑图标卡片,任一条目带 `title` 时渲染为带分隔线的步骤列表 |
|
|
65
|
-
| `items[].icon` | 可选 | 无(不绘制图标) | 23 个内置图标名之一:`search`、`eye`、`heart`、`chat`、`shield`、`wallet`、`bell`、`check`、`x`、`star`、`flag`、`clock`、`idea`、`book`、`link`、`user`、`chart`、`gear`、`file`、`pin`、`flask`、`target`、`question` | 线条图标名(未识别的名称不显示图标) |
|
|
66
|
-
| `items[].title` | 可选 | 无(默认紧凑行模式) | 字符串 | 条目小标题;填写后整组切换为带分隔线的步骤布局 |
|
|
67
|
-
| `items[].text` | 建议填写 | `[]` | 字符串或字符串数组 | 条目说明文字;写成数组时每个元素渲染为独立段落 |
|
|
68
|
-
| `caption` | 可选 | 无 | 字符串 | 列表底部的图注 |
|
|
69
|
-
|
|
70
|
-
## 限制与报错
|
|
71
|
-
|
|
72
|
-
- 除通用的 `garden-yaml` 外,本组件没有专属报错代码;表里写「不做校验」的建议值不会报错。
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · relations
|
|
3
|
-
navTitle: relations
|
|
4
|
-
description: 把三到六个要素排成环或中心辐射结构,画出谁影响谁、哪些是双向的。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 10
|
|
7
|
-
badge: relations
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:关系图](/garden/components/relations)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden relations
|
|
15
|
-
items:
|
|
16
|
-
- title: 选书
|
|
17
|
-
text: 定下这个月读什么
|
|
18
|
-
- title: 共读
|
|
19
|
-
text: 每周读完约定的章节
|
|
20
|
-
- title: 讨论
|
|
21
|
-
text: 见面聊各自的看法
|
|
22
|
-
- title: 复盘
|
|
23
|
-
text: 记下下次要改的地方
|
|
24
|
-
links:
|
|
25
|
-
- from: 1
|
|
26
|
-
to: 2
|
|
27
|
-
- from: 2
|
|
28
|
-
to: 3
|
|
29
|
-
- from: 3
|
|
30
|
-
to: 4
|
|
31
|
-
- from: 4
|
|
32
|
-
to: 1
|
|
33
|
-
- from: 3
|
|
34
|
-
to: 1
|
|
35
|
-
style: dashed
|
|
36
|
-
label: 影响选书
|
|
37
|
-
- from: 2
|
|
38
|
-
to: 4
|
|
39
|
-
style: dashed
|
|
40
|
-
caption: 四个环节互相提供信息,而不是按固定顺序走一遍。
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
```garden relations
|
|
44
|
-
items:
|
|
45
|
-
- title: 组织者
|
|
46
|
-
text: 每月发一次通知
|
|
47
|
-
- title: 成员
|
|
48
|
-
text: 八到十个邻居
|
|
49
|
-
- title: 场地
|
|
50
|
-
text: 咖啡馆或图书馆
|
|
51
|
-
- title: 书单
|
|
52
|
-
text: 大家轮流提名
|
|
53
|
-
center: 组织者
|
|
54
|
-
links:
|
|
55
|
-
- from: 1
|
|
56
|
-
to: 2
|
|
57
|
-
label: 邀请
|
|
58
|
-
- from: 1
|
|
59
|
-
to: 3
|
|
60
|
-
label: 预约
|
|
61
|
-
- from: 1
|
|
62
|
-
to: 4
|
|
63
|
-
label: 汇总
|
|
64
|
-
- from: 2
|
|
65
|
-
to: 4
|
|
66
|
-
style: dashed
|
|
67
|
-
direction: both
|
|
68
|
-
label: 提名
|
|
69
|
-
caption: 组织者放在正中,连着外圈的其余三个;成员和书单互相影响。
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## 字段写法
|
|
73
|
-
|
|
74
|
-
````markdown
|
|
75
|
-
```garden relations
|
|
76
|
-
title: # 可选,无障碍标签
|
|
77
|
-
items: # 必填,3–6 项
|
|
78
|
-
- title: # 必填,要素名
|
|
79
|
-
text: # 可选,一句说明
|
|
80
|
-
center: # 可选,序号或标题
|
|
81
|
-
links: # 可选,连线列表
|
|
82
|
-
- from: # 必填,序号或标题
|
|
83
|
-
to: # 必填,不能同 from
|
|
84
|
-
style: # solid | dashed
|
|
85
|
-
direction: # one | both
|
|
86
|
-
label: # 可选,短标签
|
|
87
|
-
caption: # 可选,图注
|
|
88
|
-
```
|
|
89
|
-
````
|
|
90
|
-
|
|
91
|
-
## 字段
|
|
92
|
-
|
|
93
|
-
围栏写 ` ```garden relations `(编辑器代码片段触发词 `;grel`)。节点没有强调色选项,所有要素视觉权重相同;其他图形直接写 ` ```mermaid ` 围栏,只走一遍的步骤用 `garden list`。YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
94
|
-
|
|
95
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
96
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
97
|
-
| `title` | 可选 | 无障碍标签默认 `"关系图"`(不渲染可视标题) | 字符串 | 关系图上方的标题 |
|
|
98
|
-
| `items` | 必填 | 无 | 对象数组,严格 `3`~`6` 项(少于 `3` 项或多于 `6` 项报 `garden-relations` 错误) | 要素列表;未设 `center` 时从正上方(12 点钟方向)起顺时针均布在椭圆上 |
|
|
99
|
-
| `items[].title` | 必填 | `""` | 字符串 | 节点标题(`links` 与 `center` 按序号或完整标题引用节点) |
|
|
100
|
-
| `items[].text` | 可选 | `""` | 字符串 | 节点标题下方的一句短说明 |
|
|
101
|
-
| `center` | 可选 | 无(全部要素排在外圈椭圆上) | `1..N` 序号(从 `1` 开始)或节点完整 `title`(找不到对应要素时报 `garden-relations` 错误) | 写在 `items` 与 `links` 之间:把该要素放在正中间,其余要素从正上方起顺时针均布在外圈;不做自动识别 |
|
|
102
|
-
| `links` | 可选 | `[]` | 对象数组(非数组或条目含未知键名时报 `garden-relations` 错误) | 节点之间的连线;外圈相邻要素连线向外轻弧弯曲,其余连线从中间直穿;首尾相接的循环把每一步写成一条 `link`(如 `1->2`、`2->3`、`3->4`、`4->1`) |
|
|
103
|
-
| `links[].from` | 必填 | 无 | `1..N` 序号或节点完整 `title`,且不能与 `to` 相同(缺失、找不到要素或与 `to` 相同时报 `garden-relations` 错误) | 起点要素 |
|
|
104
|
-
| `links[].to` | 必填 | 无 | `1..N` 序号或节点完整 `title`,且不能与 `from` 相同(缺失、找不到要素或与 `from` 相同时报 `garden-relations` 错误) | 终点要素 |
|
|
105
|
-
| `links[].style` | 可选 | `"solid"` | `"solid"` \| `"dashed"`(其他取值报 `garden-relations` 错误) | 实线(`→` / `↔`)或虚线(`⇢` / `⇠⇢`) |
|
|
106
|
-
| `links[].direction` | 可选 | `"one"` | `"one"` \| `"both"`(其他取值报 `garden-relations` 错误) | 单向箭头(指向 `to`)或两端双箭头 |
|
|
107
|
-
| `links[].label` | 可选 | `""` | 短字符串(非字符串类型报 `garden-relations` 错误) | 连线上的短标签(带底色衬垫并自动避开线条交叉点;在连线上放不下时改为圆圈序号,并在图下列出,如「`① 限制:预算 → 场地`」) |
|
|
108
|
-
| `caption` | 可选 | 无 | 字符串 | 关系图底部的图注 |
|
|
109
|
-
|
|
110
|
-
## 限制与报错
|
|
111
|
-
|
|
112
|
-
- `garden-relations`:`items` 少于 3 项或多于 6 项;`center` 找不到要素;`links` 不是列表或条目含未知键名;`from` / `to` 缺失、找不到或相同;`style`、`direction` 取值不对;`label` 不是字符串。
|
|
113
|
-
- 要素更多、有分支时改用 ```` ```mermaid ```` 流程图;只走一遍的步骤用 `garden list`。
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · stat
|
|
3
|
-
navTitle: stat
|
|
4
|
-
description: 把 2~4 个关键数字、单位与一句说明并排摆出来。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 2
|
|
7
|
-
badge: stat
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:数字指标](/garden/components/stat)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden stat
|
|
15
|
-
items:
|
|
16
|
-
- label: 正文列宽
|
|
17
|
-
value: "740"
|
|
18
|
-
unit: px
|
|
19
|
-
caption: 默认阅读列宽度
|
|
20
|
-
- label: 宽图上限
|
|
21
|
-
value: "1040"
|
|
22
|
-
unit: px
|
|
23
|
-
caption: 左右各最多向外延伸 150px
|
|
24
|
-
- label: 宽表上限
|
|
25
|
-
value: "1340"
|
|
26
|
-
unit: px
|
|
27
|
-
caption: 左右各最多向外延伸 300px
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## 字段写法
|
|
31
|
-
|
|
32
|
-
````markdown
|
|
33
|
-
```garden stat
|
|
34
|
-
items: # 多项时写,建议 2–4 项
|
|
35
|
-
- label: # 必填,指标名
|
|
36
|
-
value: # 必填,数字
|
|
37
|
-
unit: # 可选,单位
|
|
38
|
-
caption: # 可选,一句说明
|
|
39
|
-
text: # 可选,补充说明
|
|
40
|
-
source: # 可选,来源网址
|
|
41
|
-
```
|
|
42
|
-
````
|
|
43
|
-
|
|
44
|
-
## 字段
|
|
45
|
-
|
|
46
|
-
围栏写 ` ```garden stat `(编辑器代码片段触发词 `;gstat`)。多个指标放在 `items` 数组里,单个指标也可以直接把字段写在顶层;YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
47
|
-
|
|
48
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
49
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
50
|
-
| `items` | 多项时必填 | `[顶层对象]` | 对象数组(建议 `2`~`4` 项,不做校验) | 并排展示的指标项列表;省略 `items` 时直接将顶层字段作为单项指标渲染 |
|
|
51
|
-
| `label` | 必填 | `""` | 字符串 | 数字上方的指标名称 |
|
|
52
|
-
| `value` | 必填 | `""` | 字符串或数字 | 大号等宽字体显示的核心数值 |
|
|
53
|
-
| `unit` | 可选 | 无 | 字符串 | 紧跟在 `value` 右侧的单位 |
|
|
54
|
-
| `caption` | 可选 | 无 | 字符串 | 数字下方的简短说明 |
|
|
55
|
-
| `text` | 可选 | 无 | 字符串 | 补充说明文字 |
|
|
56
|
-
| `source` | 可选 | 无 | 网址、`{ url, site?, icon? }` 或数组 | 来源胶囊标签(未填 `site` 时默认取网址去掉 `www.` 后的域名) |
|
|
57
|
-
|
|
58
|
-
## 限制与报错
|
|
59
|
-
|
|
60
|
-
- 除通用的 `garden-yaml` 外,本组件没有专属报错代码;表里写「不做校验」的建议值不会报错。
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 组件参考 · timeline
|
|
3
|
-
navTitle: timeline
|
|
4
|
-
description: 按时间或阶段顺序排开版本演进、排查经过或关键节点。
|
|
5
|
-
section: reference
|
|
6
|
-
order: 4
|
|
7
|
-
badge: timeline
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
[← 组件参考](/garden/reference) · [用法:时间线](/garden/components/timeline)
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
```garden timeline
|
|
15
|
-
title: 静态发布流水线执行步骤
|
|
16
|
-
items:
|
|
17
|
-
- date: 步骤 1
|
|
18
|
-
title: 同步内容与静态资源
|
|
19
|
-
text: 校验文章信息、复制图片附件并生成搜索索引与 RSS。
|
|
20
|
-
- date: 步骤 2
|
|
21
|
-
title: 构建静态站点产物
|
|
22
|
-
text: 把全部页面预渲染到静态目录。
|
|
23
|
-
- date: 步骤 3
|
|
24
|
-
title: 校验静态页面并部署
|
|
25
|
-
text: 检查导出文件完整无误后发布到 GitHub Pages。
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 字段写法
|
|
29
|
-
|
|
30
|
-
````markdown
|
|
31
|
-
```garden timeline
|
|
32
|
-
title: # 可选,总标题
|
|
33
|
-
items: # 必填,按时间先后
|
|
34
|
-
- date: # 可选,时间点
|
|
35
|
-
title: # 必填,节点标题
|
|
36
|
-
text: # 可选,说明
|
|
37
|
-
source: # 可选,来源网址
|
|
38
|
-
```
|
|
39
|
-
````
|
|
40
|
-
|
|
41
|
-
## 字段
|
|
42
|
-
|
|
43
|
-
围栏写 ` ```garden timeline `(编辑器代码片段触发词 `;gtimeline`)。YAML 语法错误或顶层含未知键名时整块报 `garden-yaml` 错误。
|
|
44
|
-
|
|
45
|
-
| 字段 | 是否必填 | 默认值 | 取值与限制 | 说明 |
|
|
46
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
47
|
-
| `title` | 可选 | 无 | 字符串 | 时间线上方的总标题 |
|
|
48
|
-
| `items` | 必填 | `[]` | 对象数组(建议至少 `2` 项,不做校验) | 按先后顺序排列的节点列表 |
|
|
49
|
-
| `items[].date` | 可选 | 无 | 字符串 | 节点上方的时间点、年份或阶段编号 |
|
|
50
|
-
| `items[].title` | 必填 | `""` | 字符串 | 节点标题 |
|
|
51
|
-
| `items[].text` | 可选 | 无 | 字符串 | 节点的具体说明 |
|
|
52
|
-
| `items[].source` | 可选 | 无 | 网址、`{ url, site?, icon? }` 或数组 | 跟在节点说明后的来源胶囊(未填 `site` 时默认取网址去掉 `www.` 后的域名) |
|
|
53
|
-
|
|
54
|
-
## 限制与报错
|
|
55
|
-
|
|
56
|
-
- 除通用的 `garden-yaml` 外,本组件没有专属报错代码;表里写「不做校验」的建议值不会报错。
|
|
Binary file
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: garden-interactive-chart
|
|
3
|
-
description: >-
|
|
4
|
-
Writes Garden interactive charts as self-contained HTML in a same-name
|
|
5
|
-
sidecar directory and embeds them with a short garden html fence. Use when adding
|
|
6
|
-
or editing Garden widgets, steppers, inspect grids, param benches,
|
|
7
|
-
compare views, traces, KV cache charts, or any interactive chart / same-name directory HTML.
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Garden interactive charts
|
|
11
|
-
|
|
12
|
-
Complex interaction does not go into Markdown. Each post has a same-name directory, and every `.html` file in it is one chart that can be opened on its own. The post body only embeds a short fence.
|
|
13
|
-
|
|
14
|
-
Background: [Interactive components](https://github.com/hedon954/garden/blob/main/docs/interactive-blog-components.md). Finished examples to copy: [widget-kind-examples](https://github.com/hedon954/garden/tree/main/docs/widget-kind-examples).
|
|
15
|
-
|
|
16
|
-
## When to draw, when to stop
|
|
17
|
-
|
|
18
|
-
Ask first: is the reader stuck because a process was frozen into a photo, a parameter is a fixed example, two dimensions were flattened, a comparison needs scrolling back and forth, or a "what if" cannot be tried? If not, write prose or Mermaid.
|
|
19
|
-
|
|
20
|
-
Five primitives. Pick one before you draw:
|
|
21
|
-
|
|
22
|
-
| What the reader should do | Primitive | Copy from |
|
|
23
|
-
| --- | --- | --- |
|
|
24
|
-
| Stop at a given beat | Stepper | [stepper.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/stepper.html), [waste.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/waste.html) |
|
|
25
|
-
| Look at cells and talk about them | Inspect grid | [inspect-grid.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/inspect-grid.html) |
|
|
26
|
-
| Turn a knob, watch numbers or curves | Param bench | [param-bench.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/param-bench.html) |
|
|
27
|
-
| See both sides at the same moment | Compare view | [compare.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/compare.html) |
|
|
28
|
-
| See the current node and current edge | Trace | [trace.html](https://github.com/hedon954/garden/blob/main/docs/widget-kind-examples/trace.html) |
|
|
29
|
-
|
|
30
|
-
If it fits, change the data instead of adding a new type. Past about 9 nodes or 12 steps, split it into two charts.
|
|
31
|
-
|
|
32
|
-
## File conventions
|
|
33
|
-
|
|
34
|
-
When the Markdown is at `content/posts/<dir>/<slug>.md`, charts can only live in `content/posts/<dir>/<slug>/`:
|
|
35
|
-
|
|
36
|
-
```text
|
|
37
|
-
content/posts/windowsill-herbs.md
|
|
38
|
-
content/posts/windowsill-herbs/layers.html
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Body:
|
|
42
|
-
|
|
43
|
-
````md
|
|
44
|
-
```garden html
|
|
45
|
-
src: ./windowsill-herbs/layers.html
|
|
46
|
-
title: Water takes about a minute to seep from the soil surface to the drain hole.
|
|
47
|
-
```
|
|
48
|
-
````
|
|
49
|
-
|
|
50
|
-
Rules:
|
|
51
|
-
|
|
52
|
-
- `src` must be a local `.html` or `.pdf` in that same-name directory. It cannot point to `assets/`, another post, or `https://`
|
|
53
|
-
- HTML that reports its height with `garden-chart` is a chart and is shown inline. Plain HTML and PDF are folded into a preview entry by default and load when the reader opens them
|
|
54
|
-
- `title` must be a claim, not "see the chart below"
|
|
55
|
-
- One chart per HTML file. Use short kebab-case names such as `layers.html` or `diagram.html`
|
|
56
|
-
- The HTML is self-contained: CSS, SVG and scripts all live in that one file
|
|
57
|
-
- Write the HTML first, then the fence. Do not spell out step arrays or sample points in the fence
|
|
58
|
-
|
|
59
|
-
The build checks the path and copies the file to `/media/...`. A wrong path fails the build.
|
|
60
|
-
|
|
61
|
-
## Writing the HTML
|
|
62
|
-
|
|
63
|
-
1. Copy [references/shell.html](references/shell.html), or start from the closest example.
|
|
64
|
-
2. Use only the color and font tokens in [references/style.md](references/style.md). Do not invent a dark cinematic style.
|
|
65
|
-
3. Call the boot script in the shell: it reads `?theme=light|dark` and uses `ResizeObserver` to send `{ source: "garden-chart", height }` to the parent page.
|
|
66
|
-
4. Respect `prefers-reduced-motion: reduce`: autoplay stops at the first step or the final state.
|
|
67
|
-
5. Use native `button` and `input` controls. Bind sliders to fixed inputs. Never `eval` reader input, and never make network requests.
|
|
68
|
-
6. Open the HTML in a browser and walk the main path and the empty state. Then run `CONTENT_INCLUDE_DRAFTS=1 make dev` to check the embed.
|
|
69
|
-
|
|
70
|
-
## Don't
|
|
71
|
-
|
|
72
|
-
- Put steps, grids or formula sample points in Markdown
|
|
73
|
-
- Use remote scripts, remote iframes or any CDN (the system monospace stack is enough)
|
|
74
|
-
- Read or write the parent page's DOM or cookies, or depend on `allow-same-origin`
|
|
75
|
-
- Use MDX, JSX, or post-specific type names (for example `autoregressive-waste`)
|
|
76
|
-
- Make the interaction the only explanation: the surrounding prose must stand on its own
|
|
77
|
-
|
|
78
|
-
## Before you hand it in
|
|
79
|
-
|
|
80
|
-
- [ ] The file is in the same-name directory, and the fence has only `src` + `title`
|
|
81
|
-
- [ ] The HTML works when opened on its own, and the iframe grows to its height
|
|
82
|
-
- [ ] Light and dark themes both follow the Garden page
|
|
83
|
-
- [ ] No autoplay loop when reduced motion is on
|
|
84
|
-
- [ ] `title` gives the conclusion to readers without JS
|