1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

added loading circle for creating comment

This commit is contained in:
Fedor Katurov 2022-07-18 15:32:54 +07:00
parent bb81bdae69
commit fa17aac056
6 changed files with 23 additions and 21 deletions

View file

@ -92,8 +92,6 @@ const CommentForm: FC<IProps> = observer(({ comment, nodeId, saveComment, onCanc
<Filler /> <Filler />
<div className={styles.button_column}> <div className={styles.button_column}>
{isLoading && <LoaderCircle size={20} />}
{isEditing && ( {isEditing && (
<Button size="small" color="link" type="button" onClick={onCancelEdit}> <Button size="small" color="link" type="button" onClick={onCancelEdit}>
Отмена Отмена
@ -106,6 +104,7 @@ const CommentForm: FC<IProps> = observer(({ comment, nodeId, saveComment, onCanc
color="gray" color="gray"
iconRight={!isEditing ? 'enter' : 'check'} iconRight={!isEditing ? 'enter' : 'check'}
disabled={isLoading} disabled={isLoading}
loading={isLoading}
> >
{!isEditing ? 'Сказать' : 'Сохранить'} {!isEditing ? 'Сказать' : 'Сохранить'}
</Button> </Button>

View file

@ -68,15 +68,25 @@ const Button: FC<IButtonProps> = memo(
] ]
); );
const loaderSize = useMemo(() => {
if (['small', 'micro', 'mini'].includes(size)) {
return 16;
}
return 24;
}, []);
return ( return (
<Tippy content={label || ''} disabled={!label}> <Tippy content={label || ''} disabled={!label}>
<button className={computedClassName} {...props}> <button className={computedClassName} {...props}>
{iconLeft && <Icon icon={iconLeft} size={20} key={0} className={styles.icon_left} />} {iconLeft && <Icon icon={iconLeft} size={20} key={0} className={styles.icon_left} />}
{!!title ? <span>{title}</span> : children} {!!title ? <span>{title}</span> : children}
{iconRight && <Icon icon={iconRight} size={20} key={2} className={styles.icon_right} />} {iconRight && <Icon icon={iconRight} size={20} key={2} className={styles.icon_right} />}
{ {loading && (
loading && <div className={styles.loading}><LoaderCircle /></div> <div className={styles.loading}>
} <LoaderCircle size={loaderSize} />
</div>
)}
</button> </button>
</Tippy> </Tippy>
); );

View file

@ -48,7 +48,7 @@
opacity: 0; opacity: 0;
} }
svg { svg.icon {
fill: white; fill: white;
stroke: white; stroke: white;
} }
@ -174,7 +174,7 @@
.small { .small {
height: 32px; height: 32px;
svg { svg.icon {
width: 24px; width: 24px;
height: 24px; height: 24px;
} }

View file

@ -12,8 +12,8 @@ interface IProps extends SVGProps {
className?: string; className?: string;
} }
export const LoaderCircle: FC<IProps> = ({ size = 24, ...rest }) => ( export const LoaderCircle: FC<IProps> = ({ size = 24, className }) => (
<div className={classNames(styles.wrap, 'loader-circle', rest.className)}> <div className={classNames(styles.wrap, 'loader-circle', className)}>
<LoaderCircleInner {...rest} size={size} /> <LoaderCircleInner size={size} />
</div> </div>
); );

View file

@ -21,6 +21,9 @@
} }
.wrap { .wrap {
//animation: spin infinite 1s linear; animation: spin infinite 0.75s linear;
display: inline-flex; display: inline-flex;
transform-origin: 50% 50%;
align-items: center;
justify-content: center;
} }

View file

@ -1,16 +1,6 @@
@import "src/styles/variables"; @import "src/styles/variables";
@keyframes spin {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.icon { .icon {
fill: currentColor; fill: currentColor;
stroke: none; stroke: none;
animation: spin 0.75s infinite linear;
} }