type(button): fix icon PropType
This commit is contained in:
parent
5d37401013
commit
9bf60bd538
|
@ -70,7 +70,7 @@ type Props = {
|
||||||
to?: ?string,
|
to?: ?string,
|
||||||
variant?: 'primary' | 'secondary',
|
variant?: 'primary' | 'secondary',
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
icon?: string,
|
icon?: string | null,
|
||||||
className?: string,
|
className?: string,
|
||||||
isLoading?: boolean,
|
isLoading?: boolean,
|
||||||
};
|
};
|
||||||
|
@ -88,24 +88,21 @@ export const Button = ({
|
||||||
if (to && onClick) throw new Error('Should define either "to" or "onClick"');
|
if (to && onClick) throw new Error('Should define either "to" or "onClick"');
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
onClick, disabled: disabled || isLoading, icon: null, className,
|
onClick,
|
||||||
|
disabled: disabled || isLoading,
|
||||||
|
icon: null,
|
||||||
|
className,
|
||||||
};
|
};
|
||||||
const buttonLabel = isLoading ? 'Loading...' : label;
|
const buttonLabel = isLoading ? 'Loading...' : label;
|
||||||
|
|
||||||
const component = variant === 'primary' ? (
|
const component = variant === 'primary' ? (
|
||||||
<Primary {...props}>
|
<Primary {...props}>
|
||||||
{icon
|
{icon ? <Icon src={icon} /> : null}
|
||||||
? <Icon src={icon} />
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
{buttonLabel}
|
{buttonLabel}
|
||||||
</Primary>
|
</Primary>
|
||||||
) : (
|
) : (
|
||||||
<Secondary {...props}>
|
<Secondary {...props}>
|
||||||
{icon
|
{icon ? <Icon src={icon} /> : null}
|
||||||
? <Icon src={icon} />
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
{buttonLabel}
|
{buttonLabel}
|
||||||
</Secondary>
|
</Secondary>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue