Skip to content

Commit 0ae2f7f

Browse files
committed
chore: update docs
1 parent 52b1471 commit 0ae2f7f

File tree

8 files changed

+124
-21
lines changed

8 files changed

+124
-21
lines changed
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState, useEffect } from 'react';
22
import { useLocation } from 'react-router-dom';
3+
import { useLocaleContext } from '../context/locale-context';
34

45
export interface HeadingItem {
56
id: string;
@@ -18,34 +19,31 @@ const queryHeadings = (): HeadingItem[] => {
1819

1920
export const useHeadings = (): HeadingItem[] => {
2021
const { pathname } = useLocation();
22+
const { locale } = useLocaleContext();
2123
const [headings, setHeadings] = useState<HeadingItem[]>([]);
2224

2325
useEffect(() => {
2426
setHeadings([]);
2527

26-
// Try immediately in case content is already rendered
27-
const initial = queryHeadings();
28-
if (initial.length > 0) {
29-
setHeadings(initial);
30-
return;
31-
}
32-
33-
// Otherwise observe DOM changes until headings appear
3428
const container = document.querySelector('.doc-container__layout');
3529
if (!container) return;
3630

37-
const observer = new MutationObserver(() => {
31+
const update = () => {
3832
const found = queryHeadings();
3933
if (found.length > 0) {
4034
setHeadings(found);
41-
observer.disconnect();
4235
}
43-
});
36+
};
37+
38+
// Try immediately in case content is already rendered
39+
update();
4440

41+
// Also observe DOM changes to catch async content swaps (e.g. locale toggle)
42+
const observer = new MutationObserver(update);
4543
observer.observe(container, { childList: true, subtree: true });
4644

4745
return () => observer.disconnect();
48-
}, [pathname]);
46+
}, [pathname, locale]);
4947

5048
return headings;
5149
};

packages/react/src/alert/index.zh_CN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import TitleDemo from './demo/Title';
1010
import TitleSource from './demo/Title.tsx?raw';
1111
import TypeDemo from './demo/Type';
1212
import TypeSource from './demo/Type.tsx?raw';
13+
import LoopBannerDemo from './demo/LoopBanner';
14+
import LoopBannerSource from './demo/LoopBanner.tsx?raw';
1315

1416
# Alert 警告提示
1517

@@ -85,6 +87,15 @@ import { Alert } from 'tiny-design';
8587

8688
<DemoBlock component={CloseBtnDemo} source={CloseBtnSource} />
8789

90+
</Demo>
91+
<Demo>
92+
93+
### 循环横幅
94+
95+
结合 `Marquee` 组件创建滚动横幅警告。文本在鼠标悬停时会暂停滚动。
96+
97+
<DemoBlock component={LoopBannerDemo} source={LoopBannerSource} />
98+
8899
</Demo>
89100
</Column>
90101
</Layout>

packages/react/src/flex/index.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@ import WrapSource from './demo/Wrap.tsx?raw';
1111

1212
A flexbox container component using CSS `gap` for spacing with no child wrapping.
1313

14-
## Scenario
14+
## When To Use
1515

16-
Use Flex when you need a lightweight flexbox layout without wrapping each child in additional elements.
16+
Flex is a one-dimensional layout container best suited for arranging items in a single row or column.
17+
18+
- **Toolbars & action bars** — align a group of buttons, icons, or controls horizontally with consistent spacing.
19+
- **Navigation menus** — lay out nav items in a row or a vertical sidebar list.
20+
- **Form field rows** — place a label, input, and helper text side by side.
21+
- **Card footers / headers** — push actions to opposite ends with `justify="space-between"`.
22+
- **Vertical stacking** — use `vertical` to stack content like a list of cards or settings sections.
23+
- **Inline tag / badge groups** — render a wrapping set of tags with `wrap="wrap"` and a uniform `gap`.
24+
25+
### Flex vs Row
26+
27+
Both use flexbox under the hood, but they serve different purposes:
28+
29+
- Choose **Flex** when you need a general-purpose flexbox container with CSS `gap` and no column semantics.
30+
- Choose **Row / Col** when you need a 24-column grid structure with `span`, `offset`, and responsive breakpoints (`xs` through `xxl`).
1731

1832
## Usage
1933

packages/react/src/flex/index.zh_CN.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@ import WrapSource from './demo/Wrap.tsx?raw';
1313

1414
## 使用场景
1515

