Skip to content

Commit

Permalink
feat(nprogress): add nprogress package
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamadreza1388 committed Dec 20, 2024
1 parent aaef18f commit dc56e28
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"nprogress": "^0.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^7.0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Editor = () => {

return (<>
<main className={"w-[calc(100%-50px)] h-[calc(100vh-35px)] bg-[#FFF1E9] rounded-tr-[15px] after:inline-block after:border-0 after:z-[-1] after:w-[30px] after:h-[30px] after:bg-[#ffdecc] after:absolute relative after:top-0 after:right-0"}>

</main>
</>)
}
Expand Down
12 changes: 12 additions & 0 deletions src/components/editor/Logo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Link} from "react-router-dom";

const Logo = () => {

return (<>
<Link to={"/"}>
<img src="/images/favicon.svg" alt="salam logo" className={"w-[40px] absolute top-[5px] right-[7px]"}/>
</Link>
</>)
}

export default Logo;
22 changes: 22 additions & 0 deletions src/components/nprogress/RouteChangeHandler.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

const RouteChangeHandler = () => {
const location = useLocation();

useEffect(() => {
NProgress.start();

const timer = setTimeout(() => {
NProgress.done();
}, 300);

return () => clearTimeout(timer);
}, [location]);

return null;
};

export default RouteChangeHandler;
2 changes: 2 additions & 0 deletions src/layouts/EditorLayout.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Header from "../components/header/Header.jsx";
import Side from "../components/sidebar/Side.jsx";
import Editor from "../components/editor/Editor.jsx";
import Logo from "../components/editor/Logo.jsx";

const EditorLayout = () => {

return (<>
<Header />
<Logo />
<Side />
<Editor />
</>)
Expand Down
2 changes: 2 additions & 0 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createRoot } from 'react-dom/client'
import {BrowserRouter, Route, Routes} from "react-router-dom";
import EditorLayout from "./layouts/EditorLayout.jsx";
import RouteChangeHandler from "./components/nprogress/RouteChangeHandler.jsx";

createRoot(document.getElementById('root')).render(<>
<BrowserRouter>
<RouteChangeHandler />
<Routes>
<Route path="/" element={ <EditorLayout /> } />
</Routes>
Expand Down
11 changes: 11 additions & 0 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@
@tailwind utilities;

@layer base {
#nprogress .bar {
background: #29d;
}

#nprogress .peg {
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
}

#nprogress .spinner-icon {
border-top-color: #29d;
border-left-color: #29d;
}
}

0 comments on commit dc56e28

Please sign in to comment.