diff options
| author | Haishan <[email protected]> | 2020-11-22 12:13:05 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2020-11-22 12:13:05 +0800 |
| commit | 9ca6f4ff2bb6f81a7ba3d1f2c73971236e6681b2 (patch) | |
| tree | 728efebb6911ca288f80e0b37dc635a6a8830481 /src/components/Button.tsx | |
| parent | 0f5f7859ce3a06c2f859eddc3fb0936c187ba86d (diff) | |
chore: minor a11y improvement
Diffstat (limited to 'src/components/Button.tsx')
| -rw-r--r-- | src/components/Button.tsx | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 9450969..372038f 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -4,7 +4,7 @@ import * as React from 'react'; import s0 from './Button.module.css'; import { LoadingDot } from './shared/Basic'; -const { memo, forwardRef, useCallback } = React; +const { forwardRef, useCallback } = React; type ButtonInternalProps = { children?: React.ReactNode; @@ -19,6 +19,7 @@ type ButtonProps = { disabled?: boolean; kind?: 'primary' | 'minimal'; className?: string; + title?: string; } & ButtonInternalProps; function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) { @@ -28,8 +29,13 @@ function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) { isLoading, kind = 'primary', className, + children, + label, + text, + start, ...restProps } = props; + const internalProps = { children, label, text, start }; const internalOnClick = useCallback( (e) => { if (isLoading) return; @@ -39,9 +45,7 @@ function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) { ); const btnClassName = cx( s0.btn, - { - [s0.minimal]: kind === 'minimal', - }, + { [s0.minimal]: kind === 'minimal' }, className ); return ( @@ -50,23 +54,19 @@ function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) { ref={ref} onClick={internalOnClick} disabled={disabled} + {...restProps} > {isLoading ? ( <> - <span - style={{ - display: 'inline-flex', - opacity: 0, - }} - > - <ButtonInternal {...restProps} /> + <span style={{ display: 'inline-flex', opacity: 0 }}> + <ButtonInternal {...internalProps} /> </span> <span className={s0.loadingContainer}> <LoadingDot /> </span> </> ) : ( - <ButtonInternal {...restProps} /> + <ButtonInternal {...internalProps} /> )} </button> ); @@ -85,4 +85,4 @@ function ButtonInternal({ children, label, text, start }: ButtonInternalProps) { ); } -export default memo(forwardRef(Button)); +export default forwardRef(Button); |
