Skip to content

Commit

Permalink
Добавил рабочий прогресс бар
Browse files Browse the repository at this point in the history
  • Loading branch information
semant1cs committed Dec 12, 2023
1 parent 2f9bd86 commit 087f64d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 47 deletions.
21 changes: 2 additions & 19 deletions frontend/package-lock.json

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

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"mobx": "^6.11.0",
"mobx-react-lite": "^4.0.5",
"mobx-state-tree": "^5.3.0",
"progressbar.js": "^1.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.0",
Expand Down
41 changes: 22 additions & 19 deletions frontend/src/UIComponents/CustomProgressBar/CustomProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import React, {useEffect} from 'react';
import ProgressBar from "progressbar.js";
import React, {useEffect, useState} from 'react';
import "./customProgressBar.scss"

interface IPropTypes {
containerName: string;
progress: number;
}

const CustomProgressBar: React.FC<IPropTypes> = ({containerName}) => {
const CustomProgressBar: React.FC<IPropTypes> = ({progress}) => {

const [filled, setFilled] = useState(0);
useEffect(() => {
const container = document.querySelector(`#${containerName}`);
console.log(container)

if (container && container.children.length === 0) {
new ProgressBar.Line(`#${containerName}`, {
strokeWidth: 4,
easing: 'easeInOut',
duration: 1400,
color: '#FFEA82',
trailColor: '#eee',
trailWidth: 1,
svgStyle: {width: '100%', height: '100%'}
});
if (filled < progress) {
if (filled > progress - 5) {
setFilled(progress);
} else setTimeout(() => setFilled(prev => prev + 5), 10)
}
}, [containerName])
}, [filled, progress])

return (
<div id={`#${containerName}`}></div>
<div>
<div className="progressbar">
<div style=
{{
height: "100%",
width: `${filled}%`,
backgroundColor: "#00D29D",
transition: "width 0.5s"
}}></div>
<span className="progressPercent">{filled}%</span>
</div>
</div>
);
};

Expand Down
19 changes: 19 additions & 0 deletions frontend/src/UIComponents/CustomProgressBar/customProgressBar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.progressbar {
position: relative;
overflow: hidden;
width: 350px;
height: 30px;
border-radius: 5px;
background-color: #eee;
}

.progressPercent {
font-weight: 600;
position: absolute;
left: 50%;
top: 50%;
font-size: 24px;
transform: translate(-50%, -50%);
color: #eee;
text-shadow: -1px 0 #555, 0 1px #555, 1px 0 #555, 0 -1px #555;
}
4 changes: 0 additions & 4 deletions frontend/src/components/authentication/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {observer} from "mobx-react-lite";
import authStore from "../../store/authStore.ts";
import auth from "../../utils/auth.ts";
import Starfield from "react-starfield";
import CustomProgressBar from "../../UIComponents/CustomProgressBar/CustomProgressBar.tsx";

export type FormValues = {
login: string,
Expand Down Expand Up @@ -75,9 +74,6 @@ const AuthForm: React.FC = observer(() => {
/>

<input type="submit" className="auth__btn" value="ВОЙТИ"/>
<div id="user-progress">
<CustomProgressBar containerName="user-progress"/>
</div>
</form>
</div>
);
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/components/mapMenu/EmployeeMap/EmployeeMap.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React, {useEffect} from 'react';

import Coins from "../UIMapMenu/Coins.tsx";
import ChooseModuleWindow from "../UIMapMenu/ChooseModuleWindow.tsx";
import mapMenuStore from "../../../store/mapMenuStore.ts";
import UserProfile from "../UIMapMenu/UserProfile/UserProfile.tsx";
import CustomProgressBar from "../../../UIComponents/CustomProgressBar/CustomProgressBar.tsx";
import Level from "../UIMapMenu/Level/Level.tsx";
import {IUserType} from "../../../types/UserType.ts";
import {observer} from "mobx-react-lite";

import mapMenuStore from "../../../store/mapMenuStore.ts";
import moduleMenuStore from "../../../store/moduleMenuStore.ts";
import {observer} from "mobx-react-lite";

import {IUserType} from "../../../types/UserType.ts";

interface IEmployeeMap {
user?: IUserType,
Expand All @@ -33,6 +37,7 @@ const EmployeeMap: React.FC<IEmployeeMap> = observer(({user, formattedDate}) =>
<Coins coins={100} additionalClassname="coins"/>
<ChooseModuleWindow moduleName={moduleMenuStore.currentModule?.title}/>
<UserProfile user={user} formattedDate={formattedDate}/>
<div className="progress-bar-wrapper"><CustomProgressBar progress={54}/></div>
<div className="geolocations">
<div className="geolocations__wrapper">
{mapMenuStore.availableLevels.map((level, index) => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/welcomePage/WelcomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import {useNavigate} from "react-router-dom";
import './../../styles/welcomePage.scss'
import CustomButton from "../../UIComponents/customButton/CustomButton.tsx";

import './../../styles/welcomePage.scss'

import Starfield from "react-starfield";

const WelcomePage: React.FC = () => {
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/styles/mapMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,9 @@
.achievement-image {
margin-top: 10px;
}

.progress-bar-wrapper {
position: absolute;
right: 10%;
top: 5%;
}

0 comments on commit 087f64d

Please sign in to comment.