Skip to content

Commit

Permalink
feat(src/app): loading progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm committed Jul 27, 2024
1 parent 39ed601 commit 3521e50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { Box, Stack, Title } from '@mantine/core';
import classes from './index.module.css';
import Media from './components/media/Media';
import Carousel from './components/carousel/Carousel';
import { nprogress, NavigationProgress } from '@mantine/nprogress';

const handlers = {
loadProgress(data : { loadFraction: number }) {
if (data.loadFraction === 1) {
nprogress.complete()
} else {
nprogress.set(data.loadFraction * 100);
}
}
};

window.addEventListener('message', function(event) {
handlers[event.data.eventName as keyof typeof handlers]?.(event.data);
});

export default function App() {
return (
Expand All @@ -11,6 +26,7 @@ export default function App() {
</Stack>
<Carousel />
<Media />
<NavigationProgress />
</Box>
);
}
}
1 change: 1 addition & 0 deletions web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import App from './App';
import './global.css';
import '@mantine/core/styles.css';
import '@mantine/carousel/styles.css';
import '@mantine/nprogress/styles.css';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
Expand Down

0 comments on commit 3521e50

Please sign in to comment.