1
0
Эх сурвалжийг харах

fix: [Button] Fix ButtonGroup does not support style (#1138)

* fix: [Button] Fix ButtonGroup does not support style

* docs: optimize doc
YyumeiZhang 3 жил өмнө
parent
commit
c27f6b0063

+ 13 - 12
content/input/button/index-en-US.md

@@ -508,23 +508,24 @@ function SplitButtonDemo(){
 | onMouseEnter             | Mouse Enter                                                                                                   | Function(MouseEvent)                        |           |
 | onMouseLeave             | Mouse Leave                                                                                                   | Function(MouseEvent)                        |           |
 
-
 ### ButtonGroup
 
-| Properties | Instructions                                                                            | Type    | Default   |
-| ---------- | --------------------------------------------------------------------------------------- | ------- | --------- |
-| aria-label          | Label of the button group                                                                                      | string                            | -    |
-| disabled   | Disabled status                                                                         | boolean | false     |
-| size       | Button size, optional value: `"large"`,`"default"`,`"small"`                            | string  | "default" |
+| Properties | Instructions                | Type    | Default   | Version |
+| ---------- | ----------------------------| ------- | --------- |---------|
+| aria-label | Label of the button group   | string  | - | |
+| className  | Custom class name           | string   | - | |
+| disabled   | Disabled status             | boolean | false | |
+| size       | Button size, optional value: `"large"`,`"default"`,`"small"` | string  | "default" |
+| style      | Custom style                | CSSProperties   | - | 2.20.0 |
+| theme      | Button theme, optional values: `"solid"` (with background color), `"borderless"` (without background color), `"light"` (light background color) | string | "light"  | |
 | type       | Type, optional values: `"primary"`,`"secondary"`, `"tertiary"`, `"warning"`, `"danger"` | string  | "primary" |
-| className     | Custom class name                                  | string   |        |
 
 ### SplitButtonGroup **V1.12.0**
-| Properties   | Instructions                                                            | Type      | Default     |
-| -----------  | --------------------------------------------------------------  | -------- | --------- |
-| aria-label          | Label of the button group                                                                                       | string                            | -    |
-| style     | Custom style                                  | CSSProperties   |        |
-| className     | Custom class name                                  | string   |        |
+| Properties   | Instructions                     | Type     | Default   |
+| -----------  | ---------------------------------| -------- | --------- |
+| aria-label   | Label of the button group        | string   | -    |
+| className    | Custom class name                | string   | - |
+| style        | Custom style                     | CSSProperties | -  |
 
 ## Accessibility
 

+ 15 - 14
content/input/button/index.md

@@ -470,28 +470,29 @@ function SplitButtonDemo(){
 
 ### ButtonGroup
 
-| 属性     | 说明                                                                   | 类型    | 默认值    |
-| -------- | ---------------------------------------------------------------------- | ------- | --------- |
-| aria-label          | 按钮组的标签                                                                                       | string                            | -    |
-| disabled | 禁用状态                                                               | boolean | false     |
-| size     | 按钮大小,可选值:`large`、`default`、`small`                          | string  | "default" |
-| theme               | 按钮主题,可选值:`solid`(有背景色)、 `borderless`(无背景色)、 `light`(浅背景色)                     | string                          | "light"   |
-| type     | 类型,可选值:`primary`、`secondary`、`tertiary`、`warning`、 `danger` | string  | "primary" |
-| className     | 自定义类名                               | string   |         |
+| 属性     | 说明          | 类型    | 默认值      | 版本 |
+| -------- | -------------| ------- | --------- |---- |
+| aria-label | 按钮组的标签 | string  | - | |
+| className  | 自定义类名   | string  | - | |
+| disabled   | 禁用状态     | boolean | false | |
+| size       | 按钮大小,可选值:`large`、`default`、`small` | string  | "default" | |
+| style      | 自定义样式   | CSSProperties   | - | 2.20.0 |
+| theme      | 按钮主题,可选值:`solid`(有背景色)、 `borderless`(无背景色)、 `light`(浅背景色) | string | "light"   | |
+| type     | 类型,可选值:`primary`、`secondary`、`tertiary`、`warning`、 `danger` | string  | "primary" | |
 
 ### SplitButtonGroup **V1.12.0新增**
-| 属性          | 说明                                                            | 类型      | 默认值     |
-| -----------  | --------------------------------------------------------------  | -------- | --------- |
-| aria-label          | 分裂按钮组的标签                                                                                       | string                            | -    |
-| style     | 自定义样式                               | CSSProperties   |         |
-| className     | 自定义类名                               | string   |         |
+| 属性          | 说明                 | 类型      | 默认值     |
+| -----------  | ---------------------| -------- | --------- |
+| aria-label   | 分裂按钮组的标签        | string   | - |
+| className    | 自定义类名             | string   | - |
+| style        | 自定义样式             | CSSProperties   | - |
 
 ## Accessibility
 
 ### ARIA
 
 - `aria-label` 用于表示按钮的作用,对于图标按钮,我们推荐使用此属性
-- `aria-disabled` 与 disabled 属性同步,表示按钮禁用 
+- `aria-disabled` 与 disabled 属性同步,表示按钮禁用
 
 ### 键盘和焦点
 

+ 2 - 2
packages/semi-ui/button/buttonGroup.tsx

@@ -72,7 +72,7 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
     }
 
     render() {
-        const { children, disabled, size, type, className, 'aria-label': ariaLabel, ...rest } = this.props;
+        const { children, disabled, size, type, className, style, 'aria-label': ariaLabel, ...rest } = this.props;
         let inner: ReactNode[];
         let innerWithLine: ReactNode[] = [];
         const cls = classNames(`${prefixCls}-group`, className);
@@ -85,6 +85,6 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
             ));
             innerWithLine = this.getInnerWithLine(inner);
         }
-        return <div className={cls} role="group" aria-label={ariaLabel}>{innerWithLine}</div>;
+        return <div className={cls} style={style} role="group" aria-label={ariaLabel}>{innerWithLine}</div>;
     }
 }