Skip to content

Commit

Permalink
Add NProgress loading indicator to admin dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Feb 4, 2025
1 parent 8372960 commit d2228ae
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
14 changes: 14 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@types/draftjs-to-html": "^0.8.4",
"@types/html-to-draftjs": "^1.5.0",
"@types/node": "^22.13.0",
"@types/nprogress": "^0.2.3",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@types/react-draft-wysiwyg": "^1.13.8",
Expand All @@ -44,6 +45,7 @@
"history": "^5.3.0",
"html-to-draftjs": "^1.5.0",
"localized-strings": "^2.0.3",
"nprogress": "^0.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-draft-wysiwyg": "^1.15.0",
Expand Down
3 changes: 2 additions & 1 deletion backend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { GlobalProvider } from '@/context/GlobalContext'
import { UserProvider } from '@/context/UserContext'
import ScrollToTop from '@/components/ScrollToTop'
import NProgressIndicator from '@/components/NProgressIndicator'

const Header = lazy(() => import('@/components/Header'))
const SignIn = lazy(() => import('@/pages/SignIn'))
Expand Down Expand Up @@ -48,7 +49,7 @@ const App = () => (
<ScrollToTop />

<div className="app">
<Suspense fallback={<></>}>
<Suspense fallback={<NProgressIndicator />}>
<Header />

<Routes>
Expand Down
4 changes: 4 additions & 0 deletions backend/src/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
--toastify-icon-color-info: #fff !important;
}

#nprogress .bar {
background: #1a1a1a !important;
}

.buttons button {
margin-right: 15px;
margin-left: 0 !important;
Expand Down
19 changes: 19 additions & 0 deletions backend/src/components/NProgressIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useEffect } from 'react'
import NProgress from 'nprogress'

import 'nprogress/nprogress.css'

const NProgressIndicator = () => {
useEffect(() => {
NProgress.configure({ showSpinner: false })
NProgress.start()

return () => {
NProgress.done()
}
}, [])

return null
}

export default NProgressIndicator

0 comments on commit d2228ae

Please sign in to comment.