Skip to content

Commit 0726600

Browse files
authored
docs: update site docs (#3)
* docs: add developer guide * docs(site): update docs * docs(site): migrate vitepress to docusaurus * refactor(infographic): fix structure issue * docs(site): add infographic demo * chore: update package name and registry * fix(infographic): fix code and test * chore(site): clear useless file * chore(infographic): update package * test(jsx): update test case * chore: add deploy workflow * chore(site): remove useless code
1 parent 3e5c558 commit 0726600

74 files changed

Lines changed: 23669 additions & 7966 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-site.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy Site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Install Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
with:
26+
run_install: false
27+
28+
- name: Get pnpm store directory
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- name: Setup pnpm cache
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Install dependencies
42+
run: pnpm install --no-frozen-lockfile
43+
44+
- name: Build all packages
45+
run: pnpm run build
46+
47+
- name: Build site
48+
run: pnpm --filter @antv/infographic-site build
49+
50+
- name: Deploy to GitHub Pages
51+
uses: peaceiris/actions-gh-pages@v4
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
publish_dir: ./packages/site/build
55+
publish_branch: gh-pages
56+
user_name: 'github-actions[bot]'
57+
user_email: 'github-actions[bot]@users.noreply.github.com'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ tsconfig.tsbuildinfo
77
pnpm-lock.yaml
88
coverage
99

10-
.claude
10+
.claude
11+
.docusaurus
12+
build

packages/dev/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/dev/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default defineConfig({
77
},
88
plugins: [tsconfigPaths()],
99
optimizeDeps: {
10-
include: ['@alipay/infographic-dev', '@antv/infographic-jsx'],
10+
include: ['@antv/infographic', '@antv/infographic-jsx'],
1111
},
1212
});

packages/infographic/README.md

