Skip to content

Commit c77c023

Browse files
committed
docs(site): update docs
1 parent afff6c6 commit c77c023

File tree

13 files changed

+167
-78
lines changed

13 files changed

+167
-78
lines changed

packages/site/executors/build-base/files/resources.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"Overview": "Overview",
3131
"Getting Started": "Getting Started",
3232
"Dynamic Theme": "Dynamic Theme",
33-
"Internationalization": "Internationalization"
33+
"Internationalization": "Internationalization",
34+
"GlobalConfiguration": "GlobalConfiguration"
3435
},
3536
"menu": {
3637
"components-group": {},
@@ -71,7 +72,8 @@
7172
"Overview": "概述",
7273
"Getting Started": "快速开始",
7374
"Dynamic Theme": "动态主题",
74-
"Internationalization": "国际化"
75+
"Internationalization": "国际化",
76+
"GlobalConfiguration": "全局配置"
7577
},
7678
"menu": {
7779
"components-group": {},

packages/site/src/app/routes/docs/Internationalization/Internationalization.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Internationalization
22

3-
Here is the [full configuration](https://github.com/DevCloudFE/react-devui/blob/main/packages/ui/src/hooks/i18n/resources.json).
3+
Here is the [full configuration](https://github.com/DevCloudFE/react-devui/blob/main/packages/ui/src/components/root/resources.json).
44

55
## Modify language
66

@@ -25,9 +25,9 @@ export default function App() {
2525
}
2626
```
2727

28-
## Modify language display
28+
## Modify modification
2929

30-
Support to modify the language display:
30+
Partially modifications are supported:
3131

3232
```tsx
3333
import type { DRootProps } from '@react-devui/ui';
@@ -68,8 +68,10 @@ export default function App() {
6868
const rootContext = useMemo<DRootProps['context']>(
6969
() => ({
7070
i18n: {
71+
lang: 'ja-JP',
7172
resources: {
7273
'ja-JP': { DatePicker: { Now: '' } },
74+
...otherConfig,
7375
},
7476
},
7577
}),

packages/site/src/app/routes/docs/Internationalization/Internationalization.zh-CN.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 国际化
22

3-
这里是[完整配置](https://github.com/DevCloudFE/react-devui/blob/main/packages/ui/src/hooks/i18n/resources.json)
3+
这里是[完整配置](https://github.com/DevCloudFE/react-devui/blob/main/packages/ui/src/components/root/resources.json)
44

55
## 修改语言
66

@@ -25,9 +25,9 @@ export default function App() {
2525
}
2626
```
2727

28-
## 修改语言显示
28+
## 部分修改
2929

30-
支持修改语言显示
30+
支持部分修改
3131

3232
```tsx
3333
import type { DRootProps } from '@react-devui/ui';
@@ -69,7 +69,11 @@ export default function App() {
6969
() => ({
7070
i18n: {
7171
resources: {
72-
'ja-JP': { DatePicker: { Now: '' } },
72+
lang: 'ja-JP',
73+
'ja-JP': {
74+
DatePicker: { Now: '' },
75+
...otherConfig,
76+
},
7377
},
7478
},
7579
}),

packages/site/src/app/routes/docs/dynamic-theme/DynamicTheme.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,3 @@ export default function App() {
2020
}, [theme]);
2121
}
2222
```
23-
24-
## Variable conflict
25-
26-
All our css variables have namespaces added, the default is `rd`, if our css variables conflict with your project, you can modify `$rd-namespace`.
27-
28-
Note: `$rd-namespace` also affects stylesheets, so you need to modify the `DRoot` configuration:
29-
30-
```scss
31-
$rd-namespace: 'app';
32-
```
33-
34-
```tsx
35-
import type { DRootProps } from '@react-devui/ui';
36-
37-
import { useMemo } from 'react';
38-
39-
import { DRoot } from '@react-devui/ui';
40-
41-
export default function App() {
42-
const rootContext = useMemo<DRootProps['context']>(
43-
() => ({
44-
namespace: 'app',
45-
}),
46-
[]
47-
);
48-
49-
return <DRoot context={rootContext}>Some content...</DRoot>;
50-
}
51-
```

packages/site/src/app/routes/docs/dynamic-theme/DynamicTheme.zh-CN.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,3 @@ export default function App() {
2020
}, [theme]);
2121
}
2222
```
23-
24-
## 变量冲突
25-
26-
我们的 css 变量均添加了命名空间,默认为 `rd`,如果我们的 css 变量与您项目冲突,可以修改 `$rd-namespace`
27-
28-
注意:`$rd-namespace` 同样影响样式表,所以您需要修改 `DRoot` 的配置:
29-
30-
```scss
31-
$rd-namespace: 'app';
32-
```
33-
34-
```tsx
35-
import type { DRootProps } from '@react-devui/ui';
36-
37-
import { useMemo } from 'react';
38-
39-
import { DRoot } from '@react-devui/ui';
40-
41-
export default function App() {
42-
const rootContext = useMemo<DRootProps['context']>(
43-
() => ({
44-
namespace: 'app',
45-
}),
46-
[]
47-
);
48-
49-
return <DRoot context={rootContext}>Some content...</DRoot>;
50-
}
51-
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# FAQ
2+
3+
Some frequently asked questions are listed below:
4+
5+
## Does the component library contain side effects?
6+
7+
The component library only covers the global `box-sizing`, which is currently the choice of most people:
8+
9+
```scss
10+
*,
11+
*::before,
12+
*::after {
13+
box-sizing: border-box;
14+
}
15+
```
16+
17+
## When components are controlled
18+
19+
We agree that `undefined` represents that the component is in an uncontrolled state, and other values represent that the component is controlled.
20+
21+
## What is the general null value of the controlled component
22+
23+
The null value of the controlled component is divided into the following situations:
24+
25+
- String type: `''`
26+
- number: `null`
27+
- array: `[]`
28+
- Other: `null`
29+
30+
## How to modify `dayjs` configuration
31+
32+
First of all, we should ensure that the project is the only `dayjs` globally, so the `dayjs` of the component library is placed in `peerDependencies`.
33+
34+
You only need to configure `dayjs` in your project, the best practice is to create a `startup` to ensure some configuration at the beginning, please refer to [startup](https://github.com/DevCloudFE/react-devui/tree/main/packages/platform/src/startup).
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# FAQ
2+
3+
下面列出了一些常见问题:
4+
5+
## 组件库是否含有副作用
6+
7+
组件库仅样式覆盖了全局的 `box-sizing`,这也是目前绝大多数人的选择:
8+
9+
```scss
10+
*,
11+
*::before,
12+
*::after {
13+
box-sizing: border-box;
14+
}
15+
```
16+
17+
## 组件何时受控
18+
19+
我们约定 `undefined` 代表组件为非受控状态,其它值均代表组件受控。
20+
21+
## 受控组件空值一般是什么
22+
23+
受控组件空值分为下面几种情况:
24+
25+
- 字符串类型:`''`
26+
- 数字: `null`
27+
- 数组: `[]`
28+
- 其它: `null`
29+
30+
## 如何修改 `dayjs` 配置
31+
32+
首先我们应该确保项目是全局唯一的 `dayjs`,所以组件库的 `dayjs` 是放在 `peerDependencies` 中。
33+
34+
您只需要在您的项目中配置 `dayjs` 即可,最佳实践是创建一个 `startup` 确保最开始的时候进行一些配置,可参考 [startup](https://github.com/DevCloudFE/react-devui/tree/main/packages/platform/src/startup)

packages/site/src/app/routes/docs/getting-started/GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Import on demand:
3333

3434
## Import the root component
3535

36-
You need to import `DRoot` on the root component of your project (like `App.tsx`), `DRoot` is required and it provides global configuration.
36+
You need to import `DRoot` on the root component of your project (like `App.tsx`), `DRoot` is required and it provides [global configuration](/docs/GlobalConfiguration).
3737

3838
It is recommended to configure the `layout` parameter, which provides the layout information of your page, so that we can automatically do some work (such as updating the popup position).
3939

packages/site/src/app/routes/docs/getting-started/GettingStarted.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npm install @react-devui/ui @react-devui/icons @react-devui/hooks @react-devui/u
3333

3434
## 引入根组件
3535

36-
您需要在项目的根组件(如`App.tsx`)上引入 `DRoot``DRoot` 是必须的并且它提供了全局配置
36+
您需要在项目的根组件(如`App.tsx`)上引入 `DRoot``DRoot` 是必须的并且它提供了[全局配置](/docs/GlobalConfiguration)
3737

3838
建议配置 `layout` 参数,它提供了您页面的布局信息,这样我们就可以自动完成某些工作(如更新弹窗位置)。
3939

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Global Configuration
2+
3+
Through our root component `DRoot`, you can configure our component library very conveniently, and all configuration items are listed below:
4+
5+
```tsx
6+
interface DConfigContextData {
7+
// Namespace, affects `className`, e.g. set value to 'app', then 'rd-button' will become 'app-button'
8+
// Note: Need to modify the style sheet `$rd-namespace: 'app'` synchronously!
9+
namespace: string;
10+
// The global configuration of the component, the component Prop priority is: component > global configuration > default
11+
// For example: `{ DEmpty: { dDescription: 'Global configuration' } }` will modify the default description of the empty component
12+
componentConfigs: Partial<DComponentConfig>;
13+
// [Internationalization](/docs/Internationalization)
14+
i18n: {
15+
lang: DLang;
16+
resources: typeof resources;
17+
};
18+
// Page layout
19+
layout: {
20+
// Scroll container
21+
pageScrollEl?: DRefExtra;
22+
// Content container
23+
contentResizeEl?: DRefExtra;
24+
};
25+
// Whether to monitor global scrolling will cause unnecessary calculations, use with caution!
26+
// Calculations like popup position are mostly expected if the page layout is set up correctly
27+
// But if the page often contains nested scrolling, it is undoubtedly difficult to handle various position
28+
// calculations based on the scrolling events of each scrolling container. At this time, global scrolling can be monitored
29+
globalScroll: boolean;
30+
}
31+
```

0 commit comments

Comments
 (0)