mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(archive): animate loading ellipsis
This commit is contained in:
@@ -41,4 +41,13 @@ describe('LoadingEllipsis', () => {
|
||||
expect(container.textContent).toBe('Loading');
|
||||
expect(container.firstChild?.textContent).toBe('Loading');
|
||||
});
|
||||
|
||||
it('removes static trailing ellipsis text before adding the animated ellipsis', () => {
|
||||
act(() => {
|
||||
root.render(createElement(LoadingEllipsis, { string: 'Loading archive...' }));
|
||||
});
|
||||
|
||||
expect(container.textContent).toBe('Loading archive');
|
||||
expect(container.querySelector('span span span')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,8 +4,11 @@ interface LoadingEllipsisProps {
|
||||
string: string;
|
||||
}
|
||||
|
||||
const TRAILING_ELLIPSIS_PATTERN = /\s*(?:\.\.\.|\u2026)\s*$/;
|
||||
|
||||
const LoadingEllipsis = ({ string }: LoadingEllipsisProps) => {
|
||||
const words = string.split(' ');
|
||||
const normalizedString = string.replace(TRAILING_ELLIPSIS_PATTERN, '');
|
||||
const words = normalizedString.split(' ');
|
||||
const lastWord = words.pop();
|
||||
const restOfString = words.join(' ');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user