@modern-js/module-tools-docs 2.32.0 → 2.32.1
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/CHANGELOG.md +7 -0
- package/docs/en/api/config/build-config.mdx +6 -2
- package/docs/en/api/config/design-system.md +1 -1
- package/docs/en/guide/advance/theme-config.mdx +13 -29
- package/docs/zh/api/config/build-config.mdx +6 -2
- package/docs/zh/api/config/design-system.md +1 -1
- package/docs/zh/guide/advance/theme-config.mdx +8 -18
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1110,10 +1110,14 @@ When the value is of type `object`, it is merged with the default configuration
|
|
|
1110
1110
|
|
|
1111
1111
|
When the value is of type `Function`, the object returned by the function is merged with the default configuration via `Object.assign`.
|
|
1112
1112
|
|
|
1113
|
-
The `theme` property is not allowed, otherwise the build will fail, using [`designSystem`](/api/config/design-system) as the `Tailwind CSS Theme` configuration.
|
|
1114
|
-
|
|
1115
1113
|
The rest of the usage is the same as Tailwind CSS: [Quick Portal](https://tailwindcss.com/docs/configuration).
|
|
1116
1114
|
|
|
1115
|
+
### Notes
|
|
1116
|
+
|
|
1117
|
+
Please note that if you are using the [designSystem](/api/config/design-system) configuration option simultaneously, the `theme` configuration of Tailwind CSS will be overridden by the value of `designSystem`.
|
|
1118
|
+
|
|
1119
|
+
The usage of other configurations follows the same approach as the official usage of Tailwind CSS. Please refer to [tailwindcss - Configuration](https://tailwindcss.com/docs/configuration) for more details.
|
|
1120
|
+
|
|
1117
1121
|
## target
|
|
1118
1122
|
|
|
1119
1123
|
`target` is used to set the target environment for the generated JavaScript code. It enables Module Tools to transform JavaScript syntax that is not recognized by the target environment into older versions of JavaScript syntax that are compatible with these environments.
|
|
@@ -647,7 +647,7 @@ const designSystem = {
|
|
|
647
647
|
```
|
|
648
648
|
|
|
649
649
|
:::tip
|
|
650
|
-
More about [
|
|
650
|
+
More about [Tailwind CSS configuration](https://tailwindcss.com/docs/configuration#theme)
|
|
651
651
|
:::
|
|
652
652
|
|
|
653
653
|
</details>
|
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 7
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Theme Configuration
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Motivation and rationale
|
|
10
|
-
|
|
11
|
-
Theme configuration is somewhat similar to the custom theme functionality in the component library and is mainly used in style development. We can use the `designToken` generated by the `designSystem` configuration in different style development environments.
|
|
12
|
-
|
|
13
|
-
The so-called `designToken` corresponds to different things in different style development environments.
|
|
3
|
+
Module Tools provides the ability to configure the Tailwind CSS theme through the `designSystem` option.
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
- The name of the HTML class supported by tailwindcss.
|
|
17
|
-
- `@apply` custom directive under css/less/sass to use a string with the same name as the HTML class name supported by tailwindcss.
|
|
18
|
-
- css/less/scss: Generate global style variables via `designSystem`.
|
|
5
|
+
## Motivation and Principles
|
|
19
6
|
|
|
20
|
-
|
|
7
|
+
Theme configuration is similar to custom theme functionality in component libraries and is primarily used for styling. When using `designSystem`, it serves as the `theme` configuration for Tailwind CSS. Therefore, you can use:
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
:::
|
|
9
|
+
- CSS class names supported by Tailwind CSS.
|
|
10
|
+
- Strings with the same name as the CSS class names supported by Tailwind CSS, using the `@apply` custom directive in CSS/Less/Sass.
|
|
25
11
|
|
|
26
|
-
|
|
12
|
+
For the default value of `designSystem`, refer to the [`designSystem` API](/api/config/design-system).
|
|
27
13
|
|
|
28
|
-
|
|
14
|
+
## Usage Example
|
|
29
15
|
|
|
30
|
-
When using
|
|
16
|
+
When using Tailwind CSS, you can use `designSystem` to configure its [`theme`](https://tailwindcss.com/docs/theme).
|
|
31
17
|
|
|
32
|
-
For example, the following configuration extends the
|
|
18
|
+
For example, the following configuration extends the existing color configuration:
|
|
33
19
|
|
|
34
20
|
```ts title="modern.config.ts"
|
|
35
21
|
export default {
|
|
@@ -43,9 +29,9 @@ export default {
|
|
|
43
29
|
};
|
|
44
30
|
```
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
In the code, there are two ways to use Tailwind CSS.
|
|
47
33
|
|
|
48
|
-
####
|
|
34
|
+
#### CSS Class Names
|
|
49
35
|
|
|
50
36
|
```tsx title="./src/index.tsx"
|
|
51
37
|
import 'tailwindcss/utilities.css';
|
|
@@ -55,11 +41,9 @@ export default () => {
|
|
|
55
41
|
};
|
|
56
42
|
```
|
|
57
43
|
|
|
58
|
-
#### `@apply`
|
|
44
|
+
#### `@apply` Directive
|
|
59
45
|
|
|
60
|
-
|
|
61
|
-
About [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply)。
|
|
62
|
-
:::
|
|
46
|
+
Regarding [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply).
|
|
63
47
|
|
|
64
48
|
```tsx title="./src/index.tsx"
|
|
65
49
|
import './index.css';
|
|
@@ -1110,10 +1110,14 @@ const tailwind = {
|
|
|
1110
1110
|
|
|
1111
1111
|
值为 `Function` 类型时,函数返回的对象与默认配置通过 `Object.assign` 合并。
|
|
1112
1112
|
|
|
1113
|
-
不允许出现 `theme` 属性,否则会构建失败, 使用 [`designSystem`](/api/config/design-system) 作为 `Tailwind CSS Theme` 配置。
|
|
1114
|
-
|
|
1115
1113
|
其他的使用方式和 Tailwind CSS 一致: [快速传送门](https://tailwindcss.com/docs/configuration)。
|
|
1116
1114
|
|
|
1115
|
+
### 注意事项
|
|
1116
|
+
|
|
1117
|
+
注意,如果你同时使用了 [designSystem](/api/config/design-system) 配置项,那么 Tailwind CSS 的 `theme` 配置将会被 `designSystem` 的值所覆盖。
|
|
1118
|
+
|
|
1119
|
+
其他配置的使用方式与 Tailwind CSS 官方用法一致,请参考 [tailwindcss - Configuration](https://tailwindcss.com/docs/configuration)。
|
|
1120
|
+
|
|
1117
1121
|
## target
|
|
1118
1122
|
|
|
1119
1123
|
`target` 用于为生成的 JavaScript 代码设置目标环境。它让 Module Tools 将目标环境无法识别的 JavaScript 语法转换为在这些环境中可用的低版本 JavaScript 语法。
|
|
@@ -4,30 +4,20 @@ sidebar_position: 6
|
|
|
4
4
|
|
|
5
5
|
# 主题配置
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Module Tools 通过 [`designSystem`](/api/config/design-system) 选项,提供了配置 Tailwind CSS 主题的能力。
|
|
8
8
|
|
|
9
9
|
## 动机和原理
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
主题配置有些类似组件库中的定制主题功能,主要用于开发样式。当你使用 `designSystem` 时,它会作为 Tailwind CSS 的 `theme` 配置。因此你可以使用:
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
- Tailwind CSS 支持的 CSS 类名。
|
|
14
|
+
- 在 CSS/Less/Sass 下通过 `@apply` 自定义指令使用与 Tailwind CSS 支持的 CSS 类名同名的字符串。
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
- tailwindcss 支持的 HTML 类名。
|
|
17
|
-
- 在 css/less/sass 下通过 `@apply` 自定义指令使用与 tailwindcss 支持的 HTML 类名同名的字符串。
|
|
18
|
-
- css/less/scss: 通过 `designSystem` 生成全局的样式变量。
|
|
19
|
-
|
|
20
|
-
`designSystem` API 的数据结构借鉴了 `tailwindcss` 配置对象中的 [theme API](https://tailwindcss.com/docs/theme),因此存在默认的一套 `designToken`。关于默认值,可以查看 [`designSystem` API](/api/config/design-system)。
|
|
21
|
-
|
|
22
|
-
:::info
|
|
23
|
-
目前暂时还未支持 css/less/sass 全局变量。
|
|
24
|
-
:::
|
|
16
|
+
关于 `designSystem` 的默认值,可以查看 [`designSystem` API](/api/config/design-system)。
|
|
25
17
|
|
|
26
18
|
## 使用示例
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
在使用 tailwindcss 的时候,可以通过 `designSystem` 来设置它的 [`theme`](https://v2.tailwindcss.com/docs/theme#extending-the-default-theme) 配置。
|
|
20
|
+
在使用 Tailwind CSS 的时候,可以通过 `designSystem` 来设置它的 [`theme`](https://tailwindcss.com/docs/theme) 配置。
|
|
31
21
|
|
|
32
22
|
例如在下面的配置中扩展了原有的颜色配置:
|
|
33
23
|
|
|
@@ -43,9 +33,9 @@ export default {
|
|
|
43
33
|
};
|
|
44
34
|
```
|
|
45
35
|
|
|
46
|
-
|
|
36
|
+
在代码中,我们可以有两种使用 Tailwind CSS 的方式。
|
|
47
37
|
|
|
48
|
-
####
|
|
38
|
+
#### CSS 类名
|
|
49
39
|
|
|
50
40
|
```tsx title="./src/index.tsx"
|
|
51
41
|
import 'tailwindcss/utilities.css';
|
package/package.json
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"directory": "packages/document/module-doc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.32.
|
|
12
|
+
"version": "2.32.1",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"react": "^18.2.0",
|
|
16
16
|
"react-dom": "^18.2.0",
|
|
17
|
-
"@modern-js/doc-
|
|
18
|
-
"@modern-js/doc-
|
|
17
|
+
"@modern-js/doc-tools": "2.32.1",
|
|
18
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.32.1"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "modern dev",
|