mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-02-10 08:52:13 -05:00
[Glitch] Add loading indicator to timeline gap indicators in web UI
Port 82183d8a79979a738304c73f6808794d6f5d442f to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
844ae90dad
commit
2c97a59148
@ -1,9 +1,10 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
import { useIntl, defineMessages } from 'react-intl';
|
import { useIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
||||||
import { Icon } from 'flavours/glitch/components/icon';
|
import { Icon } from 'flavours/glitch/components/icon';
|
||||||
|
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
||||||
@ -17,10 +18,12 @@ interface Props<T> {
|
|||||||
|
|
||||||
export const LoadGap = <T,>({ disabled, param, onClick }: Props<T>) => {
|
export const LoadGap = <T,>({ disabled, param, onClick }: Props<T>) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
|
setLoading(true);
|
||||||
onClick(param);
|
onClick(param);
|
||||||
}, [param, onClick]);
|
}, [setLoading, param, onClick]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@ -28,8 +31,13 @@ export const LoadGap = <T,>({ disabled, param, onClick }: Props<T>) => {
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
aria-label={intl.formatMessage(messages.load_more)}
|
aria-label={intl.formatMessage(messages.load_more)}
|
||||||
|
title={intl.formatMessage(messages.load_more)}
|
||||||
>
|
>
|
||||||
|
{loading ? (
|
||||||
|
<LoadingIndicator />
|
||||||
|
) : (
|
||||||
<Icon id='ellipsis-h' icon={MoreHorizIcon} />
|
<Icon id='ellipsis-h' icon={MoreHorizIcon} />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -4105,23 +4105,27 @@ a.status-card {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.load-more {
|
.load-more {
|
||||||
display: block;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
color: $dark-text-color;
|
color: $dark-text-color;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 0;
|
border: 0;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
text-align: center;
|
|
||||||
line-height: inherit;
|
line-height: inherit;
|
||||||
margin: 0;
|
width: 100%;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
|
||||||
clear: both;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--on-surface-color);
|
background: var(--on-surface-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-gap {
|
.load-gap {
|
||||||
@ -4643,6 +4647,7 @@ a.status-card {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.load-more .loading-indicator,
|
||||||
.button .loading-indicator {
|
.button .loading-indicator {
|
||||||
position: static;
|
position: static;
|
||||||
transform: none;
|
transform: none;
|
||||||
@ -4654,6 +4659,10 @@ a.status-card {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.load-more .loading-indicator .circular-progress {
|
||||||
|
color: lighten($ui-base-color, 26%);
|
||||||
|
}
|
||||||
|
|
||||||
.circular-progress {
|
.circular-progress {
|
||||||
color: lighten($ui-base-color, 26%);
|
color: lighten($ui-base-color, 26%);
|
||||||
animation: 1.4s linear 0s infinite normal none running simple-rotate;
|
animation: 1.4s linear 0s infinite normal none running simple-rotate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user