Add full container spinner/loader
This commit is contained in:
parent
5dbc0c61c5
commit
691bc8f1ef
3 changed files with 16 additions and 20 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { Center } from '@mantine/core';
|
||||||
import type { IconType } from 'react-icons';
|
import type { IconType } from 'react-icons';
|
||||||
import { RiLoader5Fill } from 'react-icons/ri';
|
import { RiLoader5Fill } from 'react-icons/ri';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
@ -5,6 +6,7 @@ import { rotating } from '/@/renderer/styles';
|
||||||
|
|
||||||
interface SpinnerProps extends IconType {
|
interface SpinnerProps extends IconType {
|
||||||
color?: string;
|
color?: string;
|
||||||
|
container?: boolean;
|
||||||
size?: number;
|
size?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +16,17 @@ export const SpinnerIcon = styled(RiLoader5Fill)`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Spinner = ({ ...props }: SpinnerProps) => {
|
export const Spinner = ({ ...props }: SpinnerProps) => {
|
||||||
|
if (props.container) {
|
||||||
|
return (
|
||||||
|
<Center
|
||||||
|
h="100%"
|
||||||
|
w="100%"
|
||||||
|
>
|
||||||
|
<SpinnerIcon {...props} />
|
||||||
|
</Center>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return <SpinnerIcon {...props} />;
|
return <SpinnerIcon {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useMemo, useRef } from 'react';
|
import { useMemo, useRef } from 'react';
|
||||||
import { Center, Stack } from '@mantine/core';
|
import { Stack } from '@mantine/core';
|
||||||
import { AlbumListSort, LibraryItem, ServerType, SortOrder } from '/@/renderer/api/types';
|
import { AlbumListSort, LibraryItem, ServerType, SortOrder } from '/@/renderer/api/types';
|
||||||
import { FeatureCarousel, NativeScrollArea, Spinner } from '/@/renderer/components';
|
import { FeatureCarousel, NativeScrollArea, Spinner } from '/@/renderer/components';
|
||||||
import { useAlbumList } from '/@/renderer/features/albums';
|
import { useAlbumList } from '/@/renderer/features/albums';
|
||||||
|
@ -93,14 +93,7 @@ const HomeRoute = () => {
|
||||||
mostPlayed.isFetching;
|
mostPlayed.isFetching;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return <Spinner container />;
|
||||||
<Center
|
|
||||||
h="100%"
|
|
||||||
w="100%"
|
|
||||||
>
|
|
||||||
<Spinner />
|
|
||||||
</Center>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const carousels = [
|
const carousels = [
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { constrainSidebarWidth, constrainRightSidebarWidth } from '/@/renderer/u
|
||||||
import { LeftSidebar } from '/@/renderer/layouts/default-layout/left-sidebar';
|
import { LeftSidebar } from '/@/renderer/layouts/default-layout/left-sidebar';
|
||||||
import { FullScreenOverlay } from '/@/renderer/layouts/default-layout/full-screen-overlay';
|
import { FullScreenOverlay } from '/@/renderer/layouts/default-layout/full-screen-overlay';
|
||||||
import { RightSidebar } from '/@/renderer/layouts/default-layout/right-sidebar';
|
import { RightSidebar } from '/@/renderer/layouts/default-layout/right-sidebar';
|
||||||
import { Center } from '@mantine/core';
|
|
||||||
import { Spinner } from '/@/renderer/components';
|
import { Spinner } from '/@/renderer/components';
|
||||||
|
|
||||||
const SideDrawerQueue = lazy(() =>
|
const SideDrawerQueue = lazy(() =>
|
||||||
|
@ -118,16 +117,7 @@ export const MainContent = ({ shell }: { shell?: boolean }) => {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Suspense
|
<Suspense fallback={<Spinner container />}>
|
||||||
fallback={
|
|
||||||
<Center
|
|
||||||
h="100%"
|
|
||||||
w="100%"
|
|
||||||
>
|
|
||||||
<Spinner />
|
|
||||||
</Center>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</MainContentContainer>
|
</MainContentContainer>
|
||||||
|
|
Reference in a new issue