@modern-js/main-doc 2.32.1 → 2.33.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/docs/en/apis/app/runtime/app/define-config.mdx +2 -2
- package/docs/en/apis/app/runtime/model/auto-actions.mdx +2 -2
- package/docs/en/apis/app/runtime/model/model_.mdx +0 -1
- package/docs/en/apis/app/runtime/model/use-static-model.mdx +1 -1
- package/docs/en/community/contributing-guide.mdx +2 -3
- package/docs/en/configure/app/builder-plugins.mdx +1 -1
- package/docs/en/configure/app/source/enable-async-entry.mdx +3 -1
- package/docs/en/configure/app/tools/tailwindcss.mdx +43 -1
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -2
- package/docs/en/guides/advanced-features/bff/function.mdx +1 -1
- package/docs/en/guides/basic-features/css.mdx +28 -18
- package/docs/en/guides/basic-features/mock.mdx +1 -1
- package/docs/en/guides/concept/builder.mdx +2 -2
- package/docs/en/guides/get-started/glossary.mdx +13 -1
- package/docs/en/guides/get-started/introduction.mdx +10 -6
- package/docs/en/guides/topic-detail/framework-plugin/hook.mdx +2 -2
- package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/category.md +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/context.md +1 -1
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +2 -5
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +2 -2
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +1 -1
- package/docs/en/guides/topic-detail/model/performance.mdx +2 -1
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +1 -1
- package/docs/en/guides/topic-detail/model/use-model.mdx +1 -1
- package/docs/en/tutorials/first-app/c05-loader.mdx +0 -2
- package/docs/zh/community/blog/v2-release-note.mdx +7 -8
- package/docs/zh/community/contributing-guide.mdx +2 -3
- package/docs/zh/configure/app/builder-plugins.mdx +1 -1
- package/docs/zh/configure/app/source/enable-async-entry.mdx +4 -2
- package/docs/zh/configure/app/tools/tailwindcss.mdx +42 -2
- package/docs/zh/guides/basic-features/css.mdx +27 -18
- package/docs/zh/guides/concept/builder.mdx +3 -3
- package/docs/zh/guides/get-started/glossary.mdx +13 -1
- package/docs/zh/guides/get-started/introduction.mdx +11 -7
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +1 -1
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +3 -6
- package/docs/zh/tutorials/first-app/c06-model.mdx +1 -4
- package/package.json +9 -8
- package/{modern.config.ts → rspress.config.ts} +78 -76
- package/src/components/ContentCard/index.tsx +2 -3
- package/src/components/ListCard/index.tsx +1 -1
- package/src/components/RandomMemberList/index.tsx +1 -1
- package/src/components/ShowcaseList/index.module.scss +5 -5
- package/src/components/SolutionCards/index.module.scss +2 -2
- package/src/i18n/enUS.ts +2 -2
- package/src/i18n/index.ts +1 -1
- package/src/i18n/zhCN.ts +2 -2
- package/src/index.ts +3 -2
- package/src/pages/index.module.scss +1 -1
- package/src/pages/index.tsx +7 -6
- package/docs/en/configure/app/source/design-system.mdx +0 -1175
- package/docs/zh/configure/app/source/design-system.mdx +0 -1174
@@ -1,1174 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sidebar_label: designSystem
|
3
|
-
---
|
4
|
-
|
5
|
-
# source.designSystem
|
6
|
-
|
7
|
-
- **类型:** `Object`
|
8
|
-
- **默认值:** 见下方配置详情。
|
9
|
-
|
10
|
-
:::caution 注意
|
11
|
-
需要先通过 `pnpm run new` 启用 Tailwind CSS 功能。
|
12
|
-
|
13
|
-
:::
|
14
|
-
|
15
|
-
<details>
|
16
|
-
<summary>DesignSystem 配置详情</summary>
|
17
|
-
|
18
|
-
```js
|
19
|
-
const designSystem = {
|
20
|
-
screens: {
|
21
|
-
sm: '640px',
|
22
|
-
md: '768px',
|
23
|
-
lg: '1024px',
|
24
|
-
xl: '1280px',
|
25
|
-
},
|
26
|
-
colors: {
|
27
|
-
transparent: 'transparent',
|
28
|
-
current: 'currentColor',
|
29
|
-
|
30
|
-
black: '#000',
|
31
|
-
white: '#fff',
|
32
|
-
|
33
|
-
gray: {
|
34
|
-
100: '#f7fafc',
|
35
|
-
200: '#edf2f7',
|
36
|
-
300: '#e2e8f0',
|
37
|
-
400: '#cbd5e0',
|
38
|
-
500: '#a0aec0',
|
39
|
-
600: '#718096',
|
40
|
-
700: '#4a5568',
|
41
|
-
800: '#2d3748',
|
42
|
-
900: '#1a202c',
|
43
|
-
},
|
44
|
-
red: {
|
45
|
-
100: '#fff5f5',
|
46
|
-
200: '#fed7d7',
|
47
|
-
300: '#feb2b2',
|
48
|
-
400: '#fc8181',
|
49
|
-
500: '#f56565',
|
50
|
-
600: '#e53e3e',
|
51
|
-
700: '#c53030',
|
52
|
-
800: '#9b2c2c',
|
53
|
-
900: '#742a2a',
|
54
|
-
},
|
55
|
-
orange: {
|
56
|
-
100: '#fffaf0',
|
57
|
-
200: '#feebc8',
|
58
|
-
300: '#fbd38d',
|
59
|
-
400: '#f6ad55',
|
60
|
-
500: '#ed8936',
|
61
|
-
600: '#dd6b20',
|
62
|
-
700: '#c05621',
|
63
|
-
800: '#9c4221',
|
64
|
-
900: '#7b341e',
|
65
|
-
},
|
66
|
-
yellow: {
|
67
|
-
100: '#fffff0',
|
68
|
-
200: '#fefcbf',
|
69
|
-
300: '#faf089',
|
70
|
-
400: '#f6e05e',
|
71
|
-
500: '#ecc94b',
|
72
|
-
600: '#d69e2e',
|
73
|
-
700: '#b7791f',
|
74
|
-
800: '#975a16',
|
75
|
-
900: '#744210',
|
76
|
-
},
|
77
|
-
green: {
|
78
|
-
100: '#f0fff4',
|
79
|
-
200: '#c6f6d5',
|
80
|
-
300: '#9ae6b4',
|
81
|
-
400: '#68d391',
|
82
|
-
500: '#48bb78',
|
83
|
-
600: '#38a169',
|
84
|
-
700: '#2f855a',
|
85
|
-
800: '#276749',
|
86
|
-
900: '#22543d',
|
87
|
-
},
|
88
|
-
teal: {
|
89
|
-
100: '#e6fffa',
|
90
|
-
200: '#b2f5ea',
|
91
|
-
300: '#81e6d9',
|
92
|
-
400: '#4fd1c5',
|
93
|
-
500: '#38b2ac',
|
94
|
-
600: '#319795',
|
95
|
-
700: '#2c7a7b',
|
96
|
-
800: '#285e61',
|
97
|
-
900: '#234e52',
|
98
|
-
},
|
99
|
-
blue: {
|
100
|
-
100: '#ebf8ff',
|
101
|
-
200: '#bee3f8',
|
102
|
-
300: '#90cdf4',
|
103
|
-
400: '#63b3ed',
|
104
|
-
500: '#4299e1',
|
105
|
-
600: '#3182ce',
|
106
|
-
700: '#2b6cb0',
|
107
|
-
800: '#2c5282',
|
108
|
-
900: '#2a4365',
|
109
|
-
},
|
110
|
-
indigo: {
|
111
|
-
100: '#ebf4ff',
|
112
|
-
200: '#c3dafe',
|
113
|
-
300: '#a3bffa',
|
114
|
-
400: '#7f9cf5',
|
115
|
-
500: '#667eea',
|
116
|
-
600: '#5a67d8',
|
117
|
-
700: '#4c51bf',
|
118
|
-
800: '#434190',
|
119
|
-
900: '#3c366b',
|
120
|
-
},
|
121
|
-
purple: {
|
122
|
-
100: '#faf5ff',
|
123
|
-
200: '#e9d8fd',
|
124
|
-
300: '#d6bcfa',
|
125
|
-
400: '#b794f4',
|
126
|
-
500: '#9f7aea',
|
127
|
-
600: '#805ad5',
|
128
|
-
700: '#6b46c1',
|
129
|
-
800: '#553c9a',
|
130
|
-
900: '#44337a',
|
131
|
-
},
|
132
|
-
pink: {
|
133
|
-
100: '#fff5f7',
|
134
|
-
200: '#fed7e2',
|
135
|
-
300: '#fbb6ce',
|
136
|
-
400: '#f687b3',
|
137
|
-
500: '#ed64a6',
|
138
|
-
600: '#d53f8c',
|
139
|
-
700: '#b83280',
|
140
|
-
800: '#97266d',
|
141
|
-
900: '#702459',
|
142
|
-
},
|
143
|
-
},
|
144
|
-
spacing: {
|
145
|
-
px: '1px',
|
146
|
-
0: '0',
|
147
|
-
1: '0.25rem',
|
148
|
-
2: '0.5rem',
|
149
|
-
3: '0.75rem',
|
150
|
-
4: '1rem',
|
151
|
-
5: '1.25rem',
|
152
|
-
6: '1.5rem',
|
153
|
-
8: '2rem',
|
154
|
-
10: '2.5rem',
|
155
|
-
12: '3rem',
|
156
|
-
16: '4rem',
|
157
|
-
20: '5rem',
|
158
|
-
24: '6rem',
|
159
|
-
32: '8rem',
|
160
|
-
40: '10rem',
|
161
|
-
48: '12rem',
|
162
|
-
56: '14rem',
|
163
|
-
64: '16rem',
|
164
|
-
},
|
165
|
-
backgroundColor: theme => theme('colors'),
|
166
|
-
backgroundOpacity: theme => theme('opacity'),
|
167
|
-
backgroundPosition: {
|
168
|
-
bottom: 'bottom',
|
169
|
-
center: 'center',
|
170
|
-
left: 'left',
|
171
|
-
'left-bottom': 'left bottom',
|
172
|
-
'left-top': 'left top',
|
173
|
-
right: 'right',
|
174
|
-
'right-bottom': 'right bottom',
|
175
|
-
'right-top': 'right top',
|
176
|
-
top: 'top',
|
177
|
-
},
|
178
|
-
backgroundSize: {
|
179
|
-
auto: 'auto',
|
180
|
-
cover: 'cover',
|
181
|
-
contain: 'contain',
|
182
|
-
},
|
183
|
-
borderColor: theme => ({
|
184
|
-
...theme('colors'),
|
185
|
-
default: theme('colors.gray.300', 'currentColor'),
|
186
|
-
}),
|
187
|
-
borderOpacity: theme => theme('opacity'),
|
188
|
-
borderRadius: {
|
189
|
-
none: '0',
|
190
|
-
sm: '0.125rem',
|
191
|
-
default: '0.25rem',
|
192
|
-
md: '0.375rem',
|
193
|
-
lg: '0.5rem',
|
194
|
-
full: '9999px',
|
195
|
-
},
|
196
|
-
borderWidth: {
|
197
|
-
default: '1px',
|
198
|
-
0: '0',
|
199
|
-
2: '2px',
|
200
|
-
4: '4px',
|
201
|
-
8: '8px',
|
202
|
-
},
|
203
|
-
boxShadow: {
|
204
|
-
xs: '0 0 0 1px rgba(0, 0, 0, 0.05)',
|
205
|
-
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
206
|
-
default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
|
207
|
-
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
208
|
-
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
209
|
-
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
|
210
|
-
'2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
|
211
|
-
inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
|
212
|
-
outline: '0 0 0 3px rgba(66, 153, 225, 0.5)',
|
213
|
-
none: 'none',
|
214
|
-
},
|
215
|
-
container: {},
|
216
|
-
cursor: {
|
217
|
-
auto: 'auto',
|
218
|
-
default: 'default',
|
219
|
-
pointer: 'pointer',
|
220
|
-
wait: 'wait',
|
221
|
-
text: 'text',
|
222
|
-
move: 'move',
|
223
|
-
'not-allowed': 'not-allowed',
|
224
|
-
},
|
225
|
-
divideColor: theme => theme('borderColor'),
|
226
|
-
divideOpacity: theme => theme('borderOpacity'),
|
227
|
-
divideWidth: theme => theme('borderWidth'),
|
228
|
-
fill: {
|
229
|
-
current: 'currentColor',
|
230
|
-
},
|
231
|
-
flex: {
|
232
|
-
1: '1 1 0%',
|
233
|
-
auto: '1 1 auto',
|
234
|
-
initial: '0 1 auto',
|
235
|
-
none: 'none',
|
236
|
-
},
|
237
|
-
flexGrow: {
|
238
|
-
0: '0',
|
239
|
-
default: '1',
|
240
|
-
},
|
241
|
-
flexShrink: {
|
242
|
-
0: '0',
|
243
|
-
default: '1',
|
244
|
-
},
|
245
|
-
fontFamily: {
|
246
|
-
sans: [
|
247
|
-
'system-ui',
|
248
|
-
'-apple-system',
|
249
|
-
'BlinkMacSystemFont',
|
250
|
-
'"Segoe UI"',
|
251
|
-
'Roboto',
|
252
|
-
'"Helvetica Neue"',
|
253
|
-
'Arial',
|
254
|
-
'"Noto Sans"',
|
255
|
-
'sans-serif',
|
256
|
-
'"Apple Color Emoji"',
|
257
|
-
'"Segoe UI Emoji"',
|
258
|
-
'"Segoe UI Symbol"',
|
259
|
-
'"Noto Color Emoji"',
|
260
|
-
],
|
261
|
-
serif: ['Georgia', 'Cambria', '"Times New Roman"', 'Times', 'serif'],
|
262
|
-
mono: [
|
263
|
-
'Menlo',
|
264
|
-
'Monaco',
|
265
|
-
'Consolas',
|
266
|
-
'"Liberation Mono"',
|
267
|
-
'"Courier New"',
|
268
|
-
'monospace',
|
269
|
-
],
|
270
|
-
},
|
271
|
-
fontSize: {
|
272
|
-
xs: '0.75rem',
|
273
|
-
sm: '0.875rem',
|
274
|
-
base: '1rem',
|
275
|
-
lg: '1.125rem',
|
276
|
-
xl: '1.25rem',
|
277
|
-
'2xl': '1.5rem',
|
278
|
-
'3xl': '1.875rem',
|
279
|
-
'4xl': '2.25rem',
|
280
|
-
'5xl': '3rem',
|
281
|
-
'6xl': '4rem',
|
282
|
-
},
|
283
|
-
fontWeight: {
|
284
|
-
hairline: '100',
|
285
|
-
thin: '200',
|
286
|
-
light: '300',
|
287
|
-
normal: '400',
|
288
|
-
medium: '500',
|
289
|
-
semibold: '600',
|
290
|
-
bold: '700',
|
291
|
-
extrabold: '800',
|
292
|
-
black: '900',
|
293
|
-
},
|
294
|
-
height: theme => ({
|
295
|
-
auto: 'auto',
|
296
|
-
...theme('spacing'),
|
297
|
-
full: '100%',
|
298
|
-
screen: '100vh',
|
299
|
-
}),
|
300
|
-
inset: {
|
301
|
-
0: '0',
|
302
|
-
auto: 'auto',
|
303
|
-
},
|
304
|
-
letterSpacing: {
|
305
|
-
tighter: '-0.05em',
|
306
|
-
tight: '-0.025em',
|
307
|
-
normal: '0',
|
308
|
-
wide: '0.025em',
|
309
|
-
wider: '0.05em',
|
310
|
-
widest: '0.1em',
|
311
|
-
},
|
312
|
-
lineHeight: {
|
313
|
-
none: '1',
|
314
|
-
tight: '1.25',
|
315
|
-
snug: '1.375',
|
316
|
-
normal: '1.5',
|
317
|
-
relaxed: '1.625',
|
318
|
-
loose: '2',
|
319
|
-
3: '.75rem',
|
320
|
-
4: '1rem',
|
321
|
-
5: '1.25rem',
|
322
|
-
6: '1.5rem',
|
323
|
-
7: '1.75rem',
|
324
|
-
8: '2rem',
|
325
|
-
9: '2.25rem',
|
326
|
-
10: '2.5rem',
|
327
|
-
},
|
328
|
-
listStyleType: {
|
329
|
-
none: 'none',
|
330
|
-
disc: 'disc',
|
331
|
-
decimal: 'decimal',
|
332
|
-
},
|
333
|
-
margin: (theme, { negative }) => ({
|
334
|
-
auto: 'auto',
|
335
|
-
...theme('spacing'),
|
336
|
-
...negative(theme('spacing')),
|
337
|
-
}),
|
338
|
-
maxHeight: {
|
339
|
-
full: '100%',
|
340
|
-
screen: '100vh',
|
341
|
-
},
|
342
|
-
maxWidth: (theme, { breakpoints }) => ({
|
343
|
-
none: 'none',
|
344
|
-
xs: '20rem',
|
345
|
-
sm: '24rem',
|
346
|
-
md: '28rem',
|
347
|
-
lg: '32rem',
|
348
|
-
xl: '36rem',
|
349
|
-
'2xl': '42rem',
|
350
|
-
'3xl': '48rem',
|
351
|
-
'4xl': '56rem',
|
352
|
-
'5xl': '64rem',
|
353
|
-
'6xl': '72rem',
|
354
|
-
full: '100%',
|
355
|
-
...breakpoints(theme('screens')),
|
356
|
-
}),
|
357
|
-
minHeight: {
|
358
|
-
0: '0',
|
359
|
-
full: '100%',
|
360
|
-
screen: '100vh',
|
361
|
-
},
|
362
|
-
minWidth: {
|
363
|
-
0: '0',
|
364
|
-
full: '100%',
|
365
|
-
},
|
366
|
-
objectPosition: {
|
367
|
-
bottom: 'bottom',
|
368
|
-
center: 'center',
|
369
|
-
left: 'left',
|
370
|
-
'left-bottom': 'left bottom',
|
371
|
-
'left-top': 'left top',
|
372
|
-
right: 'right',
|
373
|
-
'right-bottom': 'right bottom',
|
374
|
-
'right-top': 'right top',
|
375
|
-
top: 'top',
|
376
|
-
},
|
377
|
-
opacity: {
|
378
|
-
0: '0',
|
379
|
-
25: '0.25',
|
380
|
-
50: '0.5',
|
381
|
-
75: '0.75',
|
382
|
-
100: '1',
|
383
|
-
},
|
384
|
-
order: {
|
385
|
-
first: '-9999',
|
386
|
-
last: '9999',
|
387
|
-
none: '0',
|
388
|
-
1: '1',
|
389
|
-
2: '2',
|
390
|
-
3: '3',
|
391
|
-
4: '4',
|
392
|
-
5: '5',
|
393
|
-
6: '6',
|
394
|
-
7: '7',
|
395
|
-
8: '8',
|
396
|
-
9: '9',
|
397
|
-
10: '10',
|
398
|
-
11: '11',
|
399
|
-
12: '12',
|
400
|
-
},
|
401
|
-
padding: theme => theme('spacing'),
|
402
|
-
placeholderColor: theme => theme('colors'),
|
403
|
-
placeholderOpacity: theme => theme('opacity'),
|
404
|
-
space: (theme, { negative }) => ({
|
405
|
-
...theme('spacing'),
|
406
|
-
...negative(theme('spacing')),
|
407
|
-
}),
|
408
|
-
stroke: {
|
409
|
-
current: 'currentColor',
|
410
|
-
},
|
411
|
-
strokeWidth: {
|
412
|
-
0: '0',
|
413
|
-
1: '1',
|
414
|
-
2: '2',
|
415
|
-
},
|
416
|
-
textColor: theme => theme('colors'),
|
417
|
-
textOpacity: theme => theme('opacity'),
|
418
|
-
width: theme => ({
|
419
|
-
auto: 'auto',
|
420
|
-
...theme('spacing'),
|
421
|
-
'1/2': '50%',
|
422
|
-
'1/3': '33.333333%',
|
423
|
-
'2/3': '66.666667%',
|
424
|
-
'1/4': '25%',
|
425
|
-
'2/4': '50%',
|
426
|
-
'3/4': '75%',
|
427
|
-
'1/5': '20%',
|
428
|
-
'2/5': '40%',
|
429
|
-
'3/5': '60%',
|
430
|
-
'4/5': '80%',
|
431
|
-
'1/6': '16.666667%',
|
432
|
-
'2/6': '33.333333%',
|
433
|
-
'3/6': '50%',
|
434
|
-
'4/6': '66.666667%',
|
435
|
-
'5/6': '83.333333%',
|
436
|
-
'1/12': '8.333333%',
|
437
|
-
'2/12': '16.666667%',
|
438
|
-
'3/12': '25%',
|
439
|
-
'4/12': '33.333333%',
|
440
|
-
'5/12': '41.666667%',
|
441
|
-
'6/12': '50%',
|
442
|
-
'7/12': '58.333333%',
|
443
|
-
'8/12': '66.666667%',
|
444
|
-
'9/12': '75%',
|
445
|
-
'10/12': '83.333333%',
|
446
|
-
'11/12': '91.666667%',
|
447
|
-
full: '100%',
|
448
|
-
screen: '100vw',
|
449
|
-
}),
|
450
|
-
zIndex: {
|
451
|
-
auto: 'auto',
|
452
|
-
0: '0',
|
453
|
-
10: '10',
|
454
|
-
20: '20',
|
455
|
-
30: '30',
|
456
|
-
40: '40',
|
457
|
-
50: '50',
|
458
|
-
},
|
459
|
-
gap: theme => theme('spacing'),
|
460
|
-
gridTemplateColumns: {
|
461
|
-
none: 'none',
|
462
|
-
1: 'repeat(1, minmax(0, 1fr))',
|
463
|
-
2: 'repeat(2, minmax(0, 1fr))',
|
464
|
-
3: 'repeat(3, minmax(0, 1fr))',
|
465
|
-
4: 'repeat(4, minmax(0, 1fr))',
|
466
|
-
5: 'repeat(5, minmax(0, 1fr))',
|
467
|
-
6: 'repeat(6, minmax(0, 1fr))',
|
468
|
-
7: 'repeat(7, minmax(0, 1fr))',
|
469
|
-
8: 'repeat(8, minmax(0, 1fr))',
|
470
|
-
9: 'repeat(9, minmax(0, 1fr))',
|
471
|
-
10: 'repeat(10, minmax(0, 1fr))',
|
472
|
-
11: 'repeat(11, minmax(0, 1fr))',
|
473
|
-
12: 'repeat(12, minmax(0, 1fr))',
|
474
|
-
},
|
475
|
-
gridColumn: {
|
476
|
-
auto: 'auto',
|
477
|
-
'span-1': 'span 1 / span 1',
|
478
|
-
'span-2': 'span 2 / span 2',
|
479
|
-
'span-3': 'span 3 / span 3',
|
480
|
-
'span-4': 'span 4 / span 4',
|
481
|
-
'span-5': 'span 5 / span 5',
|
482
|
-
'span-6': 'span 6 / span 6',
|
483
|
-
'span-7': 'span 7 / span 7',
|
484
|
-
'span-8': 'span 8 / span 8',
|
485
|
-
'span-9': 'span 9 / span 9',
|
486
|
-
'span-10': 'span 10 / span 10',
|
487
|
-
'span-11': 'span 11 / span 11',
|
488
|
-
'span-12': 'span 12 / span 12',
|
489
|
-
},
|
490
|
-
gridColumnStart: {
|
491
|
-
auto: 'auto',
|
492
|
-
1: '1',
|
493
|
-
2: '2',
|
494
|
-
3: '3',
|
495
|
-
4: '4',
|
496
|
-
5: '5',
|
497
|
-
6: '6',
|
498
|
-
7: '7',
|
499
|
-
8: '8',
|
500
|
-
9: '9',
|
501
|
-
10: '10',
|
502
|
-
11: '11',
|
503
|
-
12: '12',
|
504
|
-
13: '13',
|
505
|
-
},
|
506
|
-
gridColumnEnd: {
|
507
|
-
auto: 'auto',
|
508
|
-
1: '1',
|
509
|
-
2: '2',
|
510
|
-
3: '3',
|
511
|
-
4: '4',
|
512
|
-
5: '5',
|
513
|
-
6: '6',
|
514
|
-
7: '7',
|
515
|
-
8: '8',
|
516
|
-
9: '9',
|
517
|
-
10: '10',
|
518
|
-
11: '11',
|
519
|
-
12: '12',
|
520
|
-
13: '13',
|
521
|
-
},
|
522
|
-
gridTemplateRows: {
|
523
|
-
none: 'none',
|
524
|
-
1: 'repeat(1, minmax(0, 1fr))',
|
525
|
-
2: 'repeat(2, minmax(0, 1fr))',
|
526
|
-
3: 'repeat(3, minmax(0, 1fr))',
|
527
|
-
4: 'repeat(4, minmax(0, 1fr))',
|
528
|
-
5: 'repeat(5, minmax(0, 1fr))',
|
529
|
-
6: 'repeat(6, minmax(0, 1fr))',
|
530
|
-
},
|
531
|
-
gridRow: {
|
532
|
-
auto: 'auto',
|
533
|
-
'span-1': 'span 1 / span 1',
|
534
|
-
'span-2': 'span 2 / span 2',
|
535
|
-
'span-3': 'span 3 / span 3',
|
536
|
-
'span-4': 'span 4 / span 4',
|
537
|
-
'span-5': 'span 5 / span 5',
|
538
|
-
'span-6': 'span 6 / span 6',
|
539
|
-
},
|
540
|
-
gridRowStart: {
|
541
|
-
auto: 'auto',
|
542
|
-
1: '1',
|
543
|
-
2: '2',
|
544
|
-
3: '3',
|
545
|
-
4: '4',
|
546
|
-
5: '5',
|
547
|
-
6: '6',
|
548
|
-
7: '7',
|
549
|
-
},
|
550
|
-
gridRowEnd: {
|
551
|
-
auto: 'auto',
|
552
|
-
1: '1',
|
553
|
-
2: '2',
|
554
|
-
3: '3',
|
555
|
-
4: '4',
|
556
|
-
5: '5',
|
557
|
-
6: '6',
|
558
|
-
7: '7',
|
559
|
-
},
|
560
|
-
transformOrigin: {
|
561
|
-
center: 'center',
|
562
|
-
top: 'top',
|
563
|
-
'top-right': 'top right',
|
564
|
-
right: 'right',
|
565
|
-
'bottom-right': 'bottom right',
|
566
|
-
bottom: 'bottom',
|
567
|
-
'bottom-left': 'bottom left',
|
568
|
-
left: 'left',
|
569
|
-
'top-left': 'top left',
|
570
|
-
},
|
571
|
-
scale: {
|
572
|
-
0: '0',
|
573
|
-
50: '.5',
|
574
|
-
75: '.75',
|
575
|
-
90: '.9',
|
576
|
-
95: '.95',
|
577
|
-
100: '1',
|
578
|
-
105: '1.05',
|
579
|
-
110: '1.1',
|
580
|
-
125: '1.25',
|
581
|
-
150: '1.5',
|
582
|
-
},
|
583
|
-
rotate: {
|
584
|
-
'-180': '-180deg',
|
585
|
-
'-90': '-90deg',
|
586
|
-
'-45': '-45deg',
|
587
|
-
0: '0',
|
588
|
-
45: '45deg',
|
589
|
-
90: '90deg',
|
590
|
-
180: '180deg',
|
591
|
-
},
|
592
|
-
translate: (theme, { negative }) => ({
|
593
|
-
...theme('spacing'),
|
594
|
-
...negative(theme('spacing')),
|
595
|
-
'-full': '-100%',
|
596
|
-
'-1/2': '-50%',
|
597
|
-
'1/2': '50%',
|
598
|
-
full: '100%',
|
599
|
-
}),
|
600
|
-
skew: {
|
601
|
-
'-12': '-12deg',
|
602
|
-
'-6': '-6deg',
|
603
|
-
'-3': '-3deg',
|
604
|
-
0: '0',
|
605
|
-
3: '3deg',
|
606
|
-
6: '6deg',
|
607
|
-
12: '12deg',
|
608
|
-
},
|
609
|
-
transitionProperty: {
|
610
|
-
none: 'none',
|
611
|
-
all: 'all',
|
612
|
-
default:
|
613
|
-
'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform',
|
614
|
-
colors: 'background-color, border-color, color, fill, stroke',
|
615
|
-
opacity: 'opacity',
|
616
|
-
shadow: 'box-shadow',
|
617
|
-
transform: 'transform',
|
618
|
-
},
|
619
|
-
transitionTimingFunction: {
|
620
|
-
linear: 'linear',
|
621
|
-
in: 'cubic-bezier(0.4, 0, 1, 1)',
|
622
|
-
out: 'cubic-bezier(0, 0, 0.2, 1)',
|
623
|
-
'in-out': 'cubic-bezier(0.4, 0, 0.2, 1)',
|
624
|
-
},
|
625
|
-
transitionDuration: {
|
626
|
-
75: '75ms',
|
627
|
-
100: '100ms',
|
628
|
-
150: '150ms',
|
629
|
-
200: '200ms',
|
630
|
-
300: '300ms',
|
631
|
-
500: '500ms',
|
632
|
-
700: '700ms',
|
633
|
-
1000: '1000ms',
|
634
|
-
},
|
635
|
-
transitionDelay: {
|
636
|
-
75: '75ms',
|
637
|
-
100: '100ms',
|
638
|
-
150: '150ms',
|
639
|
-
200: '200ms',
|
640
|
-
300: '300ms',
|
641
|
-
500: '500ms',
|
642
|
-
700: '700ms',
|
643
|
-
1000: '1000ms',
|
644
|
-
},
|
645
|
-
};
|
646
|
-
```
|
647
|
-
</details>
|
648
|
-
|
649
|
-
:::tip 提示
|
650
|
-
更多关于 Tailwind CSS 配置可查看[这里](https://tailwindcss.com/docs/configuration#theme)。
|
651
|
-
|
652
|
-
:::
|
653
|
-
|
654
|
-
`designSystem` 用于定义项目的调色板、排版比例(Typographic Scales 或者 Type Scale)、字体列表、断点、边框圆角值等等。因为 Modern.js 借用了 Tailwind Theme 的设计方式,并且内部也集成了 Tailwind CSS,所以 `designSystem` 使用方式与 Tailwind CSS Theme 相同。
|
655
|
-
|
656
|
-
### 结构
|
657
|
-
|
658
|
-
`designSystem` 对象包含 `screens`、`colors` 和 `spacing` 的属性,以及每个可自定义核心插件。
|
659
|
-
|
660
|
-
#### Screens
|
661
|
-
|
662
|
-
使用 `screens` 可以自定义项目中的响应断点:
|
663
|
-
|
664
|
-
```js
|
665
|
-
const designSystem = {
|
666
|
-
screens: {
|
667
|
-
sm: '640px',
|
668
|
-
md: '768px',
|
669
|
-
lg: '1024px',
|
670
|
-
xl: '1280px',
|
671
|
-
},
|
672
|
-
};
|
673
|
-
```
|
674
|
-
|
675
|
-
其中 `screens` 对象里的属性名是屏幕名称(用作 `Tailwind CSS` 生成的自适应实用程序变体的前缀,例如 `md:text-center`),值是该断点应在其开始的 `min-width`。
|
676
|
-
|
677
|
-
默认断点受常见设备分辨率的启发:
|
678
|
-
|
679
|
-
```js
|
680
|
-
const designSystem = {
|
681
|
-
screens: {
|
682
|
-
sm: '640px',
|
683
|
-
// => @media (min-width: 640px) { ... }
|
684
|
-
|
685
|
-
md: '768px',
|
686
|
-
// => @media (min-width: 768px) { ... }
|
687
|
-
|
688
|
-
lg: '1024px',
|
689
|
-
// => @media (min-width: 1024px) { ... }
|
690
|
-
|
691
|
-
xl: '1280px',
|
692
|
-
// => @media (min-width: 1280px) { ... }
|
693
|
-
},
|
694
|
-
};
|
695
|
-
```
|
696
|
-
|
697
|
-
你可以在你的项目中使用任意你喜欢的名称作为断点的属性:
|
698
|
-
|
699
|
-
```js
|
700
|
-
const designSystem = {
|
701
|
-
screens: {
|
702
|
-
tablet: '640px',
|
703
|
-
// => @media (min-width: 640px) { ... }
|
704
|
-
|
705
|
-
laptop: '1024px',
|
706
|
-
// => @media (min-width: 1024px) { ... }
|
707
|
-
|
708
|
-
desktop: '1280px',
|
709
|
-
// => @media (min-width: 1280px) { ... }
|
710
|
-
},
|
711
|
-
};
|
712
|
-
```
|
713
|
-
|
714
|
-
这些屏幕名称反映在 `utilities` 中,因此 `text-center` 现在是这样的:
|
715
|
-
|
716
|
-
```css
|
717
|
-
.text-center {
|
718
|
-
text-align: center;
|
719
|
-
}
|
720
|
-
|
721
|
-
@media (min-width: 640px) {
|
722
|
-
.tablet\:text-center {
|
723
|
-
text-align: center;
|
724
|
-
}
|
725
|
-
}
|
726
|
-
|
727
|
-
@media (min-width: 1024px) {
|
728
|
-
.laptop\:text-center {
|
729
|
-
text-align: center;
|
730
|
-
}
|
731
|
-
}
|
732
|
-
|
733
|
-
@media (min-width: 1280px) {
|
734
|
-
.desktop\:text-center {
|
735
|
-
text-align: center;
|
736
|
-
}
|
737
|
-
}
|
738
|
-
```
|
739
|
-
|
740
|
-
##### Max-width 断点
|
741
|
-
|
742
|
-
如果要使用 `max-width` 断点而不是 `min-width`,可以将屏幕指定为具有 `max` 属性的对象:
|
743
|
-
|
744
|
-
```js
|
745
|
-
const designSystem = {
|
746
|
-
screens: {
|
747
|
-
xl: { max: '1279px' },
|
748
|
-
// => @media (max-width: 1279px) { ... }
|
749
|
-
|
750
|
-
lg: { max: '1023px' },
|
751
|
-
// => @media (max-width: 1023px) { ... }
|
752
|
-
|
753
|
-
md: { max: '767px' },
|
754
|
-
// => @media (max-width: 767px) { ... }
|
755
|
-
|
756
|
-
sm: { max: '639px' },
|
757
|
-
// => @media (max-width: 639px) { ... }
|
758
|
-
},
|
759
|
-
};
|
760
|
-
```
|
761
|
-
|
762
|
-
如有必要,以创建带有 `min-width` 和 `max-width` 定义的断点,例如:
|
763
|
-
|
764
|
-
```js
|
765
|
-
const designSystem = {
|
766
|
-
screens: {
|
767
|
-
sm: { min: '640px', max: '767px' },
|
768
|
-
md: { min: '768px', max: '1023px' },
|
769
|
-
lg: { min: '1024px', max: '1279px' },
|
770
|
-
xl: { min: '1280px' },
|
771
|
-
},
|
772
|
-
};
|
773
|
-
```
|
774
|
-
|
775
|
-
##### 多个范围的断点
|
776
|
-
|
777
|
-
有时,将单个断点定义应用于多个范围会很有用。
|
778
|
-
|
779
|
-
例如,假设您有一个 `sidebar`,并且希望断点基于内容区域宽度而不是整个视口。您可以模拟这种情况,当 `sidebar` 可见并缩小内容区域时,断点的样式使用较小的断点样式:
|
780
|
-
|
781
|
-
```js
|
782
|
-
const designSystem = {
|
783
|
-
screens: {
|
784
|
-
sm: '500px',
|
785
|
-
md: [
|
786
|
-
// Sidebar appears at 768px, so revert to `sm:` styles between 768px
|
787
|
-
// and 868px, after which the main content area is wide enough again to
|
788
|
-
// apply the `md:` styles.
|
789
|
-
{ min: '668px', max: '767px' },
|
790
|
-
{ min: '868px' },
|
791
|
-
],
|
792
|
-
lg: '1100px',
|
793
|
-
xl: '1400px',
|
794
|
-
},
|
795
|
-
};
|
796
|
-
```
|
797
|
-
|
798
|
-
##### 自定义媒体查询
|
799
|
-
|
800
|
-
如果需要为断点提供完全自定义的媒体查询,则可以使用带有 `raw` 属性的对象:
|
801
|
-
|
802
|
-
```js
|
803
|
-
const designSystem = {
|
804
|
-
extend: {
|
805
|
-
screens: {
|
806
|
-
portrait: { raw: '(orientation: portrait)' },
|
807
|
-
// => @media (orientation: portrait) { ... }
|
808
|
-
},
|
809
|
-
},
|
810
|
-
};
|
811
|
-
```
|
812
|
-
|
813
|
-
##### Print 样式
|
814
|
-
|
815
|
-
如果需要为打印应用不同的样式,则 `raw` 选项可能特别有用。
|
816
|
-
|
817
|
-
需要做的就是在 `designSystem.extend.screens` 下添加一个 `print`:
|
818
|
-
|
819
|
-
```js
|
820
|
-
const designSystem = {
|
821
|
-
extend: {
|
822
|
-
screens: {
|
823
|
-
print: { raw: 'print' },
|
824
|
-
// => @media print { ... }
|
825
|
-
},
|
826
|
-
},
|
827
|
-
};
|
828
|
-
```
|
829
|
-
|
830
|
-
然后,可以使用诸如 `print:text-black` 之类的类来指定仅当某人尝试打印页面时才应用的样式:
|
831
|
-
|
832
|
-
```html
|
833
|
-
<div class="text-gray-700 print:text-black">
|
834
|
-
{/* ... */}
|
835
|
-
</div>
|
836
|
-
```
|
837
|
-
|
838
|
-
##### Dark Mode
|
839
|
-
|
840
|
-
`raw` 选项可以用于实现 “暗模式” 屏幕:
|
841
|
-
|
842
|
-
```js
|
843
|
-
const designSystem = {
|
844
|
-
extend: {
|
845
|
-
screens: {
|
846
|
-
dark: { raw: '(prefers-color-scheme: dark)' },
|
847
|
-
// => @media (prefers-color-scheme: dark) { ... }
|
848
|
-
},
|
849
|
-
},
|
850
|
-
};
|
851
|
-
```
|
852
|
-
|
853
|
-
然后,您可以使用 `dark:` 前缀在暗模式下为元素设置不同的样式:
|
854
|
-
|
855
|
-
```html
|
856
|
-
<div class="text-gray-700 dark:text-gray-200">
|
857
|
-
{/* ... */}
|
858
|
-
</div>
|
859
|
-
```
|
860
|
-
|
861
|
-
请注意,由于这些 `screen variants` 是在 `Tailwind CSS` 中实现的,因此**无法使用这种方法将断点与暗模式结合使用** ,例如 `md:dark:text-gray-300` 将不起作用。
|
862
|
-
|
863
|
-
#### Colors
|
864
|
-
|
865
|
-
`colors` 属性可让您自定义项目的全局调色板。
|
866
|
-
|
867
|
-
```js
|
868
|
-
const designSystem = {
|
869
|
-
colors: {
|
870
|
-
transparent: 'transparent',
|
871
|
-
black: '#000',
|
872
|
-
white: '#fff',
|
873
|
-
gray: {
|
874
|
-
100: '#f7fafc',
|
875
|
-
// ...
|
876
|
-
900: '#1a202c',
|
877
|
-
},
|
878
|
-
|
879
|
-
// ...
|
880
|
-
},
|
881
|
-
};
|
882
|
-
```
|
883
|
-
|
884
|
-
默认情况下,这些颜色由 `backgroundColor`,`textColor` 和 `borderColor` 核心插件继承。
|
885
|
-
|
886
|
-
想了解更多,可以查看:[Customizing Colors](https://tailwindcss.com/docs/customizing-colors)。
|
887
|
-
|
888
|
-
#### Spacing
|
889
|
-
|
890
|
-
使用 `space` 属性,可以自定义项目的全局间距和缩放比例:
|
891
|
-
|
892
|
-
```js
|
893
|
-
const designSystem = {
|
894
|
-
spacing: {
|
895
|
-
px: '1px',
|
896
|
-
0: '0',
|
897
|
-
1: '0.25rem',
|
898
|
-
2: '0.5rem',
|
899
|
-
3: '0.75rem',
|
900
|
-
4: '1rem',
|
901
|
-
5: '1.25rem',
|
902
|
-
6: '1.5rem',
|
903
|
-
8: '2rem',
|
904
|
-
10: '2.5rem',
|
905
|
-
12: '3rem',
|
906
|
-
16: '4rem',
|
907
|
-
20: '5rem',
|
908
|
-
24: '6rem',
|
909
|
-
32: '8rem',
|
910
|
-
40: '10rem',
|
911
|
-
48: '12rem',
|
912
|
-
56: '14rem',
|
913
|
-
64: '16rem',
|
914
|
-
},
|
915
|
-
};
|
916
|
-
```
|
917
|
-
|
918
|
-
默认情况下,这些值由 `padding`,`margin`,`negativeMargin`,`width` 和 `height` 核心插件继承。
|
919
|
-
|
920
|
-
想要了解更多,看 [Customizing Spacing](https://tailwindcss.com/docs/customizing-spacing)。
|
921
|
-
|
922
|
-
#### Core plugins
|
923
|
-
|
924
|
-
主题部分的其余部分用于配置每个核心插件可用的值。
|
925
|
-
|
926
|
-
例如,`borderRadius` 属性可让您自定义将生成的圆角的 `utilities`:
|
927
|
-
|
928
|
-
```js
|
929
|
-
const designSystem = {
|
930
|
-
borderRadius: {
|
931
|
-
none: '0',
|
932
|
-
sm: '.125rem',
|
933
|
-
default: '.25rem',
|
934
|
-
lg: '.5rem',
|
935
|
-
full: '9999px',
|
936
|
-
},
|
937
|
-
};
|
938
|
-
```
|
939
|
-
|
940
|
-
**属性名确定所生成类的后缀,值确定实际 CSS 声明的值。**上面的示例 `borderRadius` 配置将生成以下 CSS 类:
|
941
|
-
|
942
|
-
```css
|
943
|
-
.rounded-none {
|
944
|
-
border-radius: 0;
|
945
|
-
}
|
946
|
-
.rounded-sm {
|
947
|
-
border-radius: 0.125rem;
|
948
|
-
}
|
949
|
-
.rounded {
|
950
|
-
border-radius: 0.25rem;
|
951
|
-
}
|
952
|
-
.rounded-lg {
|
953
|
-
border-radius: 0.5rem;
|
954
|
-
}
|
955
|
-
.rounded-full {
|
956
|
-
border-radius: 9999px;
|
957
|
-
}
|
958
|
-
```
|
959
|
-
|
960
|
-
会注意到,在主题配置中使用 `default` 属性创建了不带后缀的 `rounded` 类。这是许多(尽管不是全部)核心插件支持的 Tailwind CSS 中的通用约定。
|
961
|
-
|
962
|
-
要了解有关自定义特定核心插件的更多信息,请访问该插件的文档。
|
963
|
-
|
964
|
-
### 自定义默认配置
|
965
|
-
|
966
|
-
开箱即用,您的项目将自动从默认主题配置继承值。如果想自定义默认主题,则根据目标有几种不同的选择。
|
967
|
-
|
968
|
-
#### 覆盖默认配置
|
969
|
-
|
970
|
-
要覆盖默认配置中的选项,请在 `designSystem` 中添加要覆盖的属性:
|
971
|
-
|
972
|
-
```ts title="modern.config.ts"
|
973
|
-
const designSystem = {
|
974
|
-
// Replaces all of the default `opacity` values
|
975
|
-
opacity: {
|
976
|
-
0: '0',
|
977
|
-
20: '0.2',
|
978
|
-
40: '0.4',
|
979
|
-
60: '0.6',
|
980
|
-
80: '0.8',
|
981
|
-
100: '1',
|
982
|
-
},
|
983
|
-
};
|
984
|
-
|
985
|
-
export default defineConfig({
|
986
|
-
source: {
|
987
|
-
designSystem,
|
988
|
-
},
|
989
|
-
});
|
990
|
-
```
|
991
|
-
|
992
|
-
这将完全替换默认属性配置,因此在上面的示例中,不会生成默认的 `opacity utilities`。
|
993
|
-
|
994
|
-
您未提供的任何属性都将从默认主题继承,因此在上面的示例中,将保留颜色,间距,边框圆角,背景位置等内容的默认主题配置。
|
995
|
-
|
996
|
-
#### 扩展默认配置
|
997
|
-
|
998
|
-
如果您想保留主题选项的默认值,但又要添加新值,请在 `designSystem.extend` 属性下添加扩展的内容。
|
999
|
-
|
1000
|
-
例如,如果您想添加一个额外的断点但保留现有的断点,则可以扩展 `screens` 属性:
|
1001
|
-
|
1002
|
-
```ts title="modern.config.ts"
|
1003
|
-
const designSystem = {
|
1004
|
-
extend: {
|
1005
|
-
// Adds a new breakpoint in addition to the default breakpoints
|
1006
|
-
screens: {
|
1007
|
-
'2xl': '1440px',
|
1008
|
-
},
|
1009
|
-
},
|
1010
|
-
};
|
1011
|
-
|
1012
|
-
export default defineConfig({
|
1013
|
-
source: {
|
1014
|
-
designSystem,
|
1015
|
-
},
|
1016
|
-
});
|
1017
|
-
```
|
1018
|
-
|
1019
|
-
您当然可以覆盖默认主题的某些部分,并在同一配置中扩展默认主题的其他部分:
|
1020
|
-
|
1021
|
-
```ts title="modern.config.ts"
|
1022
|
-
const designSystem = {
|
1023
|
-
opacity: {
|
1024
|
-
0: '0',
|
1025
|
-
20: '0.2',
|
1026
|
-
40: '0.4',
|
1027
|
-
60: '0.6',
|
1028
|
-
80: '0.8',
|
1029
|
-
100: '1',
|
1030
|
-
},
|
1031
|
-
extend: {
|
1032
|
-
screens: {
|
1033
|
-
'2xl': '1440px',
|
1034
|
-
},
|
1035
|
-
},
|
1036
|
-
};
|
1037
|
-
|
1038
|
-
export default defineConfig({
|
1039
|
-
source: {
|
1040
|
-
designSystem,
|
1041
|
-
},
|
1042
|
-
});
|
1043
|
-
```
|
1044
|
-
|
1045
|
-
#### 引用其他值
|
1046
|
-
|
1047
|
-
如果需要在配置中引用另一个值,可以通过提供闭包函数而不是静态值来实现。函数将收到 `theme()` 函数作为参数,您可以使用该函数使用点表示法在配置中查找其他值。
|
1048
|
-
|
1049
|
-
例如,您可以在 `fill` 配置上通过引用 `theme('colors')` 为调色板中的每种颜色生成 `fill` utilities。
|
1050
|
-
|
1051
|
-
```ts title="modern.config.ts"
|
1052
|
-
const designSystem = {
|
1053
|
-
colors: {
|
1054
|
-
// ...
|
1055
|
-
},
|
1056
|
-
fill: theme => theme('colors'),
|
1057
|
-
};
|
1058
|
-
|
1059
|
-
export default defineConfig({
|
1060
|
-
source: {
|
1061
|
-
designSystem,
|
1062
|
-
},
|
1063
|
-
});
|
1064
|
-
```
|
1065
|
-
|
1066
|
-
`theme()`函数尝试从已经完全合并的配置对象中找到您要查找的值,因此它可以引用您自己的自定义设置以及默认主题值。它也可以递归工作,因此只要链末尾有一个静态值,它就可以解析您要查找的值。
|
1067
|
-
|
1068
|
-
**引用默认配置**
|
1069
|
-
|
1070
|
-
如果出于任何原因想要引用默认配置中的值,则可以从 `tailwindcss/defaultTheme` 导入它。一个有用的示例是,如果要将添加默认配置提供的字体中某一个字体:
|
1071
|
-
|
1072
|
-
```ts title="modern.config.ts"
|
1073
|
-
const defaultTheme = require('tailwindcss/defaultTheme');
|
1074
|
-
|
1075
|
-
const designSystem = {
|
1076
|
-
extend: {
|
1077
|
-
fontFamily: {
|
1078
|
-
sans: ['Lato', ...defaultTheme.fontFamily.sans],
|
1079
|
-
},
|
1080
|
-
},
|
1081
|
-
};
|
1082
|
-
|
1083
|
-
export default defineConfig({
|
1084
|
-
source: {
|
1085
|
-
designSystem,
|
1086
|
-
},
|
1087
|
-
});
|
1088
|
-
```
|
1089
|
-
|
1090
|
-
#### 禁用整个核心插件
|
1091
|
-
|
1092
|
-
如果您不想为某个核心插件生成任何类,则最好在 `corePlugins` 配置中将该插件设置为 `false`,而不是在配置中为该属性提供一个空对象:
|
1093
|
-
|
1094
|
-
```js
|
1095
|
-
// Don't assign an empty object in your theme configuration
|
1096
|
-
|
1097
|
-
const designSystem = {
|
1098
|
-
opacity: {},
|
1099
|
-
};
|
1100
|
-
|
1101
|
-
// Do disable the plugin in your corePlugins configuration
|
1102
|
-
const designSyttem = {
|
1103
|
-
corePlugins: {
|
1104
|
-
opacity: false,
|
1105
|
-
},
|
1106
|
-
};
|
1107
|
-
```
|
1108
|
-
|
1109
|
-
最终结果是相同的,但是由于许多核心插件未公开任何配置,因此无论如何只能使用 corePlugins 禁用它们,最好保持一致。
|
1110
|
-
|
1111
|
-
#### 添加自己的 key
|
1112
|
-
|
1113
|
-
在很多情况下,将自己的属性添加到配置对象可能会很有用。
|
1114
|
-
|
1115
|
-
其中一个示例是添加新属性为多个核心插件之间复用。例如,您可以提取一个 `positions`对象,`backgroundPosition` 和 `objectPosition` 插件都可以引用该对象:
|
1116
|
-
|
1117
|
-
```js
|
1118
|
-
const designSystem = {
|
1119
|
-
positions: {
|
1120
|
-
bottom: 'bottom',
|
1121
|
-
center: 'center',
|
1122
|
-
left: 'left',
|
1123
|
-
'left-bottom': 'left bottom',
|
1124
|
-
'left-top': 'left top',
|
1125
|
-
right: 'right',
|
1126
|
-
'right-bottom': 'right bottom',
|
1127
|
-
'right-top': 'right top',
|
1128
|
-
top: 'top',
|
1129
|
-
},
|
1130
|
-
backgroundPosition: theme => theme('positions'),
|
1131
|
-
objectPosition: theme => theme('positions'),
|
1132
|
-
};
|
1133
|
-
```
|
1134
|
-
|
1135
|
-
另一个示例是在自定义插件中添加新的属性以进行引用。例如,如果您为项目编写了渐变插件,则可以向该插件引用的主题对象添加渐变属性:
|
1136
|
-
|
1137
|
-
```ts title="modern.config.ts"
|
1138
|
-
const designSystem = {
|
1139
|
-
gradients: theme => ({
|
1140
|
-
'blue-green': [theme('colors.blue.500'), theme('colors.green.500')],
|
1141
|
-
'purple-blue': [theme('colors.purple.500'), theme('colors.blue.500')],
|
1142
|
-
// ...
|
1143
|
-
}),
|
1144
|
-
};
|
1145
|
-
|
1146
|
-
export default defineConfig({
|
1147
|
-
source: {
|
1148
|
-
designSystem,
|
1149
|
-
},
|
1150
|
-
tools: {
|
1151
|
-
tailwind: {
|
1152
|
-
plugins: [require('./plugins/gradients')],
|
1153
|
-
},
|
1154
|
-
},
|
1155
|
-
});
|
1156
|
-
```
|
1157
|
-
|
1158
|
-
### 配置引用
|
1159
|
-
|
1160
|
-
除了 `screens`,`colors` 和 `spacing` 外,配置对象中的所有属性都映射到 `Tailwind CSS` 的核心插件上。由于许多插件负责仅接受静态值集(例如,例如`float`)的 CSS 属性,因此请注意,并非每个插件在主题对象中都有对应的属性。
|
1161
|
-
|
1162
|
-
所有这些属性也可以在 `designSystem.extend` 属性下使用,以扩展默认主题。
|
1163
|
-
|
1164
|
-
关于所有属性的作用,可以查看此 [链接](https://tailwindcss.com/docs/theme#configuration-reference)。
|
1165
|
-
|
1166
|
-
### 额外的配置
|
1167
|
-
|
1168
|
-
除了与 Tailwind CSS Theme 相同的配置以外,还有 Modern.js 提供的额外的配置。
|
1169
|
-
|
1170
|
-
#### source.designSystem.supportStyledComponents
|
1171
|
-
|
1172
|
-
该配置类型为 `boolean`,默认为 `false`。
|
1173
|
-
|
1174
|
-
当该配置值为 `true` 时,运行时在应用外层提供 `styled-components` `ThemeProvider` 组件,并且将通过 `designSystem` 生成的 `Theme Token` 对象注入。
|