button: disabled state
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
icon,
|
icon,
|
||||||
animate = true,
|
animate = true,
|
||||||
loading,
|
loading,
|
||||||
|
disabled,
|
||||||
class: classValue,
|
class: classValue,
|
||||||
ref = $bindable<HTMLButtonElement | null>(null),
|
ref = $bindable<HTMLButtonElement | null>(null),
|
||||||
children,
|
children,
|
||||||
@@ -35,12 +36,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleButtonClick: MouseEventHandler<HTMLButtonElement> = (event) => {
|
const handleButtonClick: MouseEventHandler<HTMLButtonElement> = (event) => {
|
||||||
if (animate) {
|
if (animate && !loading && !disabled) {
|
||||||
animateLoop();
|
animateLoop();
|
||||||
animateRipple(event);
|
animateRipple(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loading) return;
|
if (loading || disabled) return;
|
||||||
|
|
||||||
onclick?.(event);
|
onclick?.(event);
|
||||||
};
|
};
|
||||||
@@ -87,8 +88,10 @@
|
|||||||
bind:this={ref}
|
bind:this={ref}
|
||||||
class={[
|
class={[
|
||||||
'button group relative flex items-center gap-3 overflow-hidden rounded-sm px-5',
|
'button group relative flex items-center gap-3 overflow-hidden rounded-sm px-5',
|
||||||
'text-sui-background cursor-pointer py-3 font-medium transition-colors',
|
'text-sui-background py-3 font-medium transition-colors',
|
||||||
!loading ? ' bg-sui-primary hover:bg-sui-secondary' : 'bg-sui-primary/50 cursor-not-allowed ',
|
!loading && !disabled
|
||||||
|
? ' bg-sui-primary hover:bg-sui-secondary cursor-pointer'
|
||||||
|
: 'bg-sui-primary/50 cursor-not-allowed ',
|
||||||
classValue
|
classValue
|
||||||
]}
|
]}
|
||||||
onclick={handleButtonClick}
|
onclick={handleButtonClick}
|
||||||
|
|||||||
Reference in New Issue
Block a user