diff --git a/web/src/components/App.tsx b/web/src/components/App.tsx index fe0c6e2..0c42aeb 100644 --- a/web/src/components/App.tsx +++ b/web/src/components/App.tsx @@ -1,10 +1,11 @@ import Notifications from "./Notifications"; import CircleProgressbar from "./CircleProgressbar"; -import { CircularProgress } from "@chakra-ui/react"; +import Progressbar from "./Progressbar"; const App: React.FC = () => { return ( <> + diff --git a/web/src/components/CircleProgressbar.tsx b/web/src/components/CircleProgressbar.tsx index 5b2ad87..4ffb8a4 100644 --- a/web/src/components/CircleProgressbar.tsx +++ b/web/src/components/CircleProgressbar.tsx @@ -13,14 +13,14 @@ interface Props { duration: number; } -debugData([ - { - action: "circleProgress", - data: { - duration: 8000, - }, - }, -]); +// debugData([ +// { +// action: "circleProgress", +// data: { +// duration: 8000, +// }, +// }, +// ]); const CircleProgressbar: React.FC = () => { const [visible, setVisible] = React.useState(false); diff --git a/web/src/components/Progressbar.tsx b/web/src/components/Progressbar.tsx new file mode 100644 index 0000000..4187f80 --- /dev/null +++ b/web/src/components/Progressbar.tsx @@ -0,0 +1,77 @@ +import React from "react"; +import { + Progress, + ProgressLabel, + Flex, + Box, + ScaleFade, +} from "@chakra-ui/react"; +import { useNuiEvent } from "../hooks/useNuiEvent"; +import { debugData } from "../utils/debugData"; +import { fetchNui } from "../utils/fetchNui"; + +interface Props { + label: string; + duration: number; +} + +debugData([ + { + action: "progress", + data: { + label: "Using lockpick", + duration: 8000, + }, + }, +]); + +const Progressbar: React.FC = () => { + const [visible, setVisible] = React.useState(false); + const [label, setLabel] = React.useState(""); + const [duration, setDuration] = React.useState(0); + + const progressComplete = () => { + setVisible(false); + fetchNui("progressComplete"); + }; + + useNuiEvent("progress", (data) => { + if (visible) return; + setVisible(true); + setLabel(data.label); + setDuration(data.duration); + }); + + return ( + + + + div:first-of-type": { + animation: `progress-bar linear ${duration}ms`, + }, + }} + > + {label} + + + + + ); +}; + +export default Progressbar; diff --git a/web/src/index.css b/web/src/index.css index 9cbfc57..3d91f76 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -26,3 +26,12 @@ code { stroke-dasharray: 264, 0; } } + +@keyframes progress-bar { + from { + width: 0%; + } + to { + width: 100%; + } +}