@modern-js/module-tools-docs 2.0.0-beta.4 → 2.0.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/.eslintrc.js +13 -0
- package/docs/en/api/config/_category_.json +4 -0
- package/docs/en/api/{build-config.md → config/build-config.md} +198 -105
- package/docs/en/api/{build-preset.md → config/build-preset.md} +65 -46
- package/docs/{zh/api → en/api/config}/design-system.md +130 -127
- package/docs/en/api/config/plugins.md +18 -0
- package/docs/en/api/{test.md → config/testing.md} +21 -12
- package/docs/en/api/index.md +3 -1
- package/docs/en/api/plugin-api/_category_.json +4 -0
- package/docs/en/api/plugin-api/plugin-hooks.md +501 -0
- package/docs/en/guide/advance/_category_.json +4 -0
- package/docs/en/guide/advance/asset.mdx +47 -30
- package/docs/en/guide/advance/build-umd.mdx +88 -80
- package/docs/en/guide/advance/copy.md +31 -28
- package/docs/en/guide/advance/external-dependency.mdx +27 -23
- package/docs/en/guide/advance/in-depth-about-build.md +56 -50
- package/docs/en/guide/advance/in-depth-about-dev-command.md +7 -4
- package/docs/en/guide/advance/theme-config.mdx +80 -0
- package/docs/en/guide/basic/_category_.json +4 -0
- package/docs/en/guide/basic/before-getting-started.md +28 -23
- package/docs/en/guide/basic/command-preview.md +18 -14
- package/docs/en/guide/basic/modify-output-product.md +27 -20
- package/docs/en/guide/basic/publish-your-project.md +21 -19
- package/docs/en/guide/basic/test-your-project.mdx +19 -16
- package/docs/en/guide/basic/use-micro-generator.md +10 -7
- package/docs/en/guide/basic/using-storybook.mdx +27 -26
- package/docs/en/guide/best-practices/_category_.json +4 -0
- package/docs/en/guide/best-practices/components.mdx +783 -0
- package/docs/en/guide/intro/_category_.json +4 -0
- package/docs/en/guide/intro/getting-started.md +9 -4
- package/docs/en/guide/intro/welcome.md +4 -0
- package/docs/en/guide/intro/why-module-engineering-solution.md +5 -1
- package/docs/en/index.md +3 -5
- package/docs/en/plugins/guide/_category_.json +4 -0
- package/docs/en/plugins/guide/getting-started.mdx +84 -0
- package/docs/en/plugins/guide/plugin-object.mdx +85 -0
- package/docs/en/plugins/guide/setup-function.mdx +117 -0
- package/docs/en/plugins/official-list/_category_.json +4 -0
- package/docs/en/plugins/official-list/overview.md +6 -0
- package/docs/zh/api/config/_category_.json +4 -0
- package/docs/zh/api/config/build-config.md +658 -0
- package/docs/zh/api/{build-preset.md → config/build-preset.md} +49 -36
- package/docs/zh/api/config/design-system.md +1166 -0
- package/docs/zh/api/config/plugins.md +18 -0
- package/docs/zh/api/{testing.md → config/testing.md} +18 -13
- package/docs/zh/api/index.md +4 -1
- package/docs/zh/api/plugin-api/_category_.json +4 -0
- package/docs/zh/api/plugin-api/plugin-hooks.md +500 -0
- package/docs/zh/guide/advance/_category_.json +4 -0
- package/docs/zh/guide/advance/asset.mdx +47 -30
- package/docs/zh/guide/advance/build-umd.mdx +88 -71
- package/docs/zh/guide/advance/copy.md +31 -28
- package/docs/zh/guide/advance/external-dependency.mdx +27 -23
- package/docs/zh/guide/advance/in-depth-about-build.md +55 -50
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +7 -4
- package/docs/zh/guide/advance/theme-config.mdx +78 -0
- package/docs/zh/guide/basic/_category_.json +4 -0
- package/docs/zh/guide/basic/before-getting-started.md +27 -22
- package/docs/zh/guide/basic/command-preview.md +17 -13
- package/docs/zh/guide/basic/modify-output-product.md +28 -21
- package/docs/zh/guide/basic/publish-your-project.md +22 -17
- package/docs/zh/guide/basic/test-your-project.mdx +20 -16
- package/docs/zh/guide/basic/use-micro-generator.md +10 -7
- package/docs/zh/guide/basic/using-storybook.mdx +27 -24
- package/docs/zh/guide/best-practices/_category_.json +4 -0
- package/docs/zh/guide/best-practices/components.mdx +793 -0
- package/docs/zh/guide/intro/_category_.json +4 -0
- package/docs/zh/guide/intro/getting-started.md +10 -4
- package/docs/zh/guide/intro/welcome.md +4 -0
- package/docs/zh/guide/intro/why-module-engineering-solution.md +5 -1
- package/docs/zh/index.md +3 -2
- package/docs/zh/plugins/guide/_category_.json +4 -0
- package/docs/zh/plugins/guide/getting-started.mdx +84 -0
- package/docs/zh/plugins/guide/plugin-object.mdx +85 -0
- package/docs/zh/plugins/guide/setup-function.mdx +117 -0
- package/docs/zh/plugins/official-list/_category_.json +4 -0
- package/docs/zh/plugins/official-list/overview.md +5 -0
- package/modern.config.ts +118 -0
- package/package.json +8 -6
- package/{docs/.island/styles → theme}/index.css +0 -1
- package/theme/index.ts +4 -0
- package/tsconfig.json +7 -0
- package/docs/.island/config.ts +0 -245
- package/docs/.island/dist/404.html +0 -41
- package/docs/.island/dist/assets/before-getting-started.1b82b538.js +0 -87
- package/docs/.island/dist/assets/before-getting-started.582a31cc.js +0 -87
- package/docs/.island/dist/assets/build-config.72eb0918.js +0 -804
- package/docs/.island/dist/assets/build-config.d8bb1658.js +0 -809
- package/docs/.island/dist/assets/build-preset.96805d7d.js +0 -256
- package/docs/.island/dist/assets/build-preset.c20dcd40.js +0 -256
- package/docs/.island/dist/assets/build-your-ui.7f349247.js +0 -2
- package/docs/.island/dist/assets/build-your-ui.a8361604.js +0 -2
- package/docs/.island/dist/assets/command-preview.2d45fc82.js +0 -264
- package/docs/.island/dist/assets/command-preview.dc51b953.js +0 -264
- package/docs/.island/dist/assets/components.esm.03560353.js +0 -9
- package/docs/.island/dist/assets/design-system.86694ff5.js +0 -1254
- package/docs/.island/dist/assets/design-system.c4745cce.js +0 -639
- package/docs/.island/dist/assets/dev.1d326a37.js +0 -37
- package/docs/.island/dist/assets/dev.1fd06000.js +0 -37
- package/docs/.island/dist/assets/down.f35427d3.svg +0 -1
- package/docs/.island/dist/assets/extension.12299fd6.js +0 -2
- package/docs/.island/dist/assets/extension.96dc63a4.js +0 -2
- package/docs/.island/dist/assets/getting-started.40e9218d.js +0 -117
- package/docs/.island/dist/assets/getting-started.b1ed3f10.js +0 -114
- package/docs/.island/dist/assets/github.3bf8ccee.svg +0 -1
- package/docs/.island/dist/assets/index.2b2347ea.js +0 -33
- package/docs/.island/dist/assets/index.6cef6f5f.js +0 -4
- package/docs/.island/dist/assets/index.cb118238.js +0 -36
- package/docs/.island/dist/assets/index.ccb6ce27.js +0 -4
- package/docs/.island/dist/assets/island_inject.11a12ecc.js +0 -1
- package/docs/.island/dist/assets/island_inject.b13deaee.js +0 -1
- package/docs/.island/dist/assets/loading.8c9bb911.svg +0 -1
- package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +0 -100
- package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +0 -100
- package/docs/.island/dist/assets/moon.6b705924.svg +0 -3
- package/docs/.island/dist/assets/plugin.895932d8.js +0 -42
- package/docs/.island/dist/assets/plugin.d2fbc531.js +0 -42
- package/docs/.island/dist/assets/publish-your-project.21b8309f.js +0 -164
- package/docs/.island/dist/assets/publish-your-project.8d398b17.js +0 -166
- package/docs/.island/dist/assets/right.89674cd7.svg +0 -1
- package/docs/.island/dist/assets/search.0aea6901.svg +0 -1
- package/docs/.island/dist/assets/search.1c85d17c.js +0 -3
- package/docs/.island/dist/assets/search.484eca11.js +0 -222
- package/docs/.island/dist/assets/search.54fca8d0.js +0 -3
- package/docs/.island/dist/assets/style.09015a4b.css +0 -1
- package/docs/.island/dist/assets/style.2e5f7bc2.css +0 -1970
- package/docs/.island/dist/assets/sun.841dac10.svg +0 -11
- package/docs/.island/dist/assets/test-your-project.18bd4582.js +0 -190
- package/docs/.island/dist/assets/test-your-project.f53bebf7.js +0 -190
- package/docs/.island/dist/assets/test.0da1f99f.js +0 -67
- package/docs/.island/dist/assets/test.0e81f002.js +0 -66
- package/docs/.island/dist/assets/translator.b1077c44.svg +0 -1
- package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +0 -60
- package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +0 -60
- package/docs/.island/dist/assets/using-storybook.57ea6b77.js +0 -260
- package/docs/.island/dist/assets/using-storybook.a2212f2e.js +0 -260
- package/docs/.island/dist/assets/welcome.0449a9c8.js +0 -13
- package/docs/.island/dist/assets/welcome.a8448931.js +0 -13
- package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +0 -26
- package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +0 -26
- package/docs/.island/dist/chunk-COLCRJ2V.js +0 -1
- package/docs/.island/dist/chunk-K5FMOYDC.js +0 -10
- package/docs/.island/dist/chunk-WE42KMYS.js +0 -26
- package/docs/.island/dist/client-entry.js +0 -3
- package/docs/.island/dist/en/api/build-config.html +0 -344
- package/docs/.island/dist/en/api/build-preset.html +0 -82
- package/docs/.island/dist/en/api/design-system.html +0 -155
- package/docs/.island/dist/en/api/dev.html +0 -45
- package/docs/.island/dist/en/api/index.html +0 -41
- package/docs/.island/dist/en/api/plugin.html +0 -48
- package/docs/.island/dist/en/api/test.html +0 -58
- package/docs/.island/dist/en/guide/before-getting-started.html +0 -127
- package/docs/.island/dist/en/guide/build-your-ui.html +0 -41
- package/docs/.island/dist/en/guide/command-preview.html +0 -100
- package/docs/.island/dist/en/guide/extension.html +0 -41
- package/docs/.island/dist/en/guide/getting-started.html +0 -76
- package/docs/.island/dist/en/guide/modify-output-product.html +0 -140
- package/docs/.island/dist/en/guide/publish-your-project.html +0 -91
- package/docs/.island/dist/en/guide/test-your-project.html +0 -72
- package/docs/.island/dist/en/guide/use-micro-generator.html +0 -65
- package/docs/.island/dist/en/guide/using-storybook.html +0 -113
- package/docs/.island/dist/en/guide/welcome.html +0 -53
- package/docs/.island/dist/en/guide/why-module-engineering-solution.html +0 -49
- package/docs/.island/dist/en/index.html +0 -42
- package/docs/.island/dist/react-dom.js +0 -1
- package/docs/.island/dist/react-dom_client.js +0 -1
- package/docs/.island/dist/react.js +0 -1
- package/docs/.island/dist/react_jsx-runtime.js +0 -10
- package/docs/.island/dist/ssr-manifest.json +0 -57
- 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 +0 -347
- package/docs/.island/dist/zh/api/build-preset.html +0 -82
- package/docs/.island/dist/zh/api/design-system.html +0 -149
- package/docs/.island/dist/zh/api/dev.html +0 -46
- package/docs/.island/dist/zh/api/index.html +0 -41
- package/docs/.island/dist/zh/api/plugin.html +0 -48
- package/docs/.island/dist/zh/api/test.html +0 -59
- package/docs/.island/dist/zh/guide/before-getting-started.html +0 -127
- package/docs/.island/dist/zh/guide/build-your-ui.html +0 -41
- package/docs/.island/dist/zh/guide/command-preview.html +0 -100
- package/docs/.island/dist/zh/guide/extension.html +0 -41
- package/docs/.island/dist/zh/guide/getting-started.html +0 -79
- package/docs/.island/dist/zh/guide/modify-output-product.html +0 -140
- package/docs/.island/dist/zh/guide/publish-your-project.html +0 -92
- package/docs/.island/dist/zh/guide/test-your-project.html +0 -72
- package/docs/.island/dist/zh/guide/use-micro-generator.html +0 -65
- package/docs/.island/dist/zh/guide/using-storybook.html +0 -114
- package/docs/.island/dist/zh/guide/welcome.html +0 -53
- package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +0 -49
- package/docs/.island/dist/zh/index.html +0 -42
- package/docs/.island/index.html +0 -39
- package/docs/en/api/design-system.md +0 -524
- package/docs/en/api/dev.md +0 -32
- package/docs/en/api/plugin.md +0 -34
- package/docs/zh/api/build-config.md +0 -570
- package/docs/zh/api/dev.md +0 -33
- package/docs/zh/api/plugins.md +0 -108
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
1
5
|
# DesignSystem
|
|
2
|
-
|
|
6
|
+
|
|
7
|
+
This chapter describes the configuration related to designSystem
|
|
3
8
|
|
|
4
9
|
:::tips
|
|
5
|
-
|
|
10
|
+
The Tailwind CSS feature needs to be enabled first via `pnpm run new`.
|
|
6
11
|
:::
|
|
7
12
|
|
|
13
|
+
- type: `Object`
|
|
14
|
+
- default: `see configuration details below`.
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<details>
|
|
13
|
-
<summary>designSystem 配置详情</summary>
|
|
14
|
-
|
|
16
|
+
<details
|
|
17
|
+
<summary>designSystem configuration details</summary>
|
|
15
18
|
```js
|
|
16
19
|
const designSystem = {
|
|
17
20
|
screens: {
|
|
@@ -631,22 +634,23 @@
|
|
|
631
634
|
'700': '700ms',
|
|
632
635
|
'1000': '1000ms',
|
|
633
636
|
},
|
|
634
|
-
};
|
|
635
|
-
```
|
|
636
637
|
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
````
|
|
637
641
|
:::tips
|
|
638
|
-
|
|
642
|
+
More about [TailwindCSS configuration](https://tailwindcss.com/docs/configuration#theme)
|
|
639
643
|
:::
|
|
640
644
|
</details>
|
|
641
645
|
|
|
642
646
|
|
|
643
|
-
`designSystem`
|
|
647
|
+
The `designSystem` is used to define the project's color palette, typographic scales (Typographic Scales or Type Scale), font list, breakpoints, border rounding values, etc. Since Modern.js borrows the design approach from Tailwind Theme and integrates with Tailwind CSS internally, `designSystem` is used in the same way as Tailwind CSS Theme
|
|
644
648
|
|
|
645
|
-
`designSystem`
|
|
649
|
+
The `designSystem` object contains the `screens`, `colors` and `spacing` properties, as well as each customizable core plugin.
|
|
646
650
|
|
|
647
651
|
## Screens
|
|
648
652
|
|
|
649
|
-
|
|
653
|
+
The responsive breakpoints in your project can be customized using `screens`: the
|
|
650
654
|
|
|
651
655
|
```js
|
|
652
656
|
const designSystem = {
|
|
@@ -657,11 +661,11 @@ const designSystem = {
|
|
|
657
661
|
xl: '1280px',
|
|
658
662
|
},
|
|
659
663
|
};
|
|
660
|
-
|
|
664
|
+
````
|
|
661
665
|
|
|
662
|
-
|
|
666
|
+
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.
|
|
663
667
|
|
|
664
|
-
|
|
668
|
+
Default breakpoints are inspired by common device resolutions: the
|
|
665
669
|
|
|
666
670
|
```js
|
|
667
671
|
const designSystem = {
|
|
@@ -681,7 +685,7 @@ const designSystem = {
|
|
|
681
685
|
};
|
|
682
686
|
```
|
|
683
687
|
|
|
684
|
-
|
|
688
|
+
You can use any name you like as a breakpoint property in your project: the
|
|
685
689
|
|
|
686
690
|
```js
|
|
687
691
|
const designSystem = {
|
|
@@ -698,32 +702,40 @@ const designSystem = {
|
|
|
698
702
|
};
|
|
699
703
|
```
|
|
700
704
|
|
|
701
|
-
|
|
705
|
+
These screen names are reflected in `utilities`, so `text-center` now looks like this
|
|
702
706
|
|
|
703
707
|
```css
|
|
704
|
-
.text-center {
|
|
708
|
+
.text-center {
|
|
709
|
+
text-align: center;
|
|
710
|
+
}
|
|
705
711
|
|
|
706
712
|
@media (min-width: 640px) {
|
|
707
|
-
|
|
713
|
+
.tablet\:text-center {
|
|
714
|
+
text-align: center;
|
|
715
|
+
}
|
|
708
716
|
}
|
|
709
717
|
|
|
710
718
|
@media (min-width: 1024px) {
|
|
711
|
-
|
|
719
|
+
.laptop\:text-center {
|
|
720
|
+
text-align: center;
|
|
721
|
+
}
|
|
712
722
|
}
|
|
713
723
|
|
|
714
724
|
@media (min-width: 1280px) {
|
|
715
|
-
|
|
725
|
+
.desktop\:text-center {
|
|
726
|
+
text-align: center;
|
|
727
|
+
}
|
|
716
728
|
}
|
|
717
729
|
```
|
|
718
730
|
|
|
719
|
-
### Max-width
|
|
731
|
+
### Max-width breakpoints
|
|
720
732
|
|
|
721
|
-
|
|
733
|
+
To use the `max-width` breakpoint instead of `min-width`, you can specify the screen as an object with the `max` attribute.
|
|
722
734
|
|
|
723
735
|
```js
|
|
724
736
|
const designSystem = {
|
|
725
737
|
screens: {
|
|
726
|
-
xl: { max: '1279px' }
|
|
738
|
+
xl: { max: '1279px' }
|
|
727
739
|
// => @media (max-width: 1279px) { ... }
|
|
728
740
|
|
|
729
741
|
lg: { max: '1023px' },
|
|
@@ -738,24 +750,24 @@ const designSystem = {
|
|
|
738
750
|
};
|
|
739
751
|
```
|
|
740
752
|
|
|
741
|
-
|
|
753
|
+
If necessary, to create breakpoints with `min-width` and `max-width` definitions, e.g.
|
|
742
754
|
|
|
743
755
|
```js
|
|
744
756
|
const designSystem = {
|
|
745
757
|
screens: {
|
|
746
|
-
sm: { min: '640px', max: '767px' }
|
|
747
|
-
md: { min: '768px', max: '1023px' }
|
|
748
|
-
lg: { min: '1024px', max: '1279px' },
|
|
749
|
-
xl: { min: '1280px' }
|
|
758
|
+
sm: { min: '640px', max: '767px' }
|
|
759
|
+
md: { min: '768px', max: '1023px' }
|
|
760
|
+
lg: { min: '1024px', max: '1279px' }, lg: { min: '1024px', max: '1279px' },
|
|
761
|
+
xl: { min: '1280px' }
|
|
750
762
|
},
|
|
751
763
|
};
|
|
752
764
|
```
|
|
753
765
|
|
|
754
|
-
###
|
|
766
|
+
### Multiple range breakpoints
|
|
755
767
|
|
|
756
|
-
|
|
768
|
+
Sometimes it can be useful to apply a single breakpoint definition to multiple scopes.
|
|
757
769
|
|
|
758
|
-
|
|
770
|
+
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
|
|
759
771
|
|
|
760
772
|
```js
|
|
761
773
|
const designSystem = {
|
|
@@ -765,8 +777,8 @@ const designSystem = {
|
|
|
765
777
|
// Sidebar appears at 768px, so revert to `sm:` styles between 768px
|
|
766
778
|
// and 868px, after which the main content area is wide enough again to
|
|
767
779
|
// apply the `md:` styles.
|
|
768
|
-
{ min: '668px', max: '767px' }
|
|
769
|
-
{ min: '868px' },
|
|
780
|
+
{ min: '668px', max: '767px' }
|
|
781
|
+
{ min: '868px' }, { min: '868px' },
|
|
770
782
|
],
|
|
771
783
|
lg: '1100px',
|
|
772
784
|
xl: '1400px',
|
|
@@ -774,9 +786,9 @@ const designSystem = {
|
|
|
774
786
|
};
|
|
775
787
|
```
|
|
776
788
|
|
|
777
|
-
###
|
|
789
|
+
### Custom media queries
|
|
778
790
|
|
|
779
|
-
|
|
791
|
+
If a fully customizable media query is required for a breakpoint, an object with the `raw` attribute can be used.
|
|
780
792
|
|
|
781
793
|
```js
|
|
782
794
|
const designSystem = {
|
|
@@ -789,30 +801,31 @@ const designSystem = {
|
|
|
789
801
|
};
|
|
790
802
|
```
|
|
791
803
|
|
|
792
|
-
### Print
|
|
804
|
+
### Print styles
|
|
793
805
|
|
|
794
|
-
|
|
806
|
+
The `raw` option may be particularly useful if you need to apply different styles to printing.
|
|
795
807
|
|
|
796
|
-
|
|
808
|
+
All that needs to be done is to add a `print` under `designSystem.extend.screens`.
|
|
797
809
|
|
|
798
|
-
|
|
810
|
+
``js
|
|
799
811
|
const designSystem = {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
812
|
+
extend: {
|
|
813
|
+
screens: {
|
|
814
|
+
print: { raw: 'print' },
|
|
815
|
+
// => @media print { ... }
|
|
816
|
+
},
|
|
817
|
+
},
|
|
806
818
|
};
|
|
807
|
-
```
|
|
808
819
|
|
|
809
|
-
|
|
820
|
+
````
|
|
821
|
+
|
|
822
|
+
Then, a class such as ``print:text-black`` can be used to specify a style that is applied only when someone tries to print a page: ``
|
|
810
823
|
|
|
811
824
|
```html
|
|
812
825
|
<div class="text-gray-700 print:text-black">
|
|
813
|
-
|
|
826
|
+
<! -- ... -->
|
|
814
827
|
</div>
|
|
815
|
-
|
|
828
|
+
````
|
|
816
829
|
|
|
817
830
|
### Dark Mode
|
|
818
831
|
|
|
@@ -833,7 +846,7 @@ const designSystem = {
|
|
|
833
846
|
|
|
834
847
|
```html
|
|
835
848
|
<div class="text-gray-700 dark:text-gray-200">
|
|
836
|
-
|
|
849
|
+
<! -- ... -->
|
|
837
850
|
</div>
|
|
838
851
|
```
|
|
839
852
|
|
|
@@ -860,13 +873,13 @@ const designSystem = {
|
|
|
860
873
|
};
|
|
861
874
|
```
|
|
862
875
|
|
|
863
|
-
|
|
876
|
+
By default, these colors are inherited by the `backgroundColor`, `textColor` and `borderColor` core plugins.
|
|
864
877
|
|
|
865
|
-
|
|
878
|
+
To learn more, you can check out: [Customizing Colors](https://tailwindcss.com/docs/customizing-colors).
|
|
866
879
|
|
|
867
880
|
## Spacing
|
|
868
881
|
|
|
869
|
-
|
|
882
|
+
The global spacing and scaling of items can be customized using the `space` attribute: the
|
|
870
883
|
|
|
871
884
|
```js
|
|
872
885
|
const designSystem = {
|
|
@@ -894,52 +907,53 @@ const designSystem = {
|
|
|
894
907
|
};
|
|
895
908
|
```
|
|
896
909
|
|
|
897
|
-
|
|
910
|
+
By default, these values are inherited by the `padding`, `margin`, `negativeMargin`, `width` and `height` core plugins.
|
|
898
911
|
|
|
899
|
-
|
|
912
|
+
To learn more, see [Customizing Spacing](https://tailwindcss.com/docs/customizing-spacing).
|
|
900
913
|
|
|
901
|
-
##
|
|
914
|
+
## Core plugins
|
|
902
915
|
|
|
903
|
-
|
|
916
|
+
The rest of the theme section is used to configure the values available for each core plugin.
|
|
904
917
|
|
|
905
|
-
|
|
918
|
+
For example, the `borderRadius` property allows you to customize the ``utilities` that will generate the rounded corners.
|
|
906
919
|
|
|
907
|
-
|
|
920
|
+
``js
|
|
908
921
|
const designSystem = {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
922
|
+
borderRadius: {
|
|
923
|
+
none: '0',
|
|
924
|
+
sm: '.125rem',
|
|
925
|
+
default: '.25rem',
|
|
926
|
+
lg: '.5rem',
|
|
927
|
+
full: '9999px',
|
|
928
|
+
},
|
|
916
929
|
};
|
|
917
|
-
```
|
|
918
930
|
|
|
919
|
-
|
|
920
|
-
|
|
931
|
+
````
|
|
932
|
+
|
|
933
|
+
** The attribute name determines the suffix of the generated class, and the value determines the value of the actual CSS declaration. **
|
|
934
|
+
The example ``borderRadius`` configuration above will generate the following CSS classes.
|
|
921
935
|
|
|
922
936
|
```css
|
|
923
937
|
.rounded-none { border-radius: 0 }
|
|
924
|
-
.rounded-sm
|
|
925
|
-
.rounded
|
|
926
|
-
.rounded-lg
|
|
938
|
+
.rounded-sm { border-radius: .125rem }
|
|
939
|
+
.rounded { border-radius: .25rem }
|
|
940
|
+
.rounded-lg { border-radius: .5rem }
|
|
927
941
|
.rounded-full { border-radius: 9999px }
|
|
928
|
-
|
|
942
|
+
````
|
|
929
943
|
|
|
930
|
-
|
|
944
|
+
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 supported by many (though not all) of the core plugins.
|
|
931
945
|
|
|
932
|
-
|
|
946
|
+
To learn more about customizing a specific core plugin, please visit the documentation for that plugin.
|
|
933
947
|
|
|
934
|
-
##
|
|
948
|
+
## Customizing the default configuration
|
|
935
949
|
|
|
936
|
-
|
|
950
|
+
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.
|
|
937
951
|
|
|
938
|
-
###
|
|
952
|
+
### Override the default configuration
|
|
939
953
|
|
|
940
|
-
|
|
954
|
+
To override the options in the default configuration, add the properties to be overridden to `designSystem` at
|
|
941
955
|
|
|
942
|
-
```
|
|
956
|
+
```js modern.config.ts
|
|
943
957
|
import { defineConfig } from '@modern-js/module-tools';
|
|
944
958
|
|
|
945
959
|
const designSystem = {
|
|
@@ -959,17 +973,17 @@ export default defineConfig({
|
|
|
959
973
|
});
|
|
960
974
|
```
|
|
961
975
|
|
|
962
|
-
|
|
976
|
+
This will completely replace the default property configuration, so in the above example, the default `opacity utilities` will not be generated.
|
|
963
977
|
|
|
964
|
-
|
|
978
|
+
Any properties you do not provide will be inherited from the default theme, so in the example above, the default theme configuration for color, spacing, border rounding, background position, etc. will be retained.
|
|
965
979
|
|
|
966
|
-
###
|
|
980
|
+
### Extending the default configuration
|
|
967
981
|
|
|
968
|
-
|
|
982
|
+
If you want to keep the default values of the theme options but add new values, add the extensions under the `designSystem.extend` property.
|
|
969
983
|
|
|
970
|
-
|
|
984
|
+
For example, if you want to add an additional breakpoint but keep the existing one, you can extend the `screens` property with.
|
|
971
985
|
|
|
972
|
-
```
|
|
986
|
+
```js modern.config.ts
|
|
973
987
|
import { defineConfig } from '@modern-js/module-tools';
|
|
974
988
|
|
|
975
989
|
const designSystem = {
|
|
@@ -986,9 +1000,9 @@ export default defineConfig({
|
|
|
986
1000
|
});
|
|
987
1001
|
```
|
|
988
1002
|
|
|
989
|
-
|
|
1003
|
+
You can certainly override some parts of the default theme and extend other parts of the default theme in the same configuration: the
|
|
990
1004
|
|
|
991
|
-
```
|
|
1005
|
+
```js modern.config.ts
|
|
992
1006
|
import { defineConfig } from '@modern-js/module-tools';
|
|
993
1007
|
|
|
994
1008
|
const designSystem = {
|
|
@@ -1012,13 +1026,13 @@ export default defineConfig({
|
|
|
1012
1026
|
});
|
|
1013
1027
|
```
|
|
1014
1028
|
|
|
1015
|
-
###
|
|
1029
|
+
### Referencing other values
|
|
1016
1030
|
|
|
1017
|
-
|
|
1031
|
+
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 a dot representation.
|
|
1018
1032
|
|
|
1019
|
-
|
|
1033
|
+
For example, you can generate `fill` utilities for each color in the palette by referring to `theme('colors')` on the `fill` configuration.
|
|
1020
1034
|
|
|
1021
|
-
```
|
|
1035
|
+
```js modern.config.ts
|
|
1022
1036
|
import { defineConfig } from '@modern-js/module-tools';
|
|
1023
1037
|
|
|
1024
1038
|
const designSystem = {
|
|
@@ -1033,13 +1047,13 @@ export default defineConfig({
|
|
|
1033
1047
|
});
|
|
1034
1048
|
```
|
|
1035
1049
|
|
|
1036
|
-
`theme()
|
|
1050
|
+
The `theme()` function tries 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.
|
|
1037
1051
|
|
|
1038
|
-
|
|
1052
|
+
**Reference to the default configuration**
|
|
1039
1053
|
|
|
1040
|
-
|
|
1054
|
+
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.
|
|
1041
1055
|
|
|
1042
|
-
```
|
|
1056
|
+
```js modern.config.ts
|
|
1043
1057
|
import { defineConfig } from '@modern-js/module-tools';
|
|
1044
1058
|
|
|
1045
1059
|
const defaultTheme = require('tailwindcss/defaultTheme');
|
|
@@ -1047,7 +1061,7 @@ const defaultTheme = require('tailwindcss/defaultTheme');
|
|
|
1047
1061
|
const designSystem = {
|
|
1048
1062
|
extend: {
|
|
1049
1063
|
fontFamily: {
|
|
1050
|
-
sans: ['Lato', ...defaultTheme.fontFamily.sans],
|
|
1064
|
+
sans: ['Lato', ... .defaultTheme.fontFamily.sans],
|
|
1051
1065
|
},
|
|
1052
1066
|
},
|
|
1053
1067
|
};
|
|
@@ -1057,9 +1071,9 @@ export default defineConfig({
|
|
|
1057
1071
|
});
|
|
1058
1072
|
```
|
|
1059
1073
|
|
|
1060
|
-
###
|
|
1074
|
+
### Disabling the entire core plugin
|
|
1061
1075
|
|
|
1062
|
-
|
|
1076
|
+
If you don't want to generate any classes for a core plugin, it's better to set the plugin to `false` in the `corePlugins` configuration, rather than providing an empty object for the property in the configuration: ``
|
|
1063
1077
|
|
|
1064
1078
|
```js
|
|
1065
1079
|
// Don't assign an empty object in your theme configuration
|
|
@@ -1071,18 +1085,18 @@ const designSystem = {
|
|
|
1071
1085
|
// Do disable the plugin in your corePlugins configuration
|
|
1072
1086
|
const designSyttem = {
|
|
1073
1087
|
corePlugins: {
|
|
1074
|
-
opacity: false,
|
|
1088
|
+
opacity: { false,
|
|
1075
1089
|
},
|
|
1076
1090
|
};
|
|
1077
1091
|
```
|
|
1078
1092
|
|
|
1079
|
-
|
|
1093
|
+
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.
|
|
1080
1094
|
|
|
1081
|
-
###
|
|
1095
|
+
### Adding your own key
|
|
1082
1096
|
|
|
1083
|
-
|
|
1097
|
+
In many cases it may be useful to add your own properties to the configuration object.
|
|
1084
1098
|
|
|
1085
|
-
|
|
1099
|
+
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.
|
|
1086
1100
|
|
|
1087
1101
|
```js
|
|
1088
1102
|
const designSystem = {
|
|
@@ -1102,9 +1116,9 @@ const designSystem = {
|
|
|
1102
1116
|
};
|
|
1103
1117
|
```
|
|
1104
1118
|
|
|
1105
|
-
|
|
1119
|
+
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.
|
|
1106
1120
|
|
|
1107
|
-
```
|
|
1121
|
+
```js modern.config.ts
|
|
1108
1122
|
import { defineConfig } from '@modern-js/module-tools';
|
|
1109
1123
|
|
|
1110
1124
|
const designSystem = {
|
|
@@ -1120,28 +1134,17 @@ export default defineConfig({
|
|
|
1120
1134
|
buildConfig: {
|
|
1121
1135
|
style: {
|
|
1122
1136
|
postcss: {
|
|
1123
|
-
plugins: [require('
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1137
|
+
plugins: [require('. /plugins/gradients')],
|
|
1138
|
+
},
|
|
1139
|
+
},
|
|
1126
1140
|
},
|
|
1127
1141
|
});
|
|
1128
1142
|
```
|
|
1129
1143
|
|
|
1130
|
-
##
|
|
1131
|
-
|
|
1132
|
-
除了 `screens`,`colors` 和 `spacing` 外,配置对象中的所有属性都映射到 `Tailwind CSS` 的核心插件上。由于许多插件负责仅接受静态值集(例如,例如`float`)的CSS属性,因此请注意,并非每个插件在主题对象中都有对应的属性。
|
|
1133
|
-
|
|
1134
|
-
所有这些属性也可以在 `designSystem.extend` 属性下使用,以扩展默认主题。
|
|
1135
|
-
|
|
1136
|
-
关于所有属性的作用,可以查看此 [链接](https://tailwindcss.com/docs/theme#configuration-reference)。
|
|
1137
|
-
|
|
1138
|
-
## 额外的配置
|
|
1139
|
-
|
|
1140
|
-
除了与 Tailwind CSS Theme 相同的配置以外,还有 Modern.js 提供的额外的配置。
|
|
1144
|
+
## Configuration references
|
|
1141
1145
|
|
|
1142
|
-
|
|
1146
|
+
All properties in the configuration object, except `screens`, `colors` and `spacing`, are mapped 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.
|
|
1143
1147
|
|
|
1144
|
-
|
|
1145
|
-
- default: `false`
|
|
1148
|
+
All of these properties can also be used under the `designSystem.extend` property to extend the default theme.
|
|
1146
1149
|
|
|
1147
|
-
|
|
1150
|
+
For more information about what all the properties do, check out this [link](https://tailwindcss.com/docs/theme#configuration-reference).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Plugins
|
|
6
|
+
|
|
7
|
+
This chapter describes the configuration of the registered module-tools plugin.
|
|
8
|
+
|
|
9
|
+
- type: `Array<ModuleToolsPlugin>`
|
|
10
|
+
|
|
11
|
+
```js modern.config.ts
|
|
12
|
+
import { ExamplePlugin } from '. /plugins/example';
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
plugins: [ExamplePlugin()],
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For more information on how to write plugins, check out the [[Plugin Writing Guide]](/en/plugins/guide/getting-started).
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 5
|
|
3
|
+
---
|
|
4
|
+
|
|
1
5
|
# Testing
|
|
2
6
|
|
|
7
|
+
This chapter describes the test-related configuration
|
|
3
8
|
:::tips
|
|
4
9
|
You need to enable the unit testing feature with `pnpm run new` first.
|
|
5
10
|
:::
|
|
6
11
|
|
|
7
|
-
|
|
8
12
|
## jest
|
|
9
|
-
* Type: `Object | Function`
|
|
10
|
-
* Default value: `{}`
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
- Type: `Object | Function`
|
|
15
|
+
- Default value: `{}`
|
|
16
|
+
|
|
17
|
+
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 .
|
|
18
|
+
|
|
19
|
+
```js modern.config.ts
|
|
20
|
+
import { defineConfig } from '@modern-js/module-tools';
|
|
13
21
|
|
|
14
|
-
```js title=modern.config.js
|
|
15
22
|
export default defineConfig({
|
|
16
23
|
testing: {
|
|
17
24
|
jest: {
|
|
18
|
-
testTimeout: 10000
|
|
19
|
-
}
|
|
20
|
-
}
|
|
25
|
+
testTimeout: 10000,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
21
28
|
});
|
|
22
29
|
```
|
|
23
30
|
|
|
24
|
-
When the value is of type
|
|
31
|
+
When the value is of type `Function`, the default configuration is passed as the first parameter and a new Jest configuration object needs to be returned.
|
|
32
|
+
|
|
33
|
+
```js modern.config.ts
|
|
34
|
+
import { defineConfig } from '@modern-js/module-tools';
|
|
25
35
|
|
|
26
|
-
```js title=modern.config.js
|
|
27
36
|
export default defineConfig({
|
|
28
37
|
testing: {
|
|
29
38
|
jest: options => {
|
|
@@ -38,8 +47,8 @@ export default defineConfig({
|
|
|
38
47
|
|
|
39
48
|
## transformer
|
|
40
49
|
|
|
41
|
-
-
|
|
42
|
-
- Default value: `babel-jest`
|
|
50
|
+
- type: `'babel-jest' | 'ts-jest'`
|
|
51
|
+
- Default value: `'babel-jest'`
|
|
43
52
|
|
|
44
53
|
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
54
|
|
package/docs/en/api/index.md
CHANGED