Skip to content

Commit

Permalink
add button loading text
Browse files Browse the repository at this point in the history
  • Loading branch information
SarjuHansaliya committed Nov 2, 2021
1 parent f0fe189 commit 2155d0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ import { IconAfter, IconBefore, Root } from './styles';
import { ButtonProps } from './types';

const Button: React.FC<ButtonProps> = (props) => {
const { iconBefore, children, iconAfter, ...rest } = props;
const { iconBefore, children, iconAfter, loading, loadingText, ...rest } = props;
return (
<Root {...rest}>
{iconBefore && <IconBefore>{iconBefore}</IconBefore>}
{children}
{iconAfter && <IconAfter>{iconAfter}</IconAfter>}
{loading ? (
loadingText ? (
loadingText
) : (
'Loading...'
)
) : (
<>
{iconBefore && <IconBefore>{iconBefore}</IconBefore>}
{children}
{iconAfter && <IconAfter>{iconAfter}</IconAfter>}
</>
)}
</Root>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type ButtonProps = {
loading?: boolean;
/** loading icon **/
loadingIcon?: React.ReactNode;
loadingText?: string;
padding?: string;
borderRadius?: string;
};

0 comments on commit 2155d0d

Please sign in to comment.