From caebed3c5a7d92345e98f3a5603ff469c1984fc6 Mon Sep 17 00:00:00 2001 From: hanyuxinting Date: Tue, 18 Mar 2025 22:38:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85rem=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sites-react/doc/docs/react/start-react.en-US.md | 13 ++++++++++++- src/sites/sites-react/doc/docs/react/start-react.md | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/sites/sites-react/doc/docs/react/start-react.en-US.md b/src/sites/sites-react/doc/docs/react/start-react.en-US.md index 4922e31557..926bfe0585 100644 --- a/src/sites/sites-react/doc/docs/react/start-react.en-US.md +++ b/src/sites/sites-react/doc/docs/react/start-react.en-US.md @@ -151,7 +151,18 @@ babel config: ## Usage Notes - NutUI-React is built on top of [react@^18.0.0](https://www.npmjs.com/package/react) -- The CSS units used in the components are px. If your project requires rem units, you can use some tools for conversion, such as [webpack](https://www.webpackjs.com/) with the [px2rem-loader](https://www.npmjs.com/package/px2rem-loader), or the [postcss](https://github.com/postcss/postcss) plugin [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem). +- The CSS units used in the components are px. If your project requires rem units, you can use some tools for conversion, such as [webpack](https://www.webpackjs.com/) with the [px2rem-loader](https://www.npmjs.com/package/px2rem-loader), or the [postcss](https://github.com/postcss/postcss) plugin [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem). Be attention, when you want to change **px** to **rem**, you should set classnames about **NutUI** in the black list, e.g: + +``` +module.exports = { + plugins: { + 'postcss-pxtorem': { + propList: ['*'], + selectorBlackList: ['nut-'] // ignore items + } + } +} +``` ## Templates diff --git a/src/sites/sites-react/doc/docs/react/start-react.md b/src/sites/sites-react/doc/docs/react/start-react.md index b2963b6275..c795a1050d 100644 --- a/src/sites/sites-react/doc/docs/react/start-react.md +++ b/src/sites/sites-react/doc/docs/react/start-react.md @@ -151,7 +151,18 @@ babel 配置: ## 使用注意事项 - NutUI-React 基于 [react@^18.0.0](https://www.npmjs.com/package/react) 构建 -- 组件 CSS 单位使用的是 **px**,如果你的项目中需要 **rem** 单位,可借助一些工具进行转换,比如 [webpack](https://www.webpackjs.com/) 的 [px2rem-loader](https://www.npmjs.com/package/px2rem-loader)、[postcss](https://github.com/postcss/postcss) 的 [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem) 插件等 +- 组件 CSS 单位使用的是 **px**,如果你的项目中需要 **rem** 单位,可借助一些工具进行转换,比如 [webpack](https://www.webpackjs.com/) 的 [px2rem-loader](https://www.npmjs.com/package/px2rem-loader)、[postcss](https://github.com/postcss/postcss) 的 [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem) 插件等。需要注意的是,在转化 **rem** 时,对 **NutUI** 相关的样式设置在黑名单里,如: + +``` +module.exports = { + plugins: { + 'postcss-pxtorem': { + propList: ['*'], + selectorBlackList: ['nut-'] // 忽略类名 + } + } +} +``` ## 示例 From 4a6351529913c3b0f0fdd1d8f7aea5a172b7117d Mon Sep 17 00:00:00 2001 From: hanyuxinting Date: Wed, 19 Mar 2025 11:19:01 +0800 Subject: [PATCH 2/2] docs: taro --- .../doc/docs/react/start-react.en-US.md | 2 +- .../doc/docs/taro/start-react.en-US.md | 20 ++++++++++++++++++ .../sites-react/doc/docs/taro/start-react.md | 21 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/sites/sites-react/doc/docs/react/start-react.en-US.md b/src/sites/sites-react/doc/docs/react/start-react.en-US.md index 926bfe0585..30135e2260 100644 --- a/src/sites/sites-react/doc/docs/react/start-react.en-US.md +++ b/src/sites/sites-react/doc/docs/react/start-react.en-US.md @@ -151,7 +151,7 @@ babel config: ## Usage Notes - NutUI-React is built on top of [react@^18.0.0](https://www.npmjs.com/package/react) -- The CSS units used in the components are px. If your project requires rem units, you can use some tools for conversion, such as [webpack](https://www.webpackjs.com/) with the [px2rem-loader](https://www.npmjs.com/package/px2rem-loader), or the [postcss](https://github.com/postcss/postcss) plugin [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem). Be attention, when you want to change **px** to **rem**, you should set classnames about **NutUI** in the black list, e.g: +- The CSS units used in the components are px. If your project requires rem units, you can use some tools for conversion, such as [webpack](https://www.webpackjs.com/) with the [px2rem-loader](https://www.npmjs.com/package/px2rem-loader), or the [postcss](https://github.com/postcss/postcss) plugin [postcss-plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem). Be attention, when you want to change **px** to **rem**, you should set classnames about **NutUI** in the black list, such as: ``` module.exports = { diff --git a/src/sites/sites-react/doc/docs/taro/start-react.en-US.md b/src/sites/sites-react/doc/docs/taro/start-react.en-US.md index 48ea002314..b53a7becf6 100644 --- a/src/sites/sites-react/doc/docs/taro/start-react.en-US.md +++ b/src/sites/sites-react/doc/docs/taro/start-react.en-US.md @@ -193,3 +193,23 @@ config = { ``` ::: + +#### 4、CSS units + +The CSS units used in the components are px. However, during the Taro compilation, Taro will help you perform size conversion operations on styles. It is important to note that you should add styles related to NutUI to the blacklist, such as: + +:::demo + +```js +// config/index.js +config = { + postcss: { + pxtransform: { + enable: true, + config: { selectorBlackList: ['nut-'] }, + }, + }, +} +``` + +::: diff --git a/src/sites/sites-react/doc/docs/taro/start-react.md b/src/sites/sites-react/doc/docs/taro/start-react.md index 270b58ab3d..5e53fc3a2f 100644 --- a/src/sites/sites-react/doc/docs/taro/start-react.md +++ b/src/sites/sites-react/doc/docs/taro/start-react.md @@ -197,3 +197,24 @@ config = { ``` ::: + +#### 4、样式单位转化 + +组件 CSS 单位使用的是 **px**,但是在 `Taro` 编译时,Taro 会帮你对样式做尺寸转换操作,需要注意的是,要对 **NutUI** 相关的样式设置在黑名单里,如: + +:::demo + +```js +// config/index.js +config = { + postcss: { + pxtransform: { + enable: true, + // 包含 `nut-` 的类名选择器中的 px 单位不会被解析 + config: { selectorBlackList: ['nut-'] }, + }, + }, +} +``` + +:::