Skip to content

Commit f349dba

Browse files
committed
improve the displaying when the button is disabled
1 parent 54522d5 commit f349dba

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/components/Elements/Button/Button.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
color: var(--button-hover-text-color);
1818
}
1919

20+
&.disabled {
21+
cursor: not-allowed;
22+
opacity: 0.8;
23+
}
2024
&.small {
2125
padding: 0.3rem 0.75rem;
2226
font-size: 0.875rem;
@@ -51,6 +55,12 @@
5155
padding: 0;
5256
padding: 0;
5357
font-size: 1.1em;
58+
59+
&.disabled {
60+
cursor: not-allowed;
61+
opacity: 0.8;
62+
}
63+
5464
&.small {
5565
min-width: 30px;
5666
height: 30px;

src/components/Elements/Button/Button.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export const Button = ({
2727
}: ButtonProps) => {
2828
return (
2929
<button
30-
className={clsx('button', isLoading && 'loading', sizes[size], className)}
30+
className={clsx(
31+
'button',
32+
isLoading && 'loading',
33+
sizes[size],
34+
className,
35+
isLoading && 'disabled'
36+
)}
3137
onClick={onClick}
3238
disabled={isLoading}>
3339
{isLoading ? <Spinner size="small" /> : startIcon}

src/components/Elements/Button/CircleButton.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import clsx from 'clsx'
2+
import { Spinner } from '../Spinner'
23

34
const sizes = {
45
small: 'small',
@@ -13,6 +14,7 @@ const variants = {
1314

1415
type CircleButtonProps = {
1516
className?: string
17+
isLoading?: boolean
1618
onClick: () => void
1719
size?: keyof typeof sizes
1820
variant?: keyof typeof variants
@@ -23,14 +25,22 @@ export const CircleButton = ({
2325
size = 'medium',
2426
variant = 'primary',
2527
onClick,
28+
isLoading,
2629
className,
2730
children,
2831
}: CircleButtonProps) => {
2932
return (
3033
<button
31-
className={clsx('circle-button', sizes[size], variants[variant], className)}
34+
disabled={isLoading}
35+
className={clsx(
36+
'circle-button',
37+
sizes[size],
38+
variants[variant],
39+
className,
40+
isLoading && 'disabled'
41+
)}
3242
onClick={onClick}>
33-
{children}
43+
{isLoading ? <Spinner size="small" /> : children}
3444
</button>
3545
)
3646
}

0 commit comments

Comments
 (0)