Skip to content

Commit 54cf97b

Browse files
committed
v1.0.1
1 parent 41b19e4 commit 54cf97b

File tree

9 files changed

+21
-22
lines changed

9 files changed

+21
-22
lines changed

docs/asset-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"index.css": "static/css/index.a84cfb9e.chunk.css",
3-
"index.js": "static/js/index.a84cfb9e.chunk.js",
2+
"index.css": "static/css/index.569717b6.chunk.css",
3+
"index.js": "static/js/index.569717b6.chunk.js",
44
"runtime-index.js": "static/js/runtime-index.92eae014.js",
55
"static/js/2.45d0bd0b.chunk.js": "static/js/2.45d0bd0b.chunk.js",
66
"index.html": "index.html"

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html style="width:100%;height:100%;overflow:auto"><head><meta charset="utf-8"/><title>Button</title><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"/><style>.demo{width:1100px;height:500px;margin:50px auto;background:#fff;font-size:12px;overflow:auto}.rw-layout-content{height:200px}.rw-layout.rw-layout-has-sider{text-align:center;background:#3ba0e9}.rw-layout-sider{width:200px;text-align:center;background:#3ba0e9;color:#fff}.rw-layout-footer,.rw-layout-header{background:#7dbcea;color:#fff;height:64px;line-height:64px;text-align:center}.rw-layout-content{background:#108ee9;color:#fff;text-align:center}</style><link href="static/css/index.a84cfb9e.chunk.css" rel="stylesheet"></head><body style="background:#f5f5f5"><div class="demo" id="demo"></div><script src="static/js/runtime-index.92eae014.js"></script><script src="static/js/2.45d0bd0b.chunk.js"></script><script src="static/js/index.a84cfb9e.chunk.js"></script></body></html>
1+
<!doctype html><html style="width:100%;height:100%;overflow:auto"><head><meta charset="utf-8"/><title>Button</title><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"/><style>.demo{width:1100px;height:500px;margin:50px auto;background:#fff;font-size:12px;overflow:auto}.rw-layout-content{height:200px}.rw-layout.rw-layout-has-sider{text-align:center;background:#3ba0e9}.rw-layout-sider{width:200px;text-align:center;background:#3ba0e9;color:#fff}.rw-layout-footer,.rw-layout-header{background:#7dbcea;color:#fff;height:64px;line-height:64px;text-align:center}.rw-layout-content{background:#108ee9;color:#fff;text-align:center}</style><link href="static/css/index.569717b6.chunk.css" rel="stylesheet"></head><body style="background:#f5f5f5"><div class="demo" id="demo"></div><script src="static/js/runtime-index.92eae014.js"></script><script src="static/js/2.45d0bd0b.chunk.js"></script><script src="static/js/index.569717b6.chunk.js"></script></body></html>

docs/static/js/index.569717b6.chunk.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/static/js/index.a84cfb9e.chunk.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-widget-button",
3-
"version": "1.0.0",
4-
"description": "rw-widget-button",
3+
"version": "1.0.1",
4+
"description": "react-widget-button",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
77
"types": "lib/index.d.ts",

src/Button.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,26 @@ export const Button: React.FC<ButtonProps> & { Group: typeof ButtonGroup } = fun
4444
tagName,
4545
...restProps
4646
}) {
47-
const btnGroup = React.useContext(ButtonGroupContext);
48-
const isDisabled = btnGroup.disabled || disabled;
47+
const context = React.useContext(ButtonGroupContext);
48+
if (context) {
49+
disabled = disabled || context.disabled;
50+
size = size || context.size;
51+
type = type || context.type;
52+
}
4953

50-
const classes = classnames({
54+
const cls = classnames({
5155
[prefixCls!]: true,
52-
[`${prefixCls}-${btnGroup.size || size}`]: btnGroup.size || size,
53-
[`${prefixCls}-disabled`]: isDisabled || loading,
56+
[`${prefixCls}-${size}`]: size,
57+
[`${prefixCls}-disabled`]: disabled || loading,
5458
[`${prefixCls}-active`]: active,
5559
[`${prefixCls}-loading`]: loading,
56-
[`${prefixCls}-${btnGroup.type || type}`]: btnGroup.type || type,
60+
[`${prefixCls}-${type}`]: type,
5761
});
5862

5963
const TagName = tagName!;
6064

6165
return (
62-
<TagName
63-
{...restProps}
64-
disabled={isDisabled || loading}
65-
className={classes}
66-
type={htmlType}
67-
>
66+
<TagName {...restProps} disabled={disabled || loading} className={cls} type={htmlType}>
6867
{prefix}
6968
{(prefix || suffix) && isReactNodeEmpty(children) ? (
7069
<span className={`${prefixCls}-text`}>{children}</span>

src/ButtonGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from "classnames";
33
import ButtonGroupContext from "./ButtonGroupContext";
44

55
export interface ButtonGroupProps {
6-
prefixCls: string;
6+
prefixCls?: string;
77
className?: string;
88
disabled?: boolean;
99
type?: "primary";
@@ -19,11 +19,11 @@ export const ButtonGroup: React.FC<ButtonGroupProps> = function ({
1919
children,
2020
...restProps
2121
}) {
22-
const classes = classNames(`${prefixCls}-group`, className);
22+
const cls = classNames(`${prefixCls}-group`, className);
2323

2424
return (
2525
<ButtonGroupContext.Provider value={{ type, size, disabled }}>
26-
<div {...restProps} className={classes}>
26+
<div {...restProps} className={cls}>
2727
{children}
2828
</div>
2929
</ButtonGroupContext.Provider>

src/ButtonGroupContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export interface ButtonGroupContext {
66
size?: "small" | "default" | "large";
77
}
88

9-
export default React.createContext<ButtonGroupContext>({});
9+
export default React.createContext<ButtonGroupContext | null>(null);

0 commit comments

Comments
 (0)