Lines changed: 0 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -90,239 +90,6 @@ infographic.render();
9090
</html>
9191
```
9292

93-
## 📚 核心概念
94-
95-
### 数据 (Data)
96-
97-
数据是信息图的内容来源:
98-
99-
```typescript
100-
const data = {
101-
title: '标题',
102-
desc: '描述',
103-
items: [
104-
{
105-
icon: 'icon-name', // 图标
106-
label: '标签', // 标签
107-
desc: '描述文本', // 描述
108-
value: 100, // 数值
109-
children: [], // 子项(层级结构)
110-
},
111-
],
112-
};
113-
```
114-
115-
### 结构 (Structure)
116-
117-
结构定义了数据项的组织和布局方式:
118-
119-
- **列表结构** (`list-*`): `list-column`, `list-row`, `list-grid`, `list-waterfall`, `list-sector`
120-
- **对比结构** (`compare-*`): `compare-left-right`, `compare-mirror`
121-
- **顺序结构** (`sequence-*`): `sequence-timeline`, `sequence-steps`, `sequence-roadmap-vertical`
122-
- **层级结构** (`hierarchy-*`): `hierarchy-tree`, `hierarchy-pyramid`
123-
- **关系结构** (`relation-*`): `relation-circle`, `relation-network`
124-
125-
### 数据项 (Item)
126-
127-
数据项是信息图中的基本信息单元:
128-
129-
- 卡片类: `badge-card`, `compact-card`, `progress-card`, `ribbon-card`
130-
- 图表类: `chart-column`, `circular-progress`
131-
- 箭头类: `horizontal-icon-arrow`, `vertical-icon-arrow`
132-
- 文本类: `plain-text`, `bullet-text`, `done-list`
133-
- 等等...
134-
135-
### 主题 (Theme)
136-
137-
主题定义了信息图的视觉风格:
138-
139-
```typescript
140-
{
141-
theme: 'default',
142-
themeConfig: {
143-
colorPrimary: '#1890ff',
144-
fontFamily: 'Arial, sans-serif',
145-
stylize: 'rough', // 手绘风格
146-
}
147-
}
148-
```
149-
150-
## 📖 文档
151-
152-
- [入门教程](./tutorial.md) - 从零开始学习 Infographic
153-
- [API 文档](./api.md) - 完整的 API 参考
154-
- [数据项开发指南](./src/designs/items/prompt.md) - 创建自定义数据项
155-
- [结构开发指南](./src/designs/structures/prompt.md) - 创建自定义结构
156-
157-
## 🎨 示例
158-
159-
### 对比图
160-
161-
```typescript
162-
new Infographic({
163-
container: '#container',
164-
data: {
165-
title: '产品版本对比',
166-
items: [
167-
{ label: '基础版', value: 99, desc: '适合个人用户' },
168-
{ label: '专业版', value: 299, desc: '适合团队使用' },
169-
{ label: '企业版', value: 999, desc: '企业级解决方案' },
170-
],
171-
},
172-
design: {
173-
structure: 'compare-left-right',
174-
item: 'progress-card',
175-
},
176-
}).render();
177-
```
178-
179-
### 层级结构
180-
181-
```typescript
182-
new Infographic({
183-
container: '#container',
184-
data: {
185-
title: '组织架构',
186-
items: [
187-
{
188-
label: 'CEO',
189-
children: [
190-
{
191-
label: 'CTO',
192-
children: [
193-
{ label: '前端团队' },
194-
{ label: '后端团队' },
195-
],
196-
},
197-
{
198-
label: 'CMO',
199-
children: [
200-
{ label: '市场部' },
201-
{ label: '销售部' },
202-
],
203-
},
204-
],
205-
},
206-
],
207-
},
208-
design: {
209-
structure: 'hierarchy-tree',
210-
item: 'rounded-rect-node',
211-
},
212-
}).render();
213-
```
214-
215-
### 使用模板
216-
217-
```typescript
218-
import { Infographic } from '@antv/infographic';
219-
220-
new Infographic({
221-
container: '#container',
222-
template: 'process-flow',
223-
data: {
224-
title: '用户注册流程',
225-
items: [
226-
{ label: '填写信息' },
227-
{ label: '验证邮箱' },
228-
{ label: '完成注册' },
229-
],
230-
},
231-
}).render();
232-
```
233-
234-
## 🔧 配置选项
235-
236-
### InfographicOptions
237-
238-
```typescript
239-
interface InfographicOptions {
240-
container?: string | HTMLElement; // 容器
241-
width?: number; // 宽度
242-
height?: number; // 高度
243-
padding?: Padding; // 内边距
244-
template?: string; // 模板
245-
design?: DesignOptions; // 设计配置
246-
data: Data; // 数据
247-
theme?: string; // 主题
248-
themeConfig?: ThemeConfig; // 主题配置
249-
}
250-
```
251-
252-
详细配置请参考 [API 文档](./api.md)
253-
254-
## 🎯 扩展开发
255-
256-
### 注册自定义主题
257-
258-
```typescript
259-
import { registerTheme } from '@antv/infographic';
260-
261-
registerTheme('my-theme', {
262-
seed: {
263-
colorPrimary: '#722ed1',
264-
fontFamily: 'Georgia, serif',
265-
},
266-
});
267-
```
268-
269-
### 注册自定义模板
270-
271-
```typescript
272-
import { registerTemplate } from '@antv/infographic';
273-
274-
registerTemplate('my-template', {
275-
design: {
276-
structure: 'list-column',
277-
item: 'badge-card',
278-
},
279-
theme: 'default',
280-
});
281-
```
282-
283-
### 创建自定义数据项
284-
285-
详见 [数据项开发指南](./src/designs/items/prompt.md)
286-
287-
### 创建自定义结构
288-
289-
详见 [结构开发指南](./src/designs/structures/prompt.md)
290-
291-
## 🏗️ 项目结构
292-
293-
```
294-
packages/infographic/
295-
├── src/
296-
│ ├── designs/ # 设计资产
297-
│ │ ├── items/ # 数据项组件
298-
│ │ ├── structures/ # 结构组件
299-
│ │ ├── components/ # 通用组件
300-
│ │ ├── decorations/ # 装饰元素
301-
│ │ └── layouts/ # 布局组件
302-
│ ├── runtime/ # 运行时(入口)
303-
│ │ └── Infographic.tsx # 主类
304-
│ ├── options/ # 选项解析
305-
│ ├── resource/ # 资源加载
306-
│ ├── renderer/ # SVG 渲染器
307-
│ ├── themes/ # 主题系统
308-
│ ├── templates/ # 模板注册
309-
│ ├── types/ # 类型定义
310-
│ └── utils/ # 工具函数
311-
├── api.md # API 文档
312-
├── tutorial.md # 入门教程
313-
└── README.md # 本文件
314-
```
315-
316-
## 🤝 贡献
317-
318-
欢迎贡献代码、报告 Bug 或提出新功能建议!
319-
320-
1. Fork 本仓库
321-
2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
322-
3. 提交你的修改 (`git commit -m 'Add some AmazingFeature'`)
323-
4. 推送到分支 (`git push origin feature/AmazingFeature`)
324-
5. 开启一个 Pull Request
325-
32693
## 📄 许可证
32794

32895
本项目基于 MIT 许可证开源 - 详见 [LICENSE](../../LICENSE) 文件

0 commit comments

Comments
 (0)