Skip to content

Commit 794a53f

Browse files
authored
docs: 补充快速上手和主题中的配置项的解释 (#3163)
* docs: 补充快速上手和主题中的配置项的解释 * docs: 补充官方主题的使用说明
1 parent 53f286c commit 794a53f

12 files changed

+65
-5
lines changed

src/sites/sites-react/doc/docs/react/official-theme-react.en-US.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ NutUI provides multiple sets of official `UI` themes by default, while allowing
1313

1414
## How to use
1515

16+
It is important to note that when configuring the theme, you also need to import the global class files in the entry file to load some global logic and styles for NutUI React:
17+
18+
| theme description | scss file name |
19+
| --- | --- |
20+
| JD APP Theme (Light Mode) | `@nutui/nutui-react/dist/styles/themes/default.css` |
21+
| JD APP Theme (Dark Mode) | `@nutui/nutui-react/dist/styles/themes/dark.css` |
22+
| JD JDesign Theme | `@nutui/nutui-react/dist/styles/themes/jmapp.css` |
23+
| JD JRKF Theme | `@nutui/nutui-react/dist/styles/themes/jrkf.css` |
24+
25+
Currently, only the default theme provides support for dark mode.
26+
1627
### Modify the configuration file of the local project vite or webpack
1728

1829
Modify the **sass-loader** configuration in the vite or webpack configuration file. The following example

src/sites/sites-react/doc/docs/react/official-theme-react.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ NutUI 默认提供多套官方`UI`主题,同时允许在一定程度上定制
1010
| --- | --- |
1111
| 京东 APP 主题(默认) | `variables.scss` |
1212
| 京东 JDesign 主题 ([预览](https://nutui.jd.com/h5/react/jdesign-3x/#/zh-CN/component/button)) | `variables-jmapp.scss` |
13+
| 京东 JRKF 主题 | `variables-jrkf.scss` |
14+
1315

1416
## 使用方式
1517

18+
需要注意的是,配置主题时,你还需要在入口文件中引入 global 类的文件来加载一些 NutUI React 的全局性逻辑和样式:
19+
20+
| 主题说明 | scss 文件名称 |
21+
| --- | --- |
22+
| 京东 APP 主题(明亮模式) | `@nutui/nutui-react/dist/styles/themes/default.css` |
23+
| 京东 APP 主题(暗黑模式) | `@nutui/nutui-react/dist/styles/themes/dark.css` |
24+
| 京东 JDesign 主题 | `@nutui/nutui-react/dist/styles/themes/jmapp.css` |
25+
| 京东 JRKF 主题 | `@nutui/nutui-react/dist/styles/themes/jrkf.css` |
26+
27+
目前只有默认主题提供了暗黑模式的支持。
28+
1629
### 修改本地项目 vite 或者 webpack 的配置文件
1730

1831
修改 vite 或者 webpack 配置文件中 **sass-loader** 的配置。如下示例

src/sites/sites-react/doc/docs/react/start-react.en-US.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ export default defineConfig({
9191
{
9292
libName: '@nutui/nutui-react',
9393
style: (name) => {
94+
// Handling on-demand import of CSS files, choose one of the two methods
9495
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
96+
// Handling on-demand import of SCSS files, choose one of the two methods
97+
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
9598
},
9699
replaceOldImport: false,
97100
camel2DashComponentName: false,
@@ -132,7 +135,7 @@ babel config:
132135
'import',
133136
{
134137
libraryName: '@nutui/nutui-react',
135-
style: 'css',
138+
style: 'css', // Here are the CSS files for on-demand import. If you need to import SCSS files, you can set the style to true.
136139
camel2DashComponentName: false,
137140
customName: (name, file) => {
138141
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}`

src/sites/sites-react/doc/docs/react/start-react.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ export default defineConfig({
9191
{
9292
libName: '@nutui/nutui-react',
9393
style: (name) => {
94+
// 按需引入 css 文件的处理,两种方式择其一
9495
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
96+
// 按需引入 scss 文件的处理,两种方式择其一
97+
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
9598
},
9699
replaceOldImport: false,
97100
camel2DashComponentName: false,
@@ -132,7 +135,7 @@ babel 配置:
132135
'import',
133136
{
134137
libraryName: '@nutui/nutui-react',
135-
style: 'css',
138+
style: 'css', // 这里是按需引入的 css 文件,如果需要引入 scss 文件,可将 style 设置为 true
136139
camel2DashComponentName: false,
137140
customName: (name, file) => {
138141
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}`

src/sites/sites-react/doc/docs/react/theme-react.en-US.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ We recommend replacing [CSS Vars] (https://developer.mozilla.org/zh-CN/docs/Web/
2323

2424
Create a new 'SCSS' file 'custom_theme.scss' in your local project.
2525

26+
**When customizing themes using SCSS files, you need to set the on-demand import to the SCSS file method. Refer to the description in the automatic on-demand loading configuration in the quick start guide.**
27+
2628
```scss
2729
// Dominant tone
2830
$color-primary: #fa2c19;

src/sites/sites-react/doc/docs/react/theme-react.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ NutUI-React 支持灵活的样式定制,满足多种视觉业务和品牌需
2020

2121
在本地项目中新建一个 `SCSS` 文件 `custom_theme.scss` 进行自定义。
2222

23+
**使用 SCSS 文件自定义主题时,需将按需引入设置为 scss 文件的方式,参考快速入手中的自动按需加载配置项中的描述**
24+
2325
```scss
2426
// 主色调
2527
$color-primary: #fa2c19;

src/sites/sites-react/doc/docs/taro/official-theme-react.en-US.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ NutUI provides multiple sets of official `UI` themes by default, while allowing
1313

1414
## How to use
1515

16+
It is important to note that when configuring the theme, you also need to import the global class files in the entry file to load some global logic and styles for NutUI React:
17+
18+
| theme description | scss file name |
19+
| --- | --- |
20+
| JD APP Theme (Light Mode) | `@nutui/nutui-react-taro/dist/styles/themes/default.css` |
21+
| JD APP Theme (Dark Mode) | `@nutui/nutui-react-taro/dist/styles/themes/dark.css` |
22+
| JD JDesign Theme | `@nutui/nutui-react-taro/dist/styles/themes/jmapp.css` |
23+
| JD JRKF Theme | `@nutui/nutui-react-taro/dist/styles/themes/jrkf.css` |
24+
25+
Currently, only the default theme provides support for dark mode.
26+
1627
### Modify the configuration file of the local project vite or webpack
1728

1829
Modify the **sass-loader** configuration in the vite or webpack configuration file. The following example

src/sites/sites-react/doc/docs/taro/official-theme-react.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ NutUI 默认提供多套官方`UI`主题,同时允许在一定程度上定制
1313

1414
## 使用方式
1515

16+
需要注意的是,配置主题时,你还需要在入口文件中引入 global 类的文件来加载一些 NutUI React 的全局性逻辑和样式:
17+
18+
| 主题说明 | scss 文件名称 |
19+
| --- | --- |
20+
| 京东 APP 主题(明亮模式) | `@nutui/nutui-react-taro/dist/styles/themes/default.css` |
21+
| 京东 APP 主题(暗黑模式) | `@nutui/nutui-react-taro/dist/styles/themes/dark.css` |
22+
| 京东 JDesign 主题 | `@nutui/nutui-react-taro/dist/styles/themes/jmapp.css` |
23+
| 京东 JRKF 主题 | `@nutui/nutui-react-taro/dist/styles/themes/jrkf.css` |
24+
25+
目前只有默认主题提供了暗黑模式的支持。
26+
1627
### 修改本地项目 vite 或者 webpack 的配置文件
1728

1829
修改 vite 或者 webpack 配置文件中 **sass-loader** 的配置。如下示例

src/sites/sites-react/doc/docs/taro/start-react.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ plugins: [
140140
'import',
141141
{
142142
libraryName: '@nutui/nutui-react-taro',
143-
style: 'css',
143+
style: 'css', // Here are the CSS files for on-demand import. If you need to import SCSS files, you can set the style to true.
144144
camel2DashComponentName: false,
145145
customName: (name, file) => {
146146
return `@nutui/nutui-react-taro/dist/es/packages/${name.toLowerCase()}`

src/sites/sites-react/doc/docs/taro/start-react.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module.exports = {
145145
'import',
146146
{
147147
libraryName: '@nutui/nutui-react-taro',
148-
style: 'css',
148+
style: 'css', // 这里是按需引入的 css 文件,如果需要引入 scss 文件,可将 style 设置为 true
149149
camel2DashComponentName: false,
150150
customName: (name, file) => {
151151
return `@nutui/nutui-react-taro/dist/es/packages/${name.toLowerCase()}`

0 commit comments

Comments
 (0)