From da7c988469ce2c3e17173f72416808ddb355d224 Mon Sep 17 00:00:00 2001 From: Nidboj132 Date: Sat, 29 Apr 2023 13:00:05 +0200 Subject: ui update --- frontend/src/components/sidebar.js | 148 +++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 48 deletions(-) (limited to 'frontend/src/components/sidebar.js') diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index 0bc5a1e..d5a55fd 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js @@ -1,7 +1,9 @@ import React from 'react'; +import { Link, useLocation } from "react-router-dom"; +import "../App.css" import "./sidebar.css"; -import img0 from "../imgs/0.png" +import logo from "../imgs/logo.png" import img1 from "../imgs/1.png" import img2 from "../imgs/2.png" import img3 from "../imgs/3.png" @@ -10,19 +12,16 @@ import img5 from "../imgs/5.png" import img6 from "../imgs/6.png" import img7 from "../imgs/7.png" import img8 from "../imgs/8.png" +import img9 from "../imgs/9.png" +export default function Sidebar(x) { -export default function Sidebar() { -const sidebar_text = ['Home\u00A0page',"Profile","News","Records","Discussions","Leaderboards","Score\u00A0log"] // text on the buttons -const [sidebar, setSidebar] = React.useState(); - - -// Locks button for 200ms before it can be clicked again, prevents spam +// Locks search button for 300ms before it can be clicked again, prevents spam const [isLocked, setIsLocked] = React.useState(false); function HandleLock(arg) { if (!isLocked) { setIsLocked(true); - setTimeout(() => setIsLocked(false), 200); + setTimeout(() => setIsLocked(false), 300); SidebarHide(arg) } } @@ -30,66 +29,119 @@ if (!isLocked) { // Clicked buttons function SidebarClick(x){ -const btn = document.querySelectorAll("button#side-grid"); +const btn = document.querySelectorAll("button"); +if(sidebar===1){setSidebar(0);SidebarHide()} -sidebar_text.forEach((e,i) =>( - btn[i].style.backgroundColor="#202232", - btn[i].style.borderRadius="20px" -)) +btn.forEach((e,i) =>{ + btn[i].style.backgroundColor="inherit" +}) +btn[x].style.backgroundColor="#202232" -btn[x].style.backgroundColor="#141520" -btn[x].style.borderRadius="10px" } // The menu button +const [sidebar, setSidebar] = React.useState(); + function SidebarHide(){ -const btn = document.querySelectorAll("button#side-grid"); -const span = document.querySelectorAll("#side-grid>span"); +const btn = document.querySelectorAll("button"); +const span = document.querySelectorAll("button>span"); const side = document.querySelector("#sidebar-list"); if(sidebar===1){ setSidebar(0) - side.style.width="308px" - sidebar_text.forEach((e, i) =>( - btn[i].style.width="300px", - setTimeout(() => {span[i].style.opacity="1";span[i].textContent=e}, 200) - )) + side.style.width="320px" + btn.forEach((e, i) =>{ + e.style.width="310px" + setTimeout(() => {span[i].style.opacity="1"}, 100) + }) + side.style.zIndex="2" } else { side.style.width="40px"; setSidebar(1) - sidebar_text.forEach((e,i) =>( - btn[i].style.width="40px", - span[i].style.opacity="0", - setTimeout(() => {span[i].textContent=""}, 100) - )) + btn.forEach((e,i) =>{ + e.style.width="40px" + span[i].style.opacity="0" + }) + setTimeout(() => {side.style.zIndex="0"}, 300); } } -return ( -