@modern-js/module-tools-docs 2.0.0-beta.4
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/LICENSE +144 -0
- package/docs/.island/config.ts +245 -0
- package/docs/.island/dist/404.html +41 -0
- package/docs/.island/dist/assets/before-getting-started.1b82b538.js +87 -0
- package/docs/.island/dist/assets/before-getting-started.582a31cc.js +87 -0
- package/docs/.island/dist/assets/build-config.72eb0918.js +804 -0
- package/docs/.island/dist/assets/build-config.d8bb1658.js +809 -0
- package/docs/.island/dist/assets/build-preset.96805d7d.js +256 -0
- package/docs/.island/dist/assets/build-preset.c20dcd40.js +256 -0
- package/docs/.island/dist/assets/build-your-ui.7f349247.js +2 -0
- package/docs/.island/dist/assets/build-your-ui.a8361604.js +2 -0
- package/docs/.island/dist/assets/command-preview.2d45fc82.js +264 -0
- package/docs/.island/dist/assets/command-preview.dc51b953.js +264 -0
- package/docs/.island/dist/assets/components.esm.03560353.js +9 -0
- package/docs/.island/dist/assets/design-system.86694ff5.js +1254 -0
- package/docs/.island/dist/assets/design-system.c4745cce.js +639 -0
- package/docs/.island/dist/assets/dev.1d326a37.js +37 -0
- package/docs/.island/dist/assets/dev.1fd06000.js +37 -0
- package/docs/.island/dist/assets/down.f35427d3.svg +1 -0
- package/docs/.island/dist/assets/extension.12299fd6.js +2 -0
- package/docs/.island/dist/assets/extension.96dc63a4.js +2 -0
- package/docs/.island/dist/assets/getting-started.40e9218d.js +117 -0
- package/docs/.island/dist/assets/getting-started.b1ed3f10.js +114 -0
- package/docs/.island/dist/assets/github.3bf8ccee.svg +1 -0
- package/docs/.island/dist/assets/index.2b2347ea.js +33 -0
- package/docs/.island/dist/assets/index.6cef6f5f.js +4 -0
- package/docs/.island/dist/assets/index.cb118238.js +36 -0
- package/docs/.island/dist/assets/index.ccb6ce27.js +4 -0
- package/docs/.island/dist/assets/island_inject.11a12ecc.js +1 -0
- package/docs/.island/dist/assets/island_inject.b13deaee.js +1 -0
- package/docs/.island/dist/assets/loading.8c9bb911.svg +1 -0
- package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +100 -0
- package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +100 -0
- package/docs/.island/dist/assets/moon.6b705924.svg +3 -0
- package/docs/.island/dist/assets/plugin.895932d8.js +42 -0
- package/docs/.island/dist/assets/plugin.d2fbc531.js +42 -0
- package/docs/.island/dist/assets/publish-your-project.21b8309f.js +164 -0
- package/docs/.island/dist/assets/publish-your-project.8d398b17.js +166 -0
- package/docs/.island/dist/assets/right.89674cd7.svg +1 -0
- package/docs/.island/dist/assets/search.0aea6901.svg +1 -0
- package/docs/.island/dist/assets/search.1c85d17c.js +3 -0
- package/docs/.island/dist/assets/search.484eca11.js +222 -0
- package/docs/.island/dist/assets/search.54fca8d0.js +3 -0
- package/docs/.island/dist/assets/style.09015a4b.css +1 -0
- package/docs/.island/dist/assets/style.2e5f7bc2.css +1970 -0
- package/docs/.island/dist/assets/sun.841dac10.svg +11 -0
- package/docs/.island/dist/assets/test-your-project.18bd4582.js +190 -0
- package/docs/.island/dist/assets/test-your-project.f53bebf7.js +190 -0
- package/docs/.island/dist/assets/test.0da1f99f.js +67 -0
- package/docs/.island/dist/assets/test.0e81f002.js +66 -0
- package/docs/.island/dist/assets/translator.b1077c44.svg +1 -0
- package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +60 -0
- package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +60 -0
- package/docs/.island/dist/assets/using-storybook.57ea6b77.js +260 -0
- package/docs/.island/dist/assets/using-storybook.a2212f2e.js +260 -0
- package/docs/.island/dist/assets/welcome.0449a9c8.js +13 -0
- package/docs/.island/dist/assets/welcome.a8448931.js +13 -0
- package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +26 -0
- package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +26 -0
- package/docs/.island/dist/chunk-COLCRJ2V.js +1 -0
- package/docs/.island/dist/chunk-K5FMOYDC.js +10 -0
- package/docs/.island/dist/chunk-WE42KMYS.js +26 -0
- package/docs/.island/dist/client-entry.js +3 -0
- package/docs/.island/dist/en/api/build-config.html +344 -0
- package/docs/.island/dist/en/api/build-preset.html +82 -0
- package/docs/.island/dist/en/api/design-system.html +155 -0
- package/docs/.island/dist/en/api/dev.html +45 -0
- package/docs/.island/dist/en/api/index.html +41 -0
- package/docs/.island/dist/en/api/plugin.html +48 -0
- package/docs/.island/dist/en/api/test.html +58 -0
- package/docs/.island/dist/en/guide/before-getting-started.html +127 -0
- package/docs/.island/dist/en/guide/build-your-ui.html +41 -0
- package/docs/.island/dist/en/guide/command-preview.html +100 -0
- package/docs/.island/dist/en/guide/extension.html +41 -0
- package/docs/.island/dist/en/guide/getting-started.html +76 -0
- package/docs/.island/dist/en/guide/modify-output-product.html +140 -0
- package/docs/.island/dist/en/guide/publish-your-project.html +91 -0
- package/docs/.island/dist/en/guide/test-your-project.html +72 -0
- package/docs/.island/dist/en/guide/use-micro-generator.html +65 -0
- package/docs/.island/dist/en/guide/using-storybook.html +113 -0
- package/docs/.island/dist/en/guide/welcome.html +53 -0
- package/docs/.island/dist/en/guide/why-module-engineering-solution.html +49 -0
- package/docs/.island/dist/en/index.html +42 -0
- package/docs/.island/dist/react-dom.js +1 -0
- package/docs/.island/dist/react-dom_client.js +1 -0
- package/docs/.island/dist/react.js +1 -0
- package/docs/.island/dist/react_jsx-runtime.js +10 -0
- package/docs/.island/dist/ssr-manifest.json +57 -0
- package/docs/.island/dist/test-result.png +0 -0
- package/docs/.island/dist/why-module-solution.png +0 -0
- package/docs/.island/dist/zh/api/build-config.html +347 -0
- package/docs/.island/dist/zh/api/build-preset.html +82 -0
- package/docs/.island/dist/zh/api/design-system.html +149 -0
- package/docs/.island/dist/zh/api/dev.html +46 -0
- package/docs/.island/dist/zh/api/index.html +41 -0
- package/docs/.island/dist/zh/api/plugin.html +48 -0
- package/docs/.island/dist/zh/api/test.html +59 -0
- package/docs/.island/dist/zh/guide/before-getting-started.html +127 -0
- package/docs/.island/dist/zh/guide/build-your-ui.html +41 -0
- package/docs/.island/dist/zh/guide/command-preview.html +100 -0
- package/docs/.island/dist/zh/guide/extension.html +41 -0
- package/docs/.island/dist/zh/guide/getting-started.html +79 -0
- package/docs/.island/dist/zh/guide/modify-output-product.html +140 -0
- package/docs/.island/dist/zh/guide/publish-your-project.html +92 -0
- package/docs/.island/dist/zh/guide/test-your-project.html +72 -0
- package/docs/.island/dist/zh/guide/use-micro-generator.html +65 -0
- package/docs/.island/dist/zh/guide/using-storybook.html +114 -0
- package/docs/.island/dist/zh/guide/welcome.html +53 -0
- package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +49 -0
- package/docs/.island/dist/zh/index.html +42 -0
- package/docs/.island/index.html +39 -0
- package/docs/.island/styles/index.css +10 -0
- package/docs/en/api/build-config.md +501 -0
- package/docs/en/api/build-preset.md +214 -0
- package/docs/en/api/design-system.md +524 -0
- package/docs/en/api/dev.md +32 -0
- package/docs/en/api/index.md +3 -0
- package/docs/en/api/plugin.md +34 -0
- package/docs/en/api/test.md +48 -0
- package/docs/en/guide/advance/asset.mdx +132 -0
- package/docs/en/guide/advance/build-umd.mdx +241 -0
- package/docs/en/guide/advance/copy.md +235 -0
- package/docs/en/guide/advance/external-dependency.mdx +125 -0
- package/docs/en/guide/advance/in-depth-about-build.md +266 -0
- package/docs/en/guide/advance/in-depth-about-dev-command.md +22 -0
- package/docs/en/guide/basic/before-getting-started.md +187 -0
- package/docs/en/guide/basic/command-preview.md +204 -0
- package/docs/en/guide/basic/modify-output-product.md +145 -0
- package/docs/en/guide/basic/publish-your-project.md +115 -0
- package/docs/en/guide/basic/test-your-project.mdx +158 -0
- package/docs/en/guide/basic/use-micro-generator.md +35 -0
- package/docs/en/guide/basic/using-storybook.mdx +187 -0
- package/docs/en/guide/intro/getting-started.md +78 -0
- package/docs/en/guide/intro/welcome.md +14 -0
- package/docs/en/guide/intro/why-module-engineering-solution.md +17 -0
- package/docs/en/index.md +35 -0
- package/docs/public/test-result.png +0 -0
- package/docs/public/why-module-solution.png +0 -0
- package/docs/zh/api/build-config.md +570 -0
- package/docs/zh/api/build-preset.md +220 -0
- package/docs/zh/api/design-system.md +1147 -0
- package/docs/zh/api/dev.md +33 -0
- package/docs/zh/api/index.md +3 -0
- package/docs/zh/api/plugins.md +108 -0
- package/docs/zh/api/testing.md +52 -0
- package/docs/zh/guide/advance/asset.mdx +132 -0
- package/docs/zh/guide/advance/build-umd.mdx +232 -0
- package/docs/zh/guide/advance/copy.md +235 -0
- package/docs/zh/guide/advance/external-dependency.mdx +125 -0
- package/docs/zh/guide/advance/in-depth-about-build.md +267 -0
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +26 -0
- package/docs/zh/guide/basic/before-getting-started.md +187 -0
- package/docs/zh/guide/basic/command-preview.md +204 -0
- package/docs/zh/guide/basic/modify-output-product.md +144 -0
- package/docs/zh/guide/basic/publish-your-project.md +112 -0
- package/docs/zh/guide/basic/test-your-project.mdx +158 -0
- package/docs/zh/guide/basic/use-micro-generator.md +35 -0
- package/docs/zh/guide/basic/using-storybook.mdx +186 -0
- package/docs/zh/guide/intro/getting-started.md +78 -0
- package/docs/zh/guide/intro/welcome.md +14 -0
- package/docs/zh/guide/intro/why-module-engineering-solution.md +17 -0
- package/docs/zh/index.md +29 -0
- package/package.json +19 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
# DesignSystem
|
|
2
|
+
This chapter describes the configuration related to designSystem
|
|
3
|
+
|
|
4
|
+
:::tips
|
|
5
|
+
The Tailwind CSS feature needs to be enabled first via `pnpm run new`.
|
|
6
|
+
:::
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* Type: `Object`
|
|
10
|
+
* Default value: see configuration details below.
|
|
11
|
+
|
|
12
|
+
<details>
|
|
13
|
+
<summary>designSystem configuration details</summary>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
:::tips
|
|
17
|
+
More about [TailwindCSS configuration](https://tailwindcss.com/docs/configuration#theme)
|
|
18
|
+
:::
|
|
19
|
+
</details>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
`designSystem` is used to define the project's color palette, typographic scales (Typographic Scales or Type Scale), font lists, breakpoints, border rounding values, and more. Since Modern.js borrows the design approach from Tailwind Theme and integrates Tailwind CSS internally, `designSystem` is used in the same way as Tailwind CSS Theme
|
|
23
|
+
|
|
24
|
+
The `designSystem` object contains the `screens`, `colors` and `spacing` properties, as well as each customizable core plugin.
|
|
25
|
+
|
|
26
|
+
## Screens
|
|
27
|
+
|
|
28
|
+
The responsive breakpoints in your project can be customized using `screens`: the
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const designSystem = {
|
|
32
|
+
screens: {
|
|
33
|
+
sm: '640px',
|
|
34
|
+
md: '768px',
|
|
35
|
+
lg: '1024px',
|
|
36
|
+
xl: '1280px',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
where the property name in the `screens` object is the screen name (used as a prefix for the adaptive utility variants generated by `Tailwind CSS`, e.g. `md:text-center`) and the value is the `min-width` at which the breakpoint should start.
|
|
42
|
+
|
|
43
|
+
Default breakpoints are inspired by common device resolutions: the
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const designSystem = {
|
|
47
|
+
screens: {
|
|
48
|
+
sm: '640px',
|
|
49
|
+
// => @media (min-width: 640px) { ... }
|
|
50
|
+
|
|
51
|
+
md: '768px',
|
|
52
|
+
// => @media (min-width: 768px) { ... }
|
|
53
|
+
|
|
54
|
+
lg: '1024px',
|
|
55
|
+
// => @media (min-width: 1024px) { ... }
|
|
56
|
+
|
|
57
|
+
xl: '1280px',
|
|
58
|
+
// => @media (min-width: 1280px) { ... }
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
You can use any name you like as a breakpoint property in your project: the
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const designSystem = {
|
|
67
|
+
screens: {
|
|
68
|
+
tablet: '640px',
|
|
69
|
+
// => @media (min-width: 640px) { ... }
|
|
70
|
+
|
|
71
|
+
laptop: '1024px',
|
|
72
|
+
// => @media (min-width: 1024px) { ... }
|
|
73
|
+
|
|
74
|
+
desktop: '1280px',
|
|
75
|
+
// => @media (min-width: 1280px) { ... }
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
These screen names are reflected in `utilities`, so `text-center` now looks like this
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
.text-center { text-align: center }
|
|
84
|
+
|
|
85
|
+
@media (min-width: 640px) {
|
|
86
|
+
.tablet\:text-center { text-align: center }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@media (min-width: 1024px) {
|
|
90
|
+
.laptop\:text-center { text-align: center }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@media (min-width: 1280px) {
|
|
94
|
+
.desktop\:text-center { text-align: center }
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Max-width breakpoints
|
|
99
|
+
|
|
100
|
+
To use the `max-width` breakpoint instead of `min-width`, you can specify the screen as an object with the `max` attribute.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const designSystem = {
|
|
104
|
+
screens: {
|
|
105
|
+
xl: { max: '1279px' }
|
|
106
|
+
// => @media (max-width: 1279px) { ... }
|
|
107
|
+
|
|
108
|
+
lg: { max: '1023px' },
|
|
109
|
+
// => @media (max-width: 1023px) { ... }
|
|
110
|
+
|
|
111
|
+
md: { max: '767px' },
|
|
112
|
+
// => @media (max-width: 767px) { ... }
|
|
113
|
+
|
|
114
|
+
sm: { max: '639px' },
|
|
115
|
+
// => @media (max-width: 639px) { ... }
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If necessary, to create breakpoints with `min-width` and `max-width` definitions, e.g.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
const designSystem = {
|
|
124
|
+
screens: {
|
|
125
|
+
sm: { min: '640px', max: '767px' }
|
|
126
|
+
md: { min: '768px', max: '1023px' }
|
|
127
|
+
lg: { min: '1024px', max: '1279px' }, lg: { min: '1024px', max: '1279px' },
|
|
128
|
+
xl: { min: '1280px' }
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Multiple range breakpoints
|
|
134
|
+
|
|
135
|
+
Sometimes it can be useful to apply a single breakpoint definition to multiple scopes.
|
|
136
|
+
|
|
137
|
+
For example, suppose you have a `sidebar` and want the breakpoint to be based on the width of the content area rather than the entire viewport. You can simulate this situation by using a smaller breakpoint style when the `sidebar` is visible and the content area is narrowed: the
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
const designSystem = {
|
|
141
|
+
screens: {
|
|
142
|
+
sm: '500px',
|
|
143
|
+
md: [
|
|
144
|
+
// Sidebar appears at 768px, so revert to `sm:` styles between 768px
|
|
145
|
+
// and 868px, after which the main content area is wide enough again to
|
|
146
|
+
// apply the `md:` styles.
|
|
147
|
+
{ min: '668px', max: '767px' }
|
|
148
|
+
{ min: '868px' }, { min: '868px' },
|
|
149
|
+
],
|
|
150
|
+
lg: '1100px',
|
|
151
|
+
xl: '1400px',
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Custom media queries
|
|
157
|
+
|
|
158
|
+
If a fully customizable media query is required for a breakpoint, an object with the `raw` attribute can be used.
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
const designSystem = {
|
|
162
|
+
extend: {
|
|
163
|
+
screens: {
|
|
164
|
+
portrait: { raw: '(orientation: portrait)' },
|
|
165
|
+
// => @media (orientation: portrait) { ... }
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Print 样式
|
|
172
|
+
|
|
173
|
+
如果需要为打印应用不同的样式,则 `raw` 选项可能特别有用。
|
|
174
|
+
|
|
175
|
+
需要做的就是在 `designSystem.extend.screens` 下添加一个 `print`:
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
const designSystem = {
|
|
179
|
+
extend: {
|
|
180
|
+
screens: {
|
|
181
|
+
print: { raw: 'print' },
|
|
182
|
+
// => @media print { ... }
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
然后,可以使用诸如 `print:text-black` 之类的类来指定仅当某人尝试打印页面时才应用的样式:
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<div class="text-gray-700 print:text-black">
|
|
192
|
+
<! -- ... -->
|
|
193
|
+
</div>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Dark Mode
|
|
197
|
+
|
|
198
|
+
`raw` 选项可以用于实现 “暗模式” 屏幕:
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
const designSystem = {
|
|
202
|
+
extend: {
|
|
203
|
+
screens: {
|
|
204
|
+
dark: { raw: '(prefers-color-scheme: dark)' },
|
|
205
|
+
// => @media (prefers-color-scheme: dark) { ... }
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
然后,您可以使用 `dark:` 前缀在暗模式下为元素设置不同的样式:
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<div class="text-gray-700 dark:text-gray-200">
|
|
215
|
+
<! -- ... -->
|
|
216
|
+
</div>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
请注意,由于这些 `screen variants` 是在 `Tailwind CSS` 中实现的,因此**无法使用这种方法将断点与暗模式结合使用** ,例如 `md:dark:text-gray-300` 将不起作用。
|
|
220
|
+
|
|
221
|
+
## Colors
|
|
222
|
+
|
|
223
|
+
`colors` 属性可让您自定义项目的全局调色板。
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
const designSystem = {
|
|
227
|
+
colors: {
|
|
228
|
+
transparent: 'transparent',
|
|
229
|
+
black: '#000',
|
|
230
|
+
white: '#fff',
|
|
231
|
+
gray: {
|
|
232
|
+
100: '#f7fafc',
|
|
233
|
+
// ...
|
|
234
|
+
900: '#1a202c',
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
// ...
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
默认情况下,这些颜色由 `backgroundColor`,`textColor` 和 `borderColor` 核心插件继承。
|
|
243
|
+
|
|
244
|
+
想了解更多,可以查看:[Customizing Colors](https://tailwindcss.com/docs/customizing-colors)。
|
|
245
|
+
|
|
246
|
+
## Spacing
|
|
247
|
+
|
|
248
|
+
The global spacing and scaling of items can be customized using the `space` property.
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
const designSystem = {
|
|
252
|
+
spacing: {
|
|
253
|
+
px: '1px',
|
|
254
|
+
0: '0',
|
|
255
|
+
1: '0.25rem',
|
|
256
|
+
2: '0.5rem',
|
|
257
|
+
3: '0.75rem',
|
|
258
|
+
4: '1rem',
|
|
259
|
+
5: '1.25rem',
|
|
260
|
+
6: '1.5rem',
|
|
261
|
+
8: '2rem',
|
|
262
|
+
10: '2.5rem',
|
|
263
|
+
12: '3rem',
|
|
264
|
+
16: '4rem',
|
|
265
|
+
20: '5rem',
|
|
266
|
+
24: '6rem',
|
|
267
|
+
32: '8rem',
|
|
268
|
+
40: '10rem',
|
|
269
|
+
48: '12rem',
|
|
270
|
+
56: '14rem',
|
|
271
|
+
64: '16rem',
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
By default, these values are inherited by the `padding`, `margin`, `negativeMargin`, `width` and `height` core plugins.
|
|
277
|
+
|
|
278
|
+
To learn more, see [Customizing Spacing](https://tailwindcss.com/docs/customizing-spacing).
|
|
279
|
+
|
|
280
|
+
## Core Plugins
|
|
281
|
+
|
|
282
|
+
The rest of the theme section is used to configure the values available for each core plugin.
|
|
283
|
+
|
|
284
|
+
For example, the ``borderRadius`` property allows you to customize the ``utilities` that will generate the rounded corners.
|
|
285
|
+
|
|
286
|
+
``js
|
|
287
|
+
const designSystem = {
|
|
288
|
+
borderRadius: {
|
|
289
|
+
none: '0',
|
|
290
|
+
sm: '.125rem',
|
|
291
|
+
default: '.25rem',
|
|
292
|
+
lg: '.5rem',
|
|
293
|
+
full: '9999px',
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
** The property name determines the suffix of the generated class, and the value determines the value of the actual CSS declaration. **
|
|
299
|
+
The example ``borderRadius`` configuration above will generate the following CSS classes.
|
|
300
|
+
|
|
301
|
+
```css
|
|
302
|
+
.rounded-none { border-radius: 0 }
|
|
303
|
+
.rounded-sm { border-radius: .125rem }
|
|
304
|
+
.rounded { border-radius: .25rem }
|
|
305
|
+
.rounded-lg { border-radius: .5rem }
|
|
306
|
+
.rounded-full { border-radius: 9999px }
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
You will notice that the `rounded` class is created without the suffix in the theme configuration using the `default` attribute. This is a common convention in Tailwind CSS that is supported by many (though not all) core plugins.
|
|
310
|
+
|
|
311
|
+
To learn more about customizing a specific core plugin, please visit the documentation for that plugin.
|
|
312
|
+
|
|
313
|
+
## Customizing the default configuration
|
|
314
|
+
|
|
315
|
+
Out of the box, your project will automatically inherit values from the default theme configuration. If you want to customize the default theme, there are several different options depending on the goal.
|
|
316
|
+
|
|
317
|
+
### Override the default configuration
|
|
318
|
+
|
|
319
|
+
To override the options in the default configuration, add the attributes to be overridden in ``designSystem`'' at
|
|
320
|
+
|
|
321
|
+
```js title="modern.config.js"
|
|
322
|
+
const designSystem = {
|
|
323
|
+
// Replaces all of the default `opacity` values
|
|
324
|
+
opacity: {
|
|
325
|
+
0: '0',
|
|
326
|
+
20: '0.2',
|
|
327
|
+
40: '0.4',
|
|
328
|
+
60: '0.6',
|
|
329
|
+
80: '0.8',
|
|
330
|
+
100: '1',
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
export default defineConfig({
|
|
335
|
+
source: {
|
|
336
|
+
designSystem,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
This will completely replace the default property configuration, so in the above example, the default `opacity utilities` will not be generated.
|
|
342
|
+
|
|
343
|
+
Any properties you don't provide will be inherited from the default theme, so in the above example, the default theme configuration for color, spacing, border rounding, background position, etc. will be retained.
|
|
344
|
+
|
|
345
|
+
### Extending the default configuration
|
|
346
|
+
|
|
347
|
+
If you want to keep the default values of the theme options but add new values, add the extensions under the `designSystem.extend` property.
|
|
348
|
+
|
|
349
|
+
For example, if you want to add an additional breakpoint but keep the existing one, you can extend the `screens` property with.
|
|
350
|
+
|
|
351
|
+
```js title="modern.config.js"
|
|
352
|
+
const designSystem = {
|
|
353
|
+
extend: {
|
|
354
|
+
// Adds a new breakpoint in addition to the default breakpoints
|
|
355
|
+
screens: {
|
|
356
|
+
'2xl': '1440px',
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export default defineConfig({
|
|
362
|
+
source: {
|
|
363
|
+
designSystem,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
You can of course override some parts of the default theme and extend other parts of the default theme in the same configuration: the
|
|
369
|
+
|
|
370
|
+
```js title="modern.config.js"
|
|
371
|
+
const designSystem = {
|
|
372
|
+
opacity: {
|
|
373
|
+
0: '0',
|
|
374
|
+
20: '0.2',
|
|
375
|
+
40: '0.4',
|
|
376
|
+
60: '0.6',
|
|
377
|
+
80: '0.8',
|
|
378
|
+
100: '1',
|
|
379
|
+
},
|
|
380
|
+
extend: {
|
|
381
|
+
screens: {
|
|
382
|
+
'2xl': '1440px',
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export default defineConfig({
|
|
388
|
+
source: {
|
|
389
|
+
designSystem,
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Referencing other values
|
|
395
|
+
|
|
396
|
+
If you need to reference another value in the configuration, you can do so by providing a closure function instead of a static value. The function will receive the `theme()` function as an argument, and you can use this function to find other values in the configuration using the dot representation.
|
|
397
|
+
|
|
398
|
+
For example, you can generate `fill` utilities for each color in the palette by referring to `theme('colors')` on the `fill` configuration.
|
|
399
|
+
|
|
400
|
+
```js title="modern.config.js"
|
|
401
|
+
const designSystem = {
|
|
402
|
+
colors: {
|
|
403
|
+
// ...
|
|
404
|
+
},
|
|
405
|
+
fill: theme => theme('colors'),
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export default defineConfig({
|
|
409
|
+
source: {
|
|
410
|
+
designSystem,
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
The `theme()` function attempts to find the value you are looking for from an already fully merged configuration object, so it can reference your own custom settings as well as the default theme value. It also works recursively, so as long as there is a static value at the end of the chain, it can resolve the value you are looking for.
|
|
416
|
+
|
|
417
|
+
**Reference to the default configuration**
|
|
418
|
+
|
|
419
|
+
If for any reason you want to reference a value in the default configuration, you can import it from `tailwindcss/defaultTheme`. A useful example would be to add one of the fonts provided by the default configuration to.
|
|
420
|
+
|
|
421
|
+
```js title="modern.config.js"
|
|
422
|
+
const defaultTheme = require('tailwindcss/defaultTheme');
|
|
423
|
+
|
|
424
|
+
const designSystem = {
|
|
425
|
+
extend: {
|
|
426
|
+
fontFamily: {
|
|
427
|
+
sans: ['Lato', . .defaultTheme.fontFamily.sans],
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export default defineConfig({
|
|
433
|
+
source: {
|
|
434
|
+
designSystem,
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Disabling the entire core plugin
|
|
440
|
+
|
|
441
|
+
If you don't want to generate any classes for a core plugin, it is better to set the plugin to ``false`` in the ``corePlugins` configuration, rather than providing an empty object for the property in the configuration: ``
|
|
442
|
+
|
|
443
|
+
```js
|
|
444
|
+
// Don't assign an empty object in your theme configuration
|
|
445
|
+
|
|
446
|
+
const designSystem = {
|
|
447
|
+
opacity: {},
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// Do disable the plugin in your corePlugins configuration
|
|
451
|
+
const designSyttem = {
|
|
452
|
+
corePlugins: {
|
|
453
|
+
opacity: { false,
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
The end result is the same, but since many core plugins don't expose any configuration, it's best to keep it consistent by only disabling them with corePlugins anyway.
|
|
459
|
+
|
|
460
|
+
### Add your own key
|
|
461
|
+
|
|
462
|
+
In many cases it may be useful to add your own properties to the configuration object.
|
|
463
|
+
|
|
464
|
+
One example is to add new properties for multiplexing between multiple core plugins. For example, you can extract a ``positions`` object that both the ``backgroundPosition`` and ``objectPosition`` plugins can refer to.
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
const designSystem = {
|
|
468
|
+
positions: {
|
|
469
|
+
bottom: 'bottom',
|
|
470
|
+
center: 'center',
|
|
471
|
+
left: 'left',
|
|
472
|
+
'left-bottom': 'left bottom',
|
|
473
|
+
'left-top': 'left top',
|
|
474
|
+
right: 'right',
|
|
475
|
+
'right-bottom': 'right bottom',
|
|
476
|
+
'right-top': 'right top',
|
|
477
|
+
top: 'top',
|
|
478
|
+
},
|
|
479
|
+
backgroundPosition: theme => theme('positions'),
|
|
480
|
+
objectPosition: theme => theme('positions'),
|
|
481
|
+
};
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Another example is to add a new property to a custom plugin for referencing. For example, if you write a gradient plugin for your project, you can add a gradient property to the theme object referenced by that plugin.
|
|
485
|
+
|
|
486
|
+
```js title="modern.config.js"
|
|
487
|
+
const designSystem = {
|
|
488
|
+
gradients: theme => ({
|
|
489
|
+
'blue-green': [theme('colors.blue.500'), theme('colors.green.500')],
|
|
490
|
+
'purple-blue': [theme('colors.purple.500'), theme('colors.blue.500')],
|
|
491
|
+
// ...
|
|
492
|
+
}),
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export default defineConfig({
|
|
496
|
+
source: {
|
|
497
|
+
designSystem,
|
|
498
|
+
},
|
|
499
|
+
tools: {
|
|
500
|
+
tailwind: {
|
|
501
|
+
plugins: [require('. /plugins/gradients')],
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
## Configuration references
|
|
508
|
+
|
|
509
|
+
All properties in the configuration object, except `screens`, `colors` and `spacing`, map to the core plugins of `Tailwind CSS`. Since many plugins are responsible for CSS properties that accept only static sets of values (e.g., e.g., `float`), please note that not every plugin has a corresponding property in the theme object.
|
|
510
|
+
|
|
511
|
+
All of these properties can also be used under the `designSystem.extend` property to extend the default theme.
|
|
512
|
+
|
|
513
|
+
For more information about what all the properties do, check this [link](https://tailwindcss.com/docs/theme#configuration-reference).
|
|
514
|
+
|
|
515
|
+
## Additional Configuration
|
|
516
|
+
|
|
517
|
+
In addition to the same configuration as Tailwind CSS Theme, there are additional configurations provided by Modern.js.
|
|
518
|
+
|
|
519
|
+
### supportStyledComponents
|
|
520
|
+
|
|
521
|
+
- type: `boolean`
|
|
522
|
+
- default: `false`
|
|
523
|
+
|
|
524
|
+
With the value `true`, the `styled-components` `ThemeProvider` component is provided in the outer layer of the application at runtime and the `Theme Token` object generated by the `designSystem` is injected.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Dev
|
|
2
|
+
|
|
3
|
+
## storybook
|
|
4
|
+
|
|
5
|
+
For Storybook configuration see: [Storybook Configuration](https://storybook.js.org/docs/react/configure/overview)
|
|
6
|
+
|
|
7
|
+
:::info
|
|
8
|
+
To use Storybook for debugging, you need to enable the "Visual Testing (Storybook)" mode feature by executing the new command under the project in advance.
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
export default {
|
|
13
|
+
dev: {
|
|
14
|
+
storybook: {
|
|
15
|
+
addons: ['@storybook/addon-essentials'],
|
|
16
|
+
babel: async (options) => ({
|
|
17
|
+
// Update your babel configuration here
|
|
18
|
+
...options,
|
|
19
|
+
}),
|
|
20
|
+
framework: '@storybook/react',
|
|
21
|
+
stories: ['../src/**/*.stories.@(js|mdx)'],
|
|
22
|
+
webpackFinal: async (config, { configType }) => {
|
|
23
|
+
// Make whatever fine-grained changes you need
|
|
24
|
+
// Return the altered config
|
|
25
|
+
return config;
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Plugins
|
|
2
|
+
This section describes the configuration related to the plugin
|
|
3
|
+
|
|
4
|
+
- type: `CliPlugin<ModuleToolsHooks>[]`
|
|
5
|
+
- default: `[]`
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
export default (): CliPlugin<ModuleToolsHooks> => {
|
|
9
|
+
return {
|
|
10
|
+
name: 'dev-plugin-example',
|
|
11
|
+
setup: () => {
|
|
12
|
+
return {
|
|
13
|
+
registerDev() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'plugin-example',
|
|
16
|
+
menuItem: {
|
|
17
|
+
name: 'dev-example',
|
|
18
|
+
value: 'dev-example',
|
|
19
|
+
},
|
|
20
|
+
action() {
|
|
21
|
+
console.info('running dev-example');
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
beforeDevMenu(originQuestion) {
|
|
26
|
+
return originQuestion;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Check out[插件](https://modernjs.dev/docs/apis/app/runtime/plugin/plugin-api)for more information
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
:::tips
|
|
4
|
+
You need to enable the unit testing feature with `pnpm run new` first.
|
|
5
|
+
:::
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## jest
|
|
9
|
+
* Type: `Object | Function`
|
|
10
|
+
* Default value: `{}`
|
|
11
|
+
|
|
12
|
+
The configuration corresponding to [Jest](https://jestjs.io/docs/configuration), when of type ``Object``, can be configured with all the underlying configurations supported by Jest .
|
|
13
|
+
|
|
14
|
+
```js title=modern.config.js
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
testing: {
|
|
17
|
+
jest: {
|
|
18
|
+
testTimeout: 10000
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
When the value is of type ``Function``, the default configuration is passed in as the first parameter and a new Jest configuration object needs to be returned.
|
|
25
|
+
|
|
26
|
+
```js title=modern.config.js
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
testing: {
|
|
29
|
+
jest: options => {
|
|
30
|
+
return {
|
|
31
|
+
... . options,
|
|
32
|
+
testTimeout: 10000
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## transformer
|
|
40
|
+
|
|
41
|
+
- Type: `'babel-jest' | 'ts-jest'`
|
|
42
|
+
- Default value: `babel-jest`
|
|
43
|
+
|
|
44
|
+
Configure the compilation tool for the source code when executing tests: [babel-jest](https://www.npmjs.com/package/babel-jest) or [ts-jest](https://github.com/kulshekhar/ts-jest). The default is `babel-jest`.
|
|
45
|
+
|
|
46
|
+
:::info
|
|
47
|
+
`babel-jest` can also compile TS files without type errors, so use `ts-jest` if you need to check the TS type when running tests.
|
|
48
|
+
:::
|