fix(ellipsis animation): dots could appear cut off and cause displacement changing width of string

This commit is contained in:
Tom (plebeius.eth)
2024-12-02 10:33:17 +01:00
parent d6d2831b46
commit 09505a6231
2 changed files with 54 additions and 11 deletions
@@ -5,7 +5,20 @@ interface LoadingEllipsisProps {
}
const LoadingEllipsis = ({ string }: LoadingEllipsisProps) => {
return <span className={styles.ellipsis}>{string}</span>;
const words = string.split(' ');
const lastWord = words.pop();
const restOfString = words.join(' ');
return (
<span>
{restOfString}
{restOfString && ' '}
<span className={styles.nowrap}>
{lastWord}
<span className={styles.ellipsis} />
</span>
</span>
);
};
export default LoadingEllipsis;