mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2025-08-27 04:59:22 +00:00
Lazy load page components
This commit is contained in:
parent
3a34db8320
commit
8bdff8da6d
@ -64,6 +64,7 @@ The project uses shadcn/ui components located in `@/components/ui`. These are un
|
||||
- **Skeleton**: Loading placeholder
|
||||
- **Slider**: Input for selecting a value from a range
|
||||
- **Sonner**: Toast notification manager
|
||||
- **Spinner**: Animated loading spinner
|
||||
- **Switch**: Toggle switch control
|
||||
- **Table**: Data table with headers and rows
|
||||
- **Tabs**: Tabbed interface component
|
||||
|
@ -1,9 +1,11 @@
|
||||
// NOTE: This file should normally not be modified unless you are adding a new provider.
|
||||
// To add new routes, edit the AppRouter.tsx file.
|
||||
|
||||
import { Suspense } from 'react';
|
||||
import NostrProvider from '@/components/NostrProvider'
|
||||
import { ThemeProvider } from "@/components/ThemeProvider";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { Spinner } from '@/components/ui/spinner';
|
||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
@ -36,7 +38,9 @@ export function App() {
|
||||
<TooltipProvider>
|
||||
<Toaster />
|
||||
<Sonner />
|
||||
<AppRouter />
|
||||
<Suspense fallback={<div className="flex items-center justify-center h-screen"><Spinner /></div>}>
|
||||
<AppRouter />
|
||||
</Suspense>
|
||||
</TooltipProvider>
|
||||
</QueryClientProvider>
|
||||
</NostrProvider>
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { lazy } from "react";
|
||||
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||
|
||||
import Index from "./pages/Index";
|
||||
import NotFound from "./pages/NotFound";
|
||||
import { ScrollToTop } from "./components/ScrollToTop";
|
||||
|
||||
// Lazy load page components
|
||||
const Index = lazy(() => import("./pages/Index"));
|
||||
const NotFound = lazy(() => import("./pages/NotFound"));
|
||||
|
||||
export function AppRouter() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
|
12
src/components/ui/spinner.tsx
Normal file
12
src/components/ui/spinner.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
|
||||
const Spinner = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<Loader2
|
||||
className={cn('my-28 h-16 w-16 text-primary/60 animate-spin', className)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export { Spinner };
|
Loading…
x
Reference in New Issue
Block a user