Skip to content

Commit

Permalink
Add loading overlay to root.tsx
Browse files Browse the repository at this point in the history
 (#134)
  • Loading branch information
kimurash committed Nov 17, 2024
1 parent 8d8df2f commit b4bc9fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
23 changes: 19 additions & 4 deletions frontend/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import {
ColorSchemeScript,
LoadingOverlay,
MantineProvider,
} from '@mantine/core';
import '@mantine/core/styles.css';
import '@mantine/notifications/styles.css';
import '@mantine/dates/styles.css';
import { Notifications } from '@mantine/notifications';
import '@mantine/notifications/styles.css';
import type { LinksFunction } from '@remix-run/cloudflare';
import {
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useNavigation,
} from '@remix-run/react';
import { ColorSchemeScript, MantineProvider } from '@mantine/core';
import { Notifications } from '@mantine/notifications';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

export const links: LinksFunction = () => [
Expand Down Expand Up @@ -53,5 +58,15 @@ export function Layout({ children }: { children: React.ReactNode }) {
}

export default function App() {
return <Outlet />;
const navigation = useNavigation();

return (
<>
<LoadingOverlay
visible={navigation.state !== 'idle'}
overlayProps={{ radius: 'sm', blur: 1 }}
/>
<Outlet />
</>
);
}
6 changes: 1 addition & 5 deletions frontend/app/routes/home/route.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppShell, Container, LoadingOverlay } from '@mantine/core';
import { AppShell, Container } from '@mantine/core';
import {
ActionFunctionArgs,
json,
Expand Down Expand Up @@ -132,10 +132,6 @@ const Home = () => {
<HeaderComponent />
<Container size="xl">
<AppShell.Main>
<LoadingOverlay
visible={navigation.state === 'loading'}
overlayProps={{ radius: 'sm', blur: 1 }}
/>
<Outlet />
</AppShell.Main>
</Container>
Expand Down

0 comments on commit b4bc9fa

Please sign in to comment.