Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions src/sites/sites-react/doc/docs/react/start-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,26 @@

## Intro

Through this article, you can master the installation and use of NutUI React. The operation is simple and easy to use, and the development is simple and fast.
Through this article, you can master the installation and usage of NutUI React. The operation is simple and easy to get started, allowing for clean and fast development.

## Install

#### 1. Install via NPM
#### 1. Install via npm

```sh
#pnpm
# pnpm
pnpm add @nutui/nutui-react
#yarn
# yarn
yarn add @nutui/nutui-react
# npm
npm install @nutui/nutui-react
```

#### 2. Manual On-Demand Loading
## Component Usage

You can manually import individual components.
> NutUI React supports Tree Shaking by default, allowing for on-demand importing of component JS files without any plugin configuration. However, CSS style files cannot be included in this way, so from a styling perspective, there are two methods of usage:

```js
import '@nutui/nutui-react/dist/es/packages/button/style'
import Button from '@nutui/nutui-react/dist/es/packages/button'
```

Note that when manually loading components on demand, you also need to import the global class file in the entry file to load some of NutUI React's global logic and styles:

```js
import '@nutui/nutui-react/dist/styles/themes/default.scss'
```

If you find the above method cumbersome, you can use the automatic on-demand loading provided by Method 3. However, when using automatic on-demand loading, you still need to import the global class file.

## Component usage

> NutUI React supports Tree Shaking by default, and supports on-demand import of component JS files without any plug-in configuration. However, css style files cannot be implemented in this way, so from the perspective of style, it can be divided into the following two usage methods:

#### Method 1, Conventional usage: Full import of styles
#### Method 1: Regular Usage - Full Import of Styles

:::demo

Expand All @@ -58,17 +41,34 @@ ReactDOM.render(

:::

#### Method 2, import styles on demand
#### Method 2: Manual On-Demand Loading

You can manually import specific components.

```js
import '@nutui/nutui-react/dist/es/packages/button/style'
import Button from '@nutui/nutui-react/dist/es/packages/button'
```

It is important to note that when manually loading components on demand, you also need to import the global class file in your entry file to load some of NutUI React's global logic and styles:

```js
import '@nutui/nutui-react/dist/styles/themes/default.scss'
```

#### Method 3: Automatic On-Demand Loading

If you find the above methods cumbersome, you can use Method 3, which provides automatic on-demand loading. However, when using automatic on-demand loading, you still need to import the global class file.

<details>
<summary>vite</summary>

Install the `vite-plugin-imp` plugin and configure it.
Install the vite-plugin-imp plugin and configure it.

```sh
#pnpm
# pnpm
pnpm add vite-plugin-imp -D
#yarn
# yarn
yarn add vite-plugin-imp -D
# npm
npm install vite-plugin-imp -D
Expand Down Expand Up @@ -104,29 +104,29 @@ export default defineConfig({

:::

</details><br/>
</details><br />

<details>
<summary>webpack</summary>

Install the `babel-plugin-import` plugin and configure it.
Install the babel-plugin-import plugin and configure it.

```sh
#pnpm
# pnpm
pnpm add babel-plugin-import -D
#yarn
# yarn
yarn add babel-plugin-import -D
# npm
npm install babel-plugin-import -D
```

Babel configuration:
babel config:

:::demo

```js
{
//...
// ...
plugins: [
[
'import',
Expand All @@ -146,15 +146,15 @@ Babel configuration:

:::

</details><br/>
</details><br />

## Precautions for use
## Usage Notes

- NutUI-React is built on [react@^18.0.0](https://www.npmjs.com/package/react)
- The component CSS unit uses **px**, if you need **rem** unit in your project, you can convert it with some tools, such as [px2rem-loader](https://www.npmjs.com/package/px2rem-loader) of [webpack](https://www.webpackjs.com/), [postcss] of [postcss](https://github.com/postcss/postcss) -plugin-px2rem](https://www.npmjs.com/package/postcss-plugin-px2rem) plugin etc.
- 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).

## Examples
## Templates

Source code for all the examples can be found in the [packages/templates](https://github.com/jdf2e/nutui-react/tree/next/packages/nutui-templates) directory.
The example code can be found in the [packages/templates](https://github.com/jdf2e/nutui-react/tree/next/packages/nutui-templates) directory.

<content-examples/>
4 changes: 2 additions & 2 deletions src/sites/sites-react/doc/docs/react/start-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ import Button from '@nutui/nutui-react/dist/es/packages/button'
import '@nutui/nutui-react/dist/styles/themes/default.scss'
```

如果你认为上面的写法比较繁琐,你可以使用方法三提供的自动按需加载,`但是使用自动按需加载时扔需引入 global 类的文件`。

#### 方法三、自动的按需加载

如果你认为上面的写法比较繁琐,你可以使用方法三提供的自动按需加载,**但是使用自动按需加载时扔需引入 global 类的文件**。

<details>
<summary>vite</summary>

Expand Down