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