@@ -183,7 +184,7 @@ const ButtonDemo = () => {
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -192,7 +193,7 @@ const ButtonDemo = () => {
fill="outline"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -201,7 +202,7 @@ const ButtonDemo = () => {
fill="dashed"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -258,19 +259,19 @@ const ButtonDemo = () => {
fill="outline"
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
@@ -290,7 +291,7 @@ const ButtonDemo = () => {
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -300,7 +301,7 @@ const ButtonDemo = () => {
fill="outline"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -310,16 +311,16 @@ const ButtonDemo = () => {
fill="dashed"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- {translated['60a53514']}
+ {translated['7db1a8b2']}
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -367,20 +368,20 @@ const ButtonDemo = () => {
fill="outline"
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
diff --git a/src/packages/button/demo.tsx b/src/packages/button/demo.tsx
index 01f4d4030e..7f8da87c2d 100644
--- a/src/packages/button/demo.tsx
+++ b/src/packages/button/demo.tsx
@@ -99,7 +99,7 @@ const ButtonDemo = () => {
'8dab2f66': 'Danger Button',
cfbdc781: 'Warning button',
c3a3a1d2: 'Success Button',
- e51e4582: 'Fill',
+ e51e4582: 'Fill Button',
'7db1a8b2': 'Disabled State',
a52bef0c: 'Load State',
d04fcbda: 'Loading',
@@ -117,54 +117,43 @@ const ButtonDemo = () => {
},
})
+ const marginStyle = { margin: 8 }
const [loading, setLoading] = useState(false)
return (
<>
{translated.ce5c5446}
-
+
{translated.c38a08ef}
-
+
{translated.b840c88f}
-
- {translated.a74a1fd4}
-
-
+ {translated.a74a1fd4}
+
{translated['8dab2f66']}
-
+
{translated.cfbdc781}
-
+
{translated.c3a3a1d2}
|
{translated.e51e4582}
-
+
Solid
-
+
Outline
-
+
Dashed
-
+
None
|
@@ -175,7 +164,7 @@ const ButtonDemo = () => {
type="primary"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -184,7 +173,7 @@ const ButtonDemo = () => {
fill="outline"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -193,7 +182,7 @@ const ButtonDemo = () => {
fill="dashed"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -239,9 +228,7 @@ const ButtonDemo = () => {
type="default"
icon={
}
rightIcon={
}
- style={{
- margin: 8,
- }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -250,27 +237,26 @@ const ButtonDemo = () => {
fill="outline"
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -283,7 +269,7 @@ const ButtonDemo = () => {
type="primary"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -293,7 +279,7 @@ const ButtonDemo = () => {
fill="outline"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -303,7 +289,7 @@ const ButtonDemo = () => {
fill="dashed"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['60a53514']}
@@ -312,7 +298,7 @@ const ButtonDemo = () => {
fill="solid"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -348,9 +334,7 @@ const ButtonDemo = () => {
disabled
icon={
}
rightIcon={
}
- style={{
- margin: 8,
- }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
@@ -360,55 +344,44 @@ const ButtonDemo = () => {
fill="outline"
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
{translated['7db1a8b2']}
{translated.ce5c5447}
-
+
{translated.b840c881}
-
+
{translated.b840c882}
|
{translated.a52bef0c}
-
+
{translated.d04fcbda}
{
}, 1500)
setLoading(!loading)
}}
- style={{ margin: 8 }}
+ style={marginStyle}
>
Click me!
@@ -431,14 +404,14 @@ const ButtonDemo = () => {
{translated.b8a453e3}
-
+
{translated['248be9e1']}
- {translated['248be9e1']}
-
+ {translated['248be9e1']}
+
{translated.ea3d02f2}
-
+
{translated.ea379d01}
|
diff --git a/src/packages/button/doc.en-US.md b/src/packages/button/doc.en-US.md
index 2aaa27010a..bfafdad2f1 100644
--- a/src/packages/button/doc.en-US.md
+++ b/src/packages/button/doc.en-US.md
@@ -12,7 +12,7 @@ import { Button } from '@nutui/nutui-react';
## Demo
-### The button type
+### Button type
The button supports six types: 'default', 'primary', 'info', 'warning', 'danger', 'success', which defaults to 'default'.
@@ -23,14 +23,15 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
primary
-
info
-
default
-
danger
-
warning
-
success
+
primary
+
info
+
default
+
danger
+
warning
+
success
>
);
};
@@ -39,7 +40,7 @@ export default App;
:::
-### Fill button
+### Fill Button
The button supports four types: 'solid', 'outline', 'dashed', 'none', which defaults to 'solid'.
@@ -50,11 +51,13 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
Solid
-
Outline
-
None
+
Solid
+
Outline
+
Dashed
+
None
>
);
};
@@ -63,21 +66,121 @@ export default App;
:::
-### Disabled state
+### Icon button
-Disable the button through the 'disabled' attribute, which is not clickable.
+Set the button icon through the 'icon' property, and provide the 'rightIcon' property to display the icon on the right side.
:::demo
```tsx
import React from "react";
import { Button } from '@nutui/nutui-react';
+import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
primary
-
primary
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-color-primary-light)`,
+ borderColor: `var(--nutui-color-primary)`,
+ color: `var(--nutui-color-primary)`,
+ }}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-3)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-1)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ Operation Button
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Operation Button
+
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Operation Button
+
>
);
};
@@ -86,20 +189,126 @@ export default App;
:::
-### Button shape
+### Disabled state
-Set the button shape through the 'shape' property, support circular, square buttons, and default to circle.
+Disable the button through the 'disabled' attribute, which is not clickable.
:::demo
```tsx
import React from "react";
import { Button } from '@nutui/nutui-react';
+import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
square
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-3)`,
+ color: `var(--nutui-gray-5)`,
+ }}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-1)`,
+ color: `var(--nutui-gray-5)`,
+ }}
+ >
+ Disabled State
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ Disabled State
+
>
);
};
@@ -108,32 +317,24 @@ export default App;
:::
-### Load state
+### Button shape
+
+Set the button shape through the 'shape' property, support circular, square buttons, and default to circle.
:::demo
```tsx
-import React, { useState } from "react";
+import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
- const [loading, setLoading] = useState(false)
+ const marginStyle = { margin: 8 }
return (
<>
-
Loading...
-
{
- setTimeout(() => {
- setLoading(false)
- }, 1500);
- setLoading(!loading)
- }}
- style={{ margin: 8 }}
- >
- Click me!
+
+ square
+ round
>
);
};
@@ -142,65 +343,34 @@ export default App;
:::
-### Icon button
-
-Set the button icon through the 'icon' property, and provide the 'rightIcon' property to display the icon on the right side.
+### Load state
:::demo
```tsx
-import React from "react";
+import React, { useState } from "react";
import { Button } from '@nutui/nutui-react';
-import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const [loading, setLoading] = useState(false)
+ const marginStyle = { margin: 8 }
return (
<>
- }
- rightIcon={ }
- style={{ margin: 8 }}
- >
- 操作按钮
+
+ Loading
}
- rightIcon={ }
- style={{ margin: 8 }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-color-primary-light)`,
- borderColor: `var(--nutui-color-primary)`,
- color: `var(--nutui-color-primary)`,
+ loading={loading}
+ type="success"
+ onClick={() => {
+ setTimeout(() => {
+ setLoading(false)
+ }, 1500)
+ setLoading(!loading)
}}
+ style={marginStyle}
>
- 操作按钮
-
-
}
- style={{ margin: 8 }}
- />
-
}
- rightIcon={
}
- style={{ margin: 8 }}
- >
- 操作按钮
+ Click me!
>
);
@@ -212,7 +382,7 @@ export default App;
### Button size
-Support 'large', 'normal', 'small' three sizes, the default is 'normal'.
+Support 'large', 'normal', 'small', 'mini' four sizes, the default is 'normal'.
:::demo
@@ -221,12 +391,18 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
Large
-
Normal
-
Small
-
Mini
+
Large Button
+
Normal Button
+
Normal Button
+
+ Small Button
+
+
+ Mini Button
+
>
);
};
@@ -235,7 +411,7 @@ export default App;
:::
-### Block
+### Block-level elements
Buttons are inline block-level elements by default, and the 'block' attribute allows you to set the element type of the button to a block-level element, which is commonly used to implement banner buttons.
@@ -248,7 +424,7 @@ import { Button } from '@nutui/nutui-react';
const App = () => {
return (
<>
-
Block
+
Block-level elements
>
);
};
@@ -268,6 +444,7 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
) => void` | `-` |
## Theming
diff --git a/src/packages/button/doc.md b/src/packages/button/doc.md
index b2736903a3..12584b102d 100644
--- a/src/packages/button/doc.md
+++ b/src/packages/button/doc.md
@@ -23,14 +23,15 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- 主要按钮
- 信息按钮
- 默认按钮
- 危险按钮
- 警告按钮
- 成功按钮
+ 主要按钮
+ 信息按钮
+ 默认按钮
+ 危险按钮
+ 警告按钮
+ 成功按钮
>
);
};
@@ -50,11 +51,13 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- Solid
- Outline
- None
+ Solid
+ Outline
+ Dashed
+ None
>
);
};
@@ -75,90 +78,109 @@ import { Button } from '@nutui/nutui-react';
import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
}
- rightIcon={ }
- style={{ margin: 8 }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{ margin: 8 }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-color-primary-light)`,
- borderColor: `var(--nutui-color-primary)`,
- color: `var(--nutui-color-primary)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-gray-3)`,
- color: `var(--nutui-gray-7)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-gray-1)`,
- color: `var(--nutui-gray-7)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- }}
- >
- 操作按钮
-
-
}
- style={{ margin: 8 }}
- />
-
}
- rightIcon={
}
- style={{ margin: 8 }}
- >
- 操作按钮
-
+ type="primary"
+ icon={
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-color-primary-light)`,
+ borderColor: `var(--nutui-color-primary)`,
+ color: `var(--nutui-color-primary)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-3)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-1)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
>
);
};
@@ -179,6 +201,7 @@ import { Button } from '@nutui/nutui-react';
import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
{
type="primary"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
{
fill="outline"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 禁用状态
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按钮
+ 禁用状态
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按钮
+ 禁用状态
}
rightIcon={
}
- style={{
- margin: 8,
- }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
+ style={marginStyle}
+ />
+
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
>
);
@@ -289,9 +328,13 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
方形按钮
+
+ 方形按钮
+
+
圆形按钮
>
);
};
@@ -310,19 +353,22 @@ import { Button } from '@nutui/nutui-react';
const App = () => {
const [loading, setLoading] = useState(false)
+ const marginStyle = { margin: 8 }
return (
<>
-
加载中...
+
+ 加载中
+
{
setTimeout(() => {
setLoading(false)
- }, 1500);
+ }, 1500)
setLoading(!loading)
}}
- style={{ margin: 8 }}
+ style={marginStyle}
>
Click me!
@@ -334,10 +380,9 @@ export default App;
:::
-
### 按钮尺寸
-支持 `large`、`normal`、`small` 三种尺寸,默认为 `normal`。
+支持 `large`、`normal`、`small`、`mini` 四种尺寸,默认为 `normal`。
:::demo
@@ -346,12 +391,18 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
大号按钮
-
普通按钮
-
小型按钮
-
迷你按钮
+
普通按钮
+
普通按钮
+
+ 小型按钮
+
+
+ 迷你按钮
+
>
);
};
@@ -393,6 +444,7 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
) => void` | `-` |
## 主题定制
diff --git a/src/packages/button/doc.taro.md b/src/packages/button/doc.taro.md
index 10e86767d8..3d1381f0a9 100644
--- a/src/packages/button/doc.taro.md
+++ b/src/packages/button/doc.taro.md
@@ -21,10 +21,11 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- 分享给好友
- 打开授权设置页
+ 分享给好友
+ 打开授权设置页
>
);
};
@@ -44,14 +45,15 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- 主要按钮
- 信息按钮
- 默认按钮
- 危险按钮
- 警告按钮
- 成功按钮
+ 主要按钮
+ 信息按钮
+ 默认按钮
+ 危险按钮
+ 警告按钮
+ 成功按钮
>
);
};
@@ -71,11 +73,17 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- Solid
- Outline
- None
+ Solid
+
+ Outline
+
+
+ Dashed
+
+ None
>
);
};
@@ -96,90 +104,112 @@ import { Button } from '@nutui/nutui-react-taro';
import { Star, Plus } from '@nutui/icons-react-taro'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
}
- rightIcon={ }
- style={{ margin: 8 }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{ margin: 8 }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-color-primary-light)`,
- borderColor: `var(--nutui-color-primary)`,
- color: `var(--nutui-color-primary)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-gray-3)`,
- color: `var(--nutui-gray-7)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- backgroundColor: `var(--nutui-gray-1)`,
- color: `var(--nutui-gray-7)`,
- }}
- >
- 操作按钮
-
-
}
- rightIcon={
}
- style={{
- margin: 8,
- }}
- >
- 操作按钮
-
-
}
- style={{ margin: 8 }}
- />
-
}
- rightIcon={
}
- style={{ margin: 8 }}
- >
- 操作按钮
-
+ type="primary"
+ icon={
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-color-primary-light)`,
+ borderColor: `var(--nutui-color-primary)`,
+ color: `var(--nutui-color-primary)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-3)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ backgroundColor: `var(--nutui-gray-1)`,
+ color: `var(--nutui-gray-7)`,
+ }}
+ >
+ 操作按钮
+
+
}
+ rightIcon={
}
+ style={{
+ margin: 8,
+ }}
+ >
+ 操作按钮
+
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 操作按钮
+
>
);
};
@@ -200,6 +230,7 @@ import { Button } from '@nutui/nutui-react-taro';
import { Star, Plus } from '@nutui/icons-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
{
type="primary"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
{
fill="outline"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
+ >
+ 禁用状态
+
+
}
+ rightIcon={
}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按钮
+ 禁用状态
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按钮
+ 禁用状态
{
margin: 8,
}}
>
- 操作按钮
+ 禁用状态
}
- style={{ margin: 8 }}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按钮
+ 禁用状态
>
);
@@ -310,9 +360,11 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
方形按钮
+
方形按钮
+
圆形按钮
>
);
};
@@ -331,9 +383,10 @@ import { Button } from '@nutui/nutui-react-taro';
const App = () => {
const [loading, setLoading] = useState(false)
+ const marginStyle = { margin: 8 }
return (
<>
-
加载中...
+
加载中
{
}, 1500);
setLoading(!loading)
}}
- style={{ margin: 8 }}
+ style={marginStyle}
>
Click me!
@@ -358,7 +411,7 @@ export default App;
### 按钮尺寸
-支持 `large`、`normal`、`small` 三种尺寸,默认为 `normal`。
+支持 `large`、`normal`、`small`、`mini` 四种尺寸,默认为 `normal`。
:::demo
@@ -367,12 +420,14 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
大号按钮
-
普通按钮
-
小型按钮
-
迷你按钮
+
普通按钮
+
普通按钮
+
小型按钮
+
迷你按钮
>
);
};
@@ -414,6 +469,7 @@ import React from "react";
import { Button } from '@nutui/nutui-react-taro';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
) => void` | `-` |
### 支持小程序API能力
diff --git a/src/packages/button/doc.zh-TW.md b/src/packages/button/doc.zh-TW.md
index 339d5cd5fc..5f23298347 100644
--- a/src/packages/button/doc.zh-TW.md
+++ b/src/packages/button/doc.zh-TW.md
@@ -23,14 +23,15 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- 主要按鈕
- 信息按鈕
- 默認按鈕
- 危險按鈕
- 警告按鈕
- 成功按鈕
+ 主要按鈕
+ 信息按鈕
+ 默认按鈕
+ 危险按鈕
+ 警告按鈕
+ 成功按鈕
>
);
};
@@ -50,11 +51,13 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
- Solid
- Outline
- None
+ Solid
+ Outline
+ Dashed
+ None
>
);
};
@@ -75,13 +78,14 @@ import { Button } from '@nutui/nutui-react';
import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
}
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
操作按鈕
@@ -90,7 +94,16 @@ const App = () => {
fill="outline"
icon={
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
+ >
+ 操作按鈕
+
+
}
+ rightIcon={
}
+ style={marginStyle}
>
操作按鈕
@@ -136,9 +149,7 @@ const App = () => {
type="default"
icon={
}
rightIcon={
}
- style={{
- margin: 8,
- }}
+ style={marginStyle}
>
操作按鈕
@@ -147,15 +158,26 @@ const App = () => {
fill="outline"
type="primary"
icon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
+ />
+
}
+ style={marginStyle}
/>
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
操作按鈕
@@ -179,6 +201,7 @@ import { Button } from '@nutui/nutui-react';
import { Star, Plus } from '@nutui/icons-react'
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
{
type="primary"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按鈕
+ 禁用狀態
{
fill="outline"
icon={ }
rightIcon={ }
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按鈕
+ 禁用狀態
+
+
}
+ rightIcon={
}
+ style={marginStyle}
+ >
+ 禁用狀態
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按鈕
+ 禁用狀態
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按鈕
+ 禁用狀態
{
color: `var(--nutui-gray-5)`,
}}
>
- 操作按鈕
+ 禁用狀態
}
rightIcon={
}
- style={{
- margin: 8,
- }}
+ style={marginStyle}
>
- 操作按鈕
+ 禁用狀態
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
- style={{ margin: 8 }}
+ style={marginStyle}
/>
}
+ style={marginStyle}
+ />
+
}
rightIcon={
}
- style={{ margin: 8 }}
+ style={marginStyle}
>
- 操作按鈕
+ 禁用狀態
>
);
@@ -289,9 +328,13 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
-
方形按鈕
+
+ 方形按鈕
+
+
圆形按鈕
>
);
};
@@ -310,19 +353,22 @@ import { Button } from '@nutui/nutui-react';
const App = () => {
const [loading, setLoading] = useState(false)
+ const marginStyle = { margin: 8 }
return (
<>
-
加載中...
+
+ 載入中
+
{
setTimeout(() => {
setLoading(false)
- }, 1500);
+ }, 1500)
setLoading(!loading)
}}
- style={{ margin: 8 }}
+ style={marginStyle}
>
Click me!
@@ -334,7 +380,6 @@ export default App;
:::
-
### 按鈕尺寸
支持 `large`、`normal`、`small` 三種尺寸,默認為 `normal`。
@@ -346,12 +391,18 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
大號按鈕
-
普通按鈕
-
小型按鈕
-
迷你按鈕
+
普通按鈕
+
普通按鈕
+
+ 小型按鈕
+
+
+ 迷你按鈕
+
>
);
};
@@ -373,7 +424,7 @@ import { Button } from '@nutui/nutui-react';
const App = () => {
return (
<>
-
塊級元素
+
块级元素
>
);
};
@@ -393,6 +444,7 @@ import React from "react";
import { Button } from '@nutui/nutui-react';
const App = () => {
+ const marginStyle = { margin: 8 }
return (
<>
) => void` | `-` |
## 主題定製
From 837810d7073f8c57fe47d0b4156285f010400978 Mon Sep 17 00:00:00 2001
From: "Alex.huxiyang" <99181718+Alexx12321@users.noreply.github.com>
Date: Fri, 19 Jan 2024 13:47:41 +0800
Subject: [PATCH 048/275] =?UTF-8?q?fix(cell):=20doc=E3=80=81demo=E4=B8=80?=
=?UTF-8?q?=E8=87=B4=E5=8C=96=E6=94=B9=E8=BF=9B=20(#1877)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: 文档demo一致化
* fix: 去除冗余
* fix: taro文档修正
* fix: 繁体字文档修正
---
src/packages/cell/demo.tsx | 7 ++++++-
src/packages/cell/doc.en-US.md | 2 +-
src/packages/cell/doc.md | 2 +-
src/packages/cell/doc.taro.md | 4 ++--
src/packages/cell/doc.zh-TW.md | 2 +-
5 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/packages/cell/demo.tsx b/src/packages/cell/demo.tsx
index ff1b701eb2..57ce5df241 100644
--- a/src/packages/cell/demo.tsx
+++ b/src/packages/cell/demo.tsx
@@ -125,7 +125,6 @@ const CellDemo = () => {
{translated.content}
|
-
{translated.title6}
{
{translated.title5}
{
>
}
align="center"
+ onClick={(
+ event: React.MouseEvent
+ ) => {
+ onJumpclick(event, 'https://jd.com')
+ }}
/>
diff --git a/src/packages/cell/doc.en-US.md b/src/packages/cell/doc.en-US.md
index e30d7f0a7d..1f05ad3f31 100644
--- a/src/packages/cell/doc.en-US.md
+++ b/src/packages/cell/doc.en-US.md
@@ -129,7 +129,7 @@ import { Cell } from '@nutui/nutui-react'
const App = () => {
return (
- |
+ |
)
}
export default App
diff --git a/src/packages/cell/doc.md b/src/packages/cell/doc.md
index b6556647d3..7a18ea1c2a 100644
--- a/src/packages/cell/doc.md
+++ b/src/packages/cell/doc.md
@@ -80,7 +80,7 @@ const App = () => {
title={
- 我是标题{translated.title}
+ 我是标题
}
description={
diff --git a/src/packages/cell/doc.taro.md b/src/packages/cell/doc.taro.md
index 700810a72e..31cddb0982 100644
--- a/src/packages/cell/doc.taro.md
+++ b/src/packages/cell/doc.taro.md
@@ -80,7 +80,7 @@ const App = () => {
title={
- 我是标题{translated.title}
+ 我是标题
}
description={
@@ -185,7 +185,7 @@ const App = () => {
align="center"
onClick={(
event: React.MouseEvent
- ) => onJumpclick(event, '/pages/index/index')}
+ ) => { onJumpclick(event, '/pages/index/index') }}
/>
diff --git a/src/packages/cell/doc.zh-TW.md b/src/packages/cell/doc.zh-TW.md
index 310037a1df..fb13e4822f 100644
--- a/src/packages/cell/doc.zh-TW.md
+++ b/src/packages/cell/doc.zh-TW.md
@@ -80,7 +80,7 @@ const App = () => {
title={
- 我是標題{translated.title}
+ 我是標題
}
description={
From 7233e619870870b91e1e85de4c4e17d78e83c158 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 19 Jan 2024 14:10:39 +0800
Subject: [PATCH 049/275] chore(deps): update dependency postcss-import to v16
(#1845)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
package.json | 2 +-
pnpm-lock.yaml | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/package.json b/package.json
index fd25606e42..e849b83cd4 100644
--- a/package.json
+++ b/package.json
@@ -173,7 +173,7 @@
"mobx": "^6.9.0",
"mobx-react-lite": "^4.0.0",
"postcss": "^8.4.21",
- "postcss-import": "^15.0.0",
+ "postcss-import": "^16.0.0",
"postcss-modules": "^6.0.0",
"postcss-rtlcss": "^5.1.0",
"prettier": "^3.0.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1afce6a7e0..ee776a2de1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -248,8 +248,8 @@ importers:
specifier: ^8.4.21
version: 8.4.32
postcss-import:
- specifier: ^15.0.0
- version: 15.1.0(postcss@8.4.32)
+ specifier: ^16.0.0
+ version: 16.0.0(postcss@8.4.32)
postcss-modules:
specifier: ^6.0.0
version: 6.0.0(postcss@8.4.32)
@@ -14393,9 +14393,9 @@ packages:
resolve: 1.22.8
dev: true
- /postcss-import@15.1.0(postcss@8.4.32):
- resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==}
- engines: {node: '>=14.0.0'}
+ /postcss-import@16.0.0(postcss@8.4.32):
+ resolution: {integrity: sha512-e77lhVvrD1I2y7dYmBv0k9ULTdArgEYZt97T4w6sFIU5uxIHvDFQlKgUUyY7v7Barj0Yf/zm5A4OquZN7jKm5Q==}
+ engines: {node: '>=18.0.0'}
peerDependencies:
postcss: ^8.0.0
dependencies:
From 585c120f9f8a9f8205f0af386abe4490a652df63 Mon Sep 17 00:00:00 2001
From: oasis <12181600+oasis-cloud@users.noreply.github.com>
Date: Fri, 19 Jan 2024 16:12:23 +0800
Subject: [PATCH 050/275] =?UTF-8?q?fix(popover):=20=E7=BD=AE=E4=BA=8E?=
=?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=AE=B9=E5=99=A8=E4=B8=AD=EF=BC=8Cpopover?=
=?UTF-8?q?=20=E9=9C=80=E8=A6=81=E8=B7=9F=E9=9A=8F=E6=BB=9A=E5=8A=A8?=
=?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=80=89=E4=B8=AD=E9=A1=B9=E7=9A=84?=
=?UTF-8?q?=E6=A0=B7=E5=BC=8F=20(#1869)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(popover): 置于滚动容器中,popover 需要跟随滚动,修复选中项的样式
* fix(popover): 置于滚动容器中,popover 需要跟随滚动,修复选中项的样式
* test: 修复单测的报错
* fix: useMemo
* fix: useMemo 导致无法获取position
* fix: fixed 定位支持
* fix: fixed 定位支持
* fix: 单元测试和文档
* fix: 由于popover插入到body,所以控制样式方式要通过自定义 className。之前popover是 div.demo 的子元素,现在 popover 是 body 的子元素
* fix: 挪动到右侧
* fix: 单测
* fix: 单测
* fix: 文案
---
.../popover/__tests__/popover.spec.tsx | 58 ++++-
src/packages/popover/demo.scss | 6 +-
src/packages/popover/demo.tsx | 94 +++++++-
src/packages/popover/doc.en-US.md | 120 ++++++++++
src/packages/popover/doc.md | 120 ++++++++++
src/packages/popover/doc.zh-TW.md | 120 ++++++++++
src/packages/popover/popover.scss | 2 +-
src/packages/popover/popover.tsx | 212 +++++++++---------
src/packages/tour/__test__/tour.spec.tsx | 14 +-
src/utils/get-scroll-parent.ts | 27 +++
10 files changed, 642 insertions(+), 131 deletions(-)
diff --git a/src/packages/popover/__tests__/popover.spec.tsx b/src/packages/popover/__tests__/popover.spec.tsx
index 1ad9bf5988..21e8da7f39 100644
--- a/src/packages/popover/__tests__/popover.spec.tsx
+++ b/src/packages/popover/__tests__/popover.spec.tsx
@@ -44,7 +44,7 @@ test('render popover content', async () => {
| |
)
- const content = container.querySelectorAll('.nut-popover-content')[0]
+ const content = document.querySelectorAll('.nut-popover-content')[0]
expect(content.className).toContain(
'nut-popup-default nut-popover-content nut-popover-content-bottom'
)
@@ -58,7 +58,7 @@ test('render popover position', async () => {
)
- const content = container.querySelectorAll('.nut-popover-content')[0]
+ const content = document.querySelectorAll('.nut-popover-content')[0]
expect(content.className).toContain(
'nut-popup-default nut-popover-content nut-popover-content-bottom-start'
)
@@ -72,7 +72,7 @@ test('render popover position2', async () => {
)
- const content = container.querySelectorAll(
+ const content = document.querySelectorAll(
'.nut-popover-arrow'
)[0] as HTMLElement
expect(content).toHaveAttribute('style', 'left: 36px;')
@@ -86,7 +86,7 @@ test('render popover position22', async () => {
)
- const content = container.querySelectorAll(
+ const content = document.querySelectorAll(
'.nut-popover-arrow'
)[0] as HTMLElement
expect(content).toHaveAttribute('style', 'left: calc(50% + 20px);')
@@ -100,7 +100,7 @@ test('render popover position3', async () => {
)
- const content = container.querySelectorAll(
+ const content = document.querySelectorAll(
'.nut-popover-arrow'
)[0] as HTMLElement
expect(content).toHaveAttribute('style', 'top: -4px;')
@@ -114,12 +114,54 @@ test('render popover position33', async () => {
)
- const content = container.querySelectorAll(
+ const content = document.querySelectorAll(
'.nut-popover-arrow'
)[0] as HTMLElement
expect(content).toHaveAttribute('style', 'top: calc(50% - 20px);')
})
+test('render position fixed ', async () => {
+ const close = jest.fn()
+ const click = jest.fn()
+ const { container, getByTestId } = render(
+
+
+
+
+ position: fixed
+
+
+
+ )
+ const item = document.querySelectorAll('.nut-popover-menu-item-name')
+ fireEvent.click(item[0])
+ expect(click).toBeCalled()
+ expect(close).toBeCalled()
+ fireEvent.click(getByTestId('a'))
+ await waitFor(() => {
+ fireEvent.scroll(getByTestId('aa'), { target: { scrollTop: 10 } })
+
+ const item1 = document.querySelectorAll('.nut-popover-menu-item-name')
+ expect(item1.length).toBe(3)
+ })
+})
+
test('should emit onchoose event when clicking the action', async () => {
const choose = jest.fn()
const { container } = render(
@@ -129,7 +171,7 @@ test('should emit onchoose event when clicking the action', async () => {
)
- const contentItem = container.querySelectorAll('.nut-popover-menu-item')[0]
+ const contentItem = document.querySelectorAll('.nut-popover-menu-item')[0]
fireEvent.click(contentItem)
await waitFor(() => expect(choose.mock.calls[0][0].name).toEqual('option1'))
await waitFor(() => expect(choose.mock.calls[0][1]).toBe(0))
@@ -144,7 +186,7 @@ test('should not emit select event when the action is disabled', async () => {
)
- const contentItem = container.querySelectorAll('.nut-popover-menu-item')[0]
+ const contentItem = document.querySelectorAll('.nut-popover-menu-item')[0]
fireEvent.click(contentItem)
await waitFor(() => expect(choose).not.toBeCalled())
diff --git a/src/packages/popover/demo.scss b/src/packages/popover/demo.scss
index ff72ff27aa..5d5f654f4c 100644
--- a/src/packages/popover/demo.scss
+++ b/src/packages/popover/demo.scss
@@ -1,7 +1,5 @@
-.demo {
- .nut-popover-content {
- width: 120px;
- }
+.demo-popover .nut-popover-content {
+ width: 120px;
}
.customClass {
diff --git a/src/packages/popover/demo.tsx b/src/packages/popover/demo.tsx
index 0f69ba242d..ddd6763311 100644
--- a/src/packages/popover/demo.tsx
+++ b/src/packages/popover/demo.tsx
@@ -17,6 +17,7 @@ import './demo.scss'
interface T {
[props: string]: string
}
+
interface List {
key?: string
name: string
@@ -47,6 +48,8 @@ const PopoverDemo = () => {
content: '自定义内容',
contentColor: '自定义颜色',
showMoreDirection: '点击查看更多方向',
+ scroll: '置于可滚动容器中',
+ fixed: '容器设置 position: fixed',
},
'en-US': {
title: 'Basic Usage',
@@ -60,6 +63,8 @@ const PopoverDemo = () => {
content: 'Custom Content',
contentColor: 'Custom Color',
showMoreDirection: 'click show more direction',
+ scroll: 'In scrollable contain',
+ fixed: 'position: fixed',
},
'zh-TW': {
title: '基礎用法',
@@ -73,6 +78,8 @@ const PopoverDemo = () => {
content: '自定義內容',
contentColor: '自定義顏色',
showMoreDirection: '點擊查看更多方向',
+ scroll: '置於可滾動容器中',
+ fixed: '容器設置 position: fixed',
},
})
const selfContentStyle = {
@@ -231,7 +238,22 @@ const PopoverDemo = () => {
const clickCustomHandle = () => {
setCustomTarget(!customTarget)
}
-
+ const [visiblePopover, setVisiblePopover] = useState(false)
+ const [visiblePopover1, setVisiblePopover1] = useState(false)
+ const list = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
return (
<>
@@ -244,12 +266,6 @@ const PopoverDemo = () => {
onClick={() => {
basic ? setBasic(false) : setBasic(true)
}}
- onOpen={() => {
- console.log('打开菜单时触发')
- }}
- onClose={() => {
- console.log('关闭菜单时触发')
- }}
>
{translated.title}
@@ -258,6 +274,7 @@ const PopoverDemo = () => {
{translated.title1}
{
@@ -316,9 +333,7 @@ const PopoverDemo = () => {
)
})}
- ) : (
- ''
- )}
+ ) : null}
{translated.title3}
@@ -363,6 +378,7 @@ const PopoverDemo = () => {
{translated.title4}
{
{translated.contentColor}
+
+
{translated.scroll}
+
+
+
{
+ visiblePopover
+ ? setVisiblePopover1(false)
+ : setVisiblePopover1(true)
+ }}
+ >
+
+ {translated.scroll}
+
+
+
+
+
+
{translated.fixed}
+
+
{
+ visiblePopover
+ ? setVisiblePopover(false)
+ : setVisiblePopover(true)
+ }}
+ >
+
+ position: fixed
+
+
+
+
>
)
diff --git a/src/packages/popover/doc.en-US.md b/src/packages/popover/doc.en-US.md
index 9cd4a8e898..0754d4f2e8 100644
--- a/src/packages/popover/doc.en-US.md
+++ b/src/packages/popover/doc.en-US.md
@@ -488,6 +488,126 @@ export default App
:::
+### In scrollable container
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const itemList = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
+### Container setting position: fixed
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const list = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
## Popover
### Props
diff --git a/src/packages/popover/doc.md b/src/packages/popover/doc.md
index bb2e703a2e..c8b5055060 100644
--- a/src/packages/popover/doc.md
+++ b/src/packages/popover/doc.md
@@ -493,6 +493,126 @@ export default App
:::
+### 置于可滚动容器中
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const itemList = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
+### 容器设置 position: fixed
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const list = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
## Popover
### Props
diff --git a/src/packages/popover/doc.zh-TW.md b/src/packages/popover/doc.zh-TW.md
index 2db3d2cf25..18a7b42891 100644
--- a/src/packages/popover/doc.zh-TW.md
+++ b/src/packages/popover/doc.zh-TW.md
@@ -493,6 +493,126 @@ export default App
:::
+### 置於可滾動容器中
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const itemList = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
+### 容器設置 position: fixed
+
+:::demo
+
+```tsx
+import React, { useState, useRef } from 'react'
+import { Popover, Button } from '@nutui/nutui-react'
+
+const App = () => {
+ const [visible, setVisible] = useState(false)
+ const list = [
+ {
+ key: 'key1',
+ name: 'option1',
+ },
+ {
+ key: 'key2',
+ name: 'option2',
+ },
+ {
+ key: 'key3',
+ name: 'option3',
+ },
+ ]
+ return (
+ <>
+
+ >
+ )
+}
+
+export default App
+```
+
+:::
+
## Popover
### Props
diff --git a/src/packages/popover/popover.scss b/src/packages/popover/popover.scss
index d9c63ae558..70f1233173 100644
--- a/src/packages/popover/popover.scss
+++ b/src/packages/popover/popover.scss
@@ -97,7 +97,7 @@
border-bottom: 1px solid $popover-divider-color;
&:last-child {
- margin-bottom: 2px;
+ margin-bottom: 0px;
border-bottom: none;
}
diff --git a/src/packages/popover/popover.tsx b/src/packages/popover/popover.tsx
index 496689147c..9146fab465 100644
--- a/src/packages/popover/popover.tsx
+++ b/src/packages/popover/popover.tsx
@@ -1,17 +1,21 @@
import React, {
CSSProperties,
FunctionComponent,
+ ReactPortal,
useEffect,
+ useMemo,
useRef,
useState,
} from 'react'
import classNames from 'classnames'
+import { createPortal } from 'react-dom'
import Popup from '@/packages/popup'
import { PopupProps } from '@/packages/popup/popup'
import { getRect } from '@/utils/use-client-rect'
import { ComponentDefaults } from '@/utils/typings'
import useClickAway from '@/utils/use-click-away'
import { canUseDom } from '@/utils/can-use-dom'
+import { getAllScrollableParents } from '@/utils/get-scroll-parent'
export type PopoverLocation =
| 'bottom'
@@ -101,8 +105,6 @@ export const Popover: FunctionComponent<
const popoverRef = useRef