16-
需要轻量级弹性布局时使用,无需为每个子元素添加额外的包裹元素。
16+
Flex 是一个一维布局容器,适合将元素排列在一行或一列中。
17+
18+
- **工具栏与操作栏** — 将一组按钮、图标或控件水平排列,间距一致。
19+
- **导航菜单** — 水平排列导航项,或构建垂直侧边栏列表。
20+
- **表单字段行** — 将标签、输入框和提示文字并排放置。
21+
- **卡片头部 / 底部** — 使用 `justify="space-between"` 将操作按钮推到两端。
22+
- **垂直堆叠** — 使用 `vertical` 纵向堆叠内容,如卡片列表或设置分组。
23+
- **标签 / 徽标组** — 配合 `wrap="wrap"` 和统一的 `gap` 渲染可自动换行的标签集合。
24+
25+
### Flex 与 Row 的区别
26+
27+
两者底层都使用 Flexbox,但适用场景不同:
28+
29+
- 选择 **Flex** — 需要一个通用的弹性盒子容器,使用 CSS `gap` 控制间距,不涉及栏数语义。
30+
- 选择 **Row / Col** — 需要 24 栏栅格结构,使用 `span``offset` 和响应式断点(`xs``xxl`)。
1731

1832
## 使用方式
1933

packages/react/src/grid/index.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@ import { Grid } from 'tiny-design';
2525

2626
## When To Use
2727

28-
- Use `Grid System` (`Row` / `Col`) for classic page columns, marketing layouts, and 24-column responsive structure.
29-
- Use `Grid` for dashboard shells, editor workbenches, card walls, named areas, row spanning, and two-dimensional composition.
30-
- If you are migrating from MUI `Grid`, start with `spacing`, `rowSpacing`, `columnSpacing`, `size`, and `offset`, then adopt `areas` or `rowSpan` when you need layouts that flex grids cannot express.
28+
Grid is a two-dimensional layout component built on CSS Grid. It excels when you need control over both rows **and** columns simultaneously.
29+
30+
- **Dashboard shells** — define named `areas` like `"sidebar header" "sidebar main"` for application-level page structure.
31+
- **Card walls / galleries** — use `minColumnWidth` with `autoFit` to create responsive card grids that reflow without manual breakpoints.
32+
- **Data-dense UIs** — use explicit `columns` and `rows` to build spreadsheet-like or calendar-like layouts where items span multiple rows or columns.
33+
- **Asymmetric layouts** — use `Grid.Item colSpan` and `rowSpan` to create hero sections or featured cards that span across tracks.
34+
- **Responsive rearrangement** — pass responsive objects to `columns`, `gap`, and `areas` to radically change the layout across breakpoints (e.g. stacking sidebar below content on mobile).
35+
36+
### Grid vs Grid System (Row / Col)
37+
38+
| | Grid | Grid System (Row / Col) |
39+
|---|---|---|
40+
| CSS technology | CSS Grid | Flexbox + 24-column math |
41+
| Dimensions | Two-dimensional (rows + columns) | One-dimensional (columns only) |
42+
| Best for | Dashboards, card walls, named areas, row spanning | Classic page columns, form layouts, marketing pages |
43+
| Responsive | Responsive props on any value | Breakpoint props (`xs``xxl`) on Col |
44+
45+
- If you are migrating from **MUI Grid**, start with `spacing`, `rowSpacing`, `columnSpacing`, `size`, and `offset`, then adopt `areas` or `rowSpan` when you need layouts that flex grids cannot express.
3146

3247
## Examples
3348

packages/react/src/grid/index.zh_CN.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@ import { Grid } from 'tiny-design';
2525

2626
## 适用场景
2727

