Skip to content

Commit

Permalink
Add nprogress
Browse files Browse the repository at this point in the history
  • Loading branch information
kielbasa-elp committed Feb 23, 2024
1 parent 8e09567 commit 2fc6211
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
18 changes: 18 additions & 0 deletions apps/web-remix/app/components/progressBar/PageProgress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { useEffect } from "react";
import { useNavigation } from "@remix-run/react";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
import "./pageProgress.css";

NProgress.configure({ showSpinner: false });

export const PageProgress: React.FC = () => {
const { state } = useNavigation();

useEffect(() => {
if (state === "loading") NProgress.start();
if (state === "idle") NProgress.done();
}, [state]);

return null;
};
11 changes: 11 additions & 0 deletions apps/web-remix/app/components/progressBar/pageProgress.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#nprogress .bar{
@apply !bg-primary-500 !h-[1.5px]
}

#nprogress .spinner-icon{
@apply !border-t-primary-600 !border-l-primary-600
}

#nprogress .peg{
@apply !shadow-xl !shadow-primary-500
}
4 changes: 3 additions & 1 deletion apps/web-remix/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { withSentry } from "@sentry/remix";
import type { LinksFunction } from "@remix-run/node";
import Modal from "react-modal";
import {
isRouteErrorResponse,
Links,
Expand All @@ -13,7 +14,7 @@ import { Toaster } from "~/components/toasts/Toaster";
import "./tailwind.css";
import { GlobalNotFound } from "~/components/errorBoundaries/GlobalNotFound";
import { GlobalRuntime } from "~/components/errorBoundaries/GlobalRuntime";
import Modal from "react-modal";
import { PageProgress } from "~/components/progressBar/PageProgress";

Modal.setAppElement("#_root");

Expand Down Expand Up @@ -50,6 +51,7 @@ function App() {
</head>
<body className="bg-neutral-950">
<Toaster />
<PageProgress />
<Outlet />
<ScrollRestoration />
<Scripts />
Expand Down
2 changes: 1 addition & 1 deletion apps/web-remix/app/routes/_dashboard.$organizationId.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Avatar, Button, Icon, IconButton } from "@elpassion/taco";
import { DataFunctionArgs, json, LoaderFunctionArgs } from "@remix-run/node";
import { json, LoaderFunctionArgs } from "@remix-run/node";
import {
Link,
Outlet,
Expand Down
2 changes: 2 additions & 0 deletions apps/web-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"lru-cache": "^10.2.0",
"markdown-to-jsx": "^7.4.1",
"morgan": "^1.10.0",
"nprogress": "^0.2.0",
"phoenix": "^1.7.7",
"rc-menu": "^9.12.0",
"rc-select": "^14.11.0",
Expand Down Expand Up @@ -89,6 +90,7 @@
"@types/lodash.merge": "^4.6.7",
"@types/lodash.startcase": "^4.4.7",
"@types/morgan": "^1.9.5",
"@types/nprogress": "^0.2.3",
"@types/phoenix": "^1.6.0",
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
Expand Down
14 changes: 14 additions & 0 deletions apps/web-remix/pnpm-lock.yaml

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

0 comments on commit 2fc6211

Please sign in to comment.