From 4f6fc6abafeaf217e37e60df5184ac4833117ca8 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 18 Dec 2022 13:17:42 +0100 Subject: [PATCH] refactor(web/progress): progress bar mantine rewrite --- web/src/features/progress/Progressbar.tsx | 94 +++++++++++------------ 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/web/src/features/progress/Progressbar.tsx b/web/src/features/progress/Progressbar.tsx index 9cc5408..72b8e3e 100644 --- a/web/src/features/progress/Progressbar.tsx +++ b/web/src/features/progress/Progressbar.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Text, Flex, Box } from '@chakra-ui/react'; +import { Progress, Box, Text, createStyles } from '@mantine/core'; import { useNuiEvent } from '../../hooks/useNuiEvent'; import { fetchNui } from '../../utils/fetchNui'; @@ -8,7 +8,38 @@ export interface ProgressbarProps { duration: number; } +const useStyles = createStyles((theme) => ({ + container: { + width: 350, + height: 45, + position: 'absolute', + bottom: '15%', + left: '50%', + transform: 'translate(-50%)', + borderRadius: theme.radius.xs, + backgroundColor: 'rgba(0, 0, 0, 0.5)', + }, + bar: { + height: '100%', + borderRadius: theme.radius.xs, + backgroundColor: theme.colors[theme.primaryColor][theme.fn.primaryShade()], + }, + label: { + maxWidth: 350, + padding: 8, + textOverflow: 'ellipsis', + overflow: 'hidden', + whiteSpace: 'nowrap', + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + fontSize: 20, + }, +})); + const Progressbar: React.FC = () => { + const { classes } = useStyles(); const [visible, setVisible] = React.useState(false); const [label, setLabel] = React.useState(''); const [duration, setDuration] = React.useState(0); @@ -34,55 +65,20 @@ const Progressbar: React.FC = () => { }); return ( - - - {visible && ( - - - - {label} - - - )} + <> + + + {label} - + ); };