28-
- `Grid System``Row` / `Col`)更适合经典页面分栏、营销页和 24 栅格结构。
29-
- `Grid` 更适合 dashboard 壳层、编辑器工作台、卡片墙、命名区域、跨行布局和二维组合。
30-
- 如果你是从 MUI `Grid` 迁移过来,可以先使用 `spacing``rowSpacing``columnSpacing``size``offset`,再逐步使用 `areas``rowSpan` 这些更强的 CSS Grid 能力。
28+
Grid 是一个基于 CSS Grid 的二维布局组件,适合同时控制行****列的场景。
29+
30+
- **Dashboard 壳层** — 使用 `areas` 定义命名区域,如 `"sidebar header" "sidebar main"`,构建应用级页面骨架。
31+
- **卡片墙 / 图库** — 使用 `minColumnWidth` 配合 `autoFit`,创建无需手动断点即可自动回流的响应式卡片网格。
32+
- **数据密集型界面** — 使用显式 `columns``rows`,构建类似表格或日历的布局,子项可跨越多行多列。
33+
- **非对称布局** — 使用 `Grid.Item``colSpan``rowSpan`,创建跨轨道的 Hero 区域或特色卡片。
34+
- **响应式重排** — 向 `columns``gap``areas` 传入响应式对象,在不同断点下彻底改变布局(如移动端将侧边栏堆叠到内容下方)。
35+
36+
### Grid 与 Grid System(Row / Col)对比
37+
38+
| | Grid | Grid System(Row / Col) |
39+
|---|---|---|
40+
| CSS 技术 | CSS Grid | Flexbox + 24 栏数学计算 |
41+
| 布局维度 | 二维(行 + 列) | 一维(仅列) |
42+
| 最佳场景 | Dashboard、卡片墙、命名区域、跨行布局 | 经典页面分栏、表单布局、营销页 |
43+
| 响应式方式 | 任意属性均支持响应式对象 | Col 上的断点属性(`xs``xxl`|
44+
45+
- 如果你是从 **MUI Grid** 迁移过来,可以先使用 `spacing``rowSpacing``columnSpacing``size``offset`,再逐步使用 `areas``rowSpan` 这些更强的 CSS Grid 能力。
3146

3247
## 代码示例
3348

packages/react/src/row/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ Use `Row` and `Col` to build classic 24-column page grids with responsive breakp
2121
import { Row, Col } from 'tiny-design';
2222
```
2323

24+
## When To Use
25+
26+
Grid System provides a familiar 24-column grid powered by Flexbox — the same mental model used by Bootstrap and Ant Design.
27+
28+
- **Page-level content columns** — split a page into sidebar (6 columns) and main content (18 columns) with a single `gutter`.
29+
- **Form layouts** — align labels and inputs into consistent columns across different form sections.
30+
- **Marketing / landing pages** — create hero sections, feature grids, and pricing tables with predictable column math.
31+
- **Responsive column shifting** — use breakpoint props (`xs` through `xxl`) on `Col` to stack columns on mobile and spread them on desktop.
32+
- **Column offset & reordering** — use `offset` to create whitespace and `order` to rearrange columns visually without changing DOM order.
33+
34+
### Choosing between layout components
35+
36+
| Scenario | Recommended |
37+
|---|---|
38+
| Toolbar, button group, inline tags | **Flex** |
39+
| Page columns, form grid, marketing layout | **Grid System** (Row / Col) |
40+
| Dashboard shell, card wall, named areas, row spanning | **Grid** |
41+
2442
## Examples
2543

2644
<Demo>

packages/react/src/row/index.zh_CN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ import ResponsiveSource from '../grid/demo/Responsive.tsx?raw';
2121
import { Row, Col } from 'tiny-design';
2222
```
2323

24+
## 使用场景
25+
26+
Grid System 提供基于 Flexbox 的 24 栏栅格系统,与 Bootstrap 和 Ant Design 的心智模型一致。
27+
28+
- **页面级内容分栏** — 将页面拆分为侧边栏(6 栏)和主内容区(18 栏),通过 `gutter` 统一控制间距。
29+
- **表单布局** — 将标签和输入框对齐到一致的列中,保证不同表单区域的视觉统一。
30+
- **营销 / 落地页** — 创建 Hero 区域、功能网格和价格表,列数计算直观可预测。
31+
- **响应式列变化** — 在 `Col` 上使用断点属性(`xs``xxl`),实现移动端堆叠、桌面端展开。
32+
- **列偏移与重排** — 使用 `offset` 创建留白,使用 `order` 在不改变 DOM 顺序的情况下调整视觉排列。
33+
34+
### 布局组件选择指南
35+
36+
| 场景 | 推荐组件 |
37+
|---|---|
38+
| 工具栏、按钮组、内联标签 | **Flex** |
39+
| 页面分栏、表单栅格、营销页 | **Grid System**(Row / Col) |
40+
| Dashboard 壳层、卡片墙、命名区域、跨行布局 | **Grid** |
41+
2442
## 代码示例
2543

2644
<Demo>

0 commit comments

Comments
 (0)