Skip to content

Commit

Permalink
Add NProgress for loading indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Dec 30, 2024
1 parent 30eac98 commit 6582dda
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
14 changes: 14 additions & 0 deletions frontend/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 frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/leaflet": "^1.9.15",
"@types/leaflet-boundary-canvas": "^1.0.3",
"@types/node": "^22.10.2",
"@types/nprogress": "^0.2.3",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@types/react-google-recaptcha": "^2.1.9",
Expand All @@ -46,6 +47,7 @@
"history": "^5.3.0",
"leaflet": "^1.9.4",
"leaflet-boundary-canvas": "^1.0.0",
"nprogress": "^0.2.0",
"react": "^19.0.0",
"react-circle-flags": "^0.0.23",
"react-dom": "^19.0.0",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UserProvider } from '@/context/UserContext'
import { RecaptchaProvider } from '@/context/RecaptchaContext'
import { init as initGA } from '@/common/ga4'
import ScrollToTop from '@/components/ScrollToTop'
import NProgressIndicator from '@/components/NProgressIndicator'

if (env.GOOGLE_ANALYTICS_ENABLED) {
initGA()
Expand Down Expand Up @@ -42,7 +43,7 @@ const App = () => (
<ScrollToTop />

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

<Routes>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
display: none !important;
}

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

.bold {
font-weight: 500 !important;
}
Expand Down
19 changes: 19 additions & 0 deletions frontend/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 6582dda

Please sign in to comment.