summaryrefslogtreecommitdiff
path: root/src/components/Button.js
diff options
context:
space:
mode:
authorHaishan <[email protected]>2019-12-27 13:12:49 +0800
committerHaishan <[email protected]>2019-12-27 16:29:46 +0800
commitaca578cb9dfdaed33f91c62ffdf3ef1a456c6a72 (patch)
tree0db1a3f2646ec28841ba59d00e89f156432a9afb /src/components/Button.js
parent45c3c7b8b4793ca3b6cd8366baaf035346a6d745 (diff)
refactor: abstract ButtonWithIcon as a button enhancer
Diffstat (limited to 'src/components/Button.js')
-rw-r--r--src/components/Button.js18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/components/Button.js b/src/components/Button.js
index d9bcd22..ce83153 100644
--- a/src/components/Button.js
+++ b/src/components/Button.js
@@ -6,10 +6,11 @@ const noop = () => {};
const { memo, forwardRef } = React;
-function Button({ children, label, onClick = noop }, ref) {
+function Button({ children, label, text, start, onClick = noop }, ref) {
return (
<button className={s0.btn} ref={ref} onClick={onClick}>
- {children || label}
+ {start ? <span className={s0.btnStart}>{start}</span> : null}
+ {children || label || text}
</button>
);
}
@@ -22,17 +23,4 @@ export function ButtonPlain({ children, label, onClick = noop }) {
);
}
-function WithIcon({ text, icon, onClick = noop }, ref) {
- return (
- <button className={s0.btn} ref={ref} onClick={onClick}>
- <div className={s0.withIconWrapper}>
- {icon}
- <span className={s0.txt}>{text}</span>
- </div>
- </button>
- );
-}
-
-export const ButtonWithIcon = memo(forwardRef(WithIcon));
-
export default memo(forwardRef(Button));