@modern-js/module-tools-docs 2.32.0 → 2.32.2-alpha.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 +18 -0
- package/docs/en/api/config/build-config.mdx +22 -17
- package/docs/en/api/config/build-preset.mdx +11 -72
- package/docs/en/guide/advance/asset.mdx +1 -1
- package/docs/en/guide/advance/copy.md +17 -18
- package/docs/en/guide/advance/external-dependency.mdx +1 -1
- package/docs/en/guide/advance/in-depth-about-build.md +27 -28
- package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/en/guide/basic/before-getting-started.md +1 -1
- package/docs/en/guide/basic/modify-output-product.md +44 -70
- package/docs/en/guide/basic/test-your-project.mdx +0 -2
- package/docs/en/guide/basic/use-micro-generator.md +12 -37
- package/docs/en/guide/basic/using-storybook.mdx +15 -0
- package/docs/en/guide/best-practices/components.mdx +5 -198
- package/docs/en/guide/best-practices/use-tailwindcss.mdx +289 -0
- package/docs/en/plugins/guide/setup-function.mdx +0 -1
- package/docs/zh/api/config/build-config.mdx +24 -21
- package/docs/zh/api/config/build-preset.mdx +12 -69
- package/docs/zh/guide/advance/asset.mdx +3 -6
- package/docs/zh/guide/advance/copy.md +0 -2
- package/docs/zh/guide/advance/external-dependency.mdx +1 -1
- package/docs/zh/guide/advance/in-depth-about-build.md +30 -56
- package/docs/zh/guide/basic/before-getting-started.md +1 -1
- package/docs/zh/guide/basic/modify-output-product.md +46 -69
- package/docs/zh/guide/basic/use-micro-generator.md +13 -33
- package/docs/zh/guide/basic/using-storybook.mdx +16 -5
- package/docs/zh/guide/best-practices/components.mdx +1 -196
- package/docs/zh/guide/best-practices/use-tailwindcss.mdx +289 -0
- package/docs/zh/plugins/guide/setup-function.mdx +0 -1
- package/modern.config.ts +8 -0
- package/package.json +3 -3
- package/docs/en/api/config/design-system.md +0 -1166
- package/docs/en/guide/advance/theme-config.mdx +0 -76
- package/docs/zh/api/config/design-system.md +0 -1166
- package/docs/zh/guide/advance/theme-config.mdx +0 -74
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 7
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Theme Configuration
|
|
6
|
-
|
|
7
|
-
The module project provides the ability to configure themes through the [`designSystem`](/en/api/config/design-system) API.
|
|
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.
|
|
14
|
-
|
|
15
|
-
- tailwindcss: use `designSystem` as the `theme` configuration for tailwindcss. So you can use.
|
|
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`.
|
|
19
|
-
|
|
20
|
-
The data structure of the `designSystem` API is borrowed from the [theme API](https://tailwindcss.com/docs/theme) in the `tailwindcss` configuration object, so a default set of `designToken` exists. For the default values, see the [`designSystem` API](/api/config/design-system).
|
|
21
|
-
|
|
22
|
-
:::info
|
|
23
|
-
The css/less/sass global variables are not supported yet.
|
|
24
|
-
:::
|
|
25
|
-
|
|
26
|
-
## Usage examples
|
|
27
|
-
|
|
28
|
-
### tailwindcss
|
|
29
|
-
|
|
30
|
-
When using tailwindcss, its [`theme`](https://v2.tailwindcss.com/docs/theme#extending-the-default-theme) configuration can be set via `designSystem`.
|
|
31
|
-
|
|
32
|
-
For example, the following configuration extends the original color configuration:
|
|
33
|
-
|
|
34
|
-
```ts title="modern.config.ts"
|
|
35
|
-
export default {
|
|
36
|
-
designSystem: {
|
|
37
|
-
extend: {
|
|
38
|
-
colors: {
|
|
39
|
-
primary: '#1677ff',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
We can have two ways of using tailwindcss in our code.
|
|
47
|
-
|
|
48
|
-
#### HTML Class
|
|
49
|
-
|
|
50
|
-
```tsx title="./src/index.tsx"
|
|
51
|
-
import 'tailwindcss/utilities.css';
|
|
52
|
-
|
|
53
|
-
export default () => {
|
|
54
|
-
return <div className="bg-primary"></div>;
|
|
55
|
-
};
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
#### `@apply` Directives
|
|
59
|
-
|
|
60
|
-
:::info
|
|
61
|
-
About [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply)。
|
|
62
|
-
:::
|
|
63
|
-
|
|
64
|
-
```tsx title="./src/index.tsx"
|
|
65
|
-
import './index.css';
|
|
66
|
-
|
|
67
|
-
export default () => {
|
|
68
|
-
return <div className="btn-primary"></div>;
|
|
69
|
-
};
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```css title="./src/index.css"
|
|
73
|
-
.btn-primary {
|
|
74
|
-
@apply bg-primary;
|
|
75
|
-
}
|
|
76
|
-
```
|