mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
refactor button to use default loader
This commit is contained in:
@@ -2,9 +2,24 @@
|
||||
font-weight: 500;
|
||||
border: 1px solid transparent;
|
||||
transition:
|
||||
opacity 0.2s ease,
|
||||
background-color 0.2s ease-in-out,
|
||||
border-color 0.2s ease-in-out;
|
||||
|
||||
&[data-loading='true'] {
|
||||
transform: none;
|
||||
|
||||
&::before {
|
||||
transition: none;
|
||||
transition: opacity 0.1s ease;
|
||||
}
|
||||
|
||||
.inner {
|
||||
opacity: 0;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
&[data-disabled='true'] {
|
||||
opacity: 0.6;
|
||||
}
|
||||
@@ -143,7 +158,7 @@
|
||||
}
|
||||
|
||||
.loader {
|
||||
display: none;
|
||||
transition-duration: 0;
|
||||
}
|
||||
|
||||
.section {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import styles from './button.module.css';
|
||||
|
||||
import { Spinner } from '/@/shared/components/spinner/spinner';
|
||||
import { Tooltip, TooltipProps } from '/@/shared/components/tooltip/tooltip';
|
||||
import { useTimeout } from '/@/shared/hooks/use-timeout';
|
||||
import { createPolymorphicComponent } from '/@/shared/utils/create-polymorphic-component';
|
||||
@@ -48,6 +47,7 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
<MantineButton
|
||||
autoContrast
|
||||
classNames={{
|
||||
inner: styles.inner,
|
||||
label: clsx(styles.label, {
|
||||
[styles.uppercase]: uppercase,
|
||||
}),
|
||||
@@ -56,6 +56,7 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
section: styles.section,
|
||||
...classNames,
|
||||
}}
|
||||
loading={loading}
|
||||
ref={ref}
|
||||
size={size}
|
||||
style={style}
|
||||
@@ -63,11 +64,6 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{loading && (
|
||||
<div className={styles.spinner}>
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
</MantineButton>
|
||||
</Tooltip>
|
||||
);
|
||||
@@ -76,6 +72,7 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
return (
|
||||
<MantineButton
|
||||
classNames={{
|
||||
inner: styles.inner,
|
||||
label: clsx(styles.label, {
|
||||
[styles.uppercase]: uppercase,
|
||||
}),
|
||||
@@ -84,6 +81,7 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
section: styles.section,
|
||||
...classNames,
|
||||
}}
|
||||
loading={loading}
|
||||
ref={ref}
|
||||
size={size}
|
||||
style={style}
|
||||
@@ -91,11 +89,6 @@ export const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{loading && (
|
||||
<div className={styles.spinner}>
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
</MantineButton>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user