aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/Sidebar.tsx
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2024-09-09 19:29:42 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2024-09-09 19:29:42 +0300
commit89560a61bc6e41d86acaea596762eda2da38fe50 (patch)
tree1cf4b7c73c17f045d3f4837b480ddf7a61230a94 /frontend/src/components/Sidebar.tsx
parentrefactor: rankings page (diff)
downloadlphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.gz
lphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.bz2
lphub-89560a61bc6e41d86acaea596762eda2da38fe50.zip
refactor: upload run form, lots of random shit
Diffstat (limited to 'frontend/src/components/Sidebar.tsx')
-rw-r--r--frontend/src/components/Sidebar.tsx33
1 files changed, 26 insertions, 7 deletions
diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx
index d303927..22d5c8b 100644
--- a/frontend/src/components/Sidebar.tsx
+++ b/frontend/src/components/Sidebar.tsx
@@ -1,7 +1,7 @@
1import React from 'react'; 1import React from 'react';
2import { Link, useLocation } from 'react-router-dom'; 2import { Link, useLocation } from 'react-router-dom';
3 3
4import { BookIcon, FlagIcon, HelpIcon, HomeIcon, LogoIcon, NewsIcon, PortalIcon, SearchIcon, TableIcon } from '../images/Images'; 4import { BookIcon, FlagIcon, HelpIcon, HomeIcon, LogoIcon, PortalIcon, SearchIcon, UploadIcon } from '../images/Images';
5import Login from './Login'; 5import Login from './Login';
6import { UserProfile } from '../types/Profile'; 6import { UserProfile } from '../types/Profile';
7import { Search } from '../types/Search'; 7import { Search } from '../types/Search';
@@ -12,9 +12,10 @@ interface SidebarProps {
12 setToken: React.Dispatch<React.SetStateAction<string | undefined>>; 12 setToken: React.Dispatch<React.SetStateAction<string | undefined>>;
13 profile?: UserProfile; 13 profile?: UserProfile;
14 setProfile: React.Dispatch<React.SetStateAction<UserProfile | undefined>>; 14 setProfile: React.Dispatch<React.SetStateAction<UserProfile | undefined>>;
15 onUploadRun: () => void;
15}; 16};
16 17
17const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => { 18const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile, onUploadRun }) => {
18 19
19 const [searchData, setSearchData] = React.useState<Search | undefined>(undefined); 20 const [searchData, setSearchData] = React.useState<Search | undefined>(undefined);
20 const [isSidebarLocked, setIsSidebarLocked] = React.useState<boolean>(false); 21 const [isSidebarLocked, setIsSidebarLocked] = React.useState<boolean>(false);
@@ -40,11 +41,19 @@ const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => {
40 const span = document.querySelectorAll("button.sidebar-button>span") as NodeListOf<HTMLElement> 41 const span = document.querySelectorAll("button.sidebar-button>span") as NodeListOf<HTMLElement>
41 const side = document.querySelector("#sidebar-list") as HTMLElement; 42 const side = document.querySelector("#sidebar-list") as HTMLElement;
42 const searchbar = document.querySelector("#searchbar") as HTMLInputElement; 43 const searchbar = document.querySelector("#searchbar") as HTMLInputElement;
44 const uploadRunBtn = document.querySelector("#upload-run") as HTMLInputElement;
45 const uploadRunSpan = document.querySelector("#upload-run>span") as HTMLInputElement;
43 46
44 if (isSidebarOpen) { 47 if (isSidebarOpen) {
45 if (profile) { 48 if (profile) {
46 const login = document.querySelectorAll(".login>button")[1] as HTMLElement; 49 const login = document.querySelectorAll(".login>button")[1] as HTMLElement;
47 login.style.opacity = "1" 50 login.style.opacity = "1"
51 uploadRunBtn.style.width = "310px"
52 uploadRunBtn.style.padding = "0.4em 0 0 11px"
53 uploadRunSpan.style.opacity = "0"
54 setTimeout(() => {
55 uploadRunSpan.style.opacity = "1"
56 }, 100)
48 } 57 }
49 setSidebarOpen(false); 58 setSidebarOpen(false);
50 side.style.width = "320px" 59 side.style.width = "320px"
@@ -54,14 +63,17 @@ const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => {
54 setTimeout(() => { 63 setTimeout(() => {
55 span[i].style.opacity = "1" 64 span[i].style.opacity = "1"
56 }, 100) 65 }, 100)
57 }) 66 });
58 side.style.zIndex = "2" 67 side.style.zIndex = "2"
59 } else { 68 } else {
60 if (profile) { 69 if (profile) {
61 const login = document.querySelectorAll(".login>button")[1] as HTMLElement; 70 const login = document.querySelectorAll(".login>button")[1] as HTMLElement;
62 login.style.opacity = "0" 71 login.style.opacity = "0"
72 uploadRunBtn.style.width = "40px"
73 uploadRunBtn.style.padding = "0.4em 0 0 5px"
74 uploadRunSpan.style.opacity = "0"
63 } 75 }
64 setSidebarOpen(true) 76 setSidebarOpen(true);
65 side.style.width = "40px"; 77 side.style.width = "40px";
66 searchbar.focus(); 78 searchbar.focus();
67 btn.forEach((e, i) => { 79 btn.forEach((e, i) => {
@@ -106,7 +118,7 @@ const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => {
106 <img src={LogoIcon} alt="" height={"80px"} /> 118 <img src={LogoIcon} alt="" height={"80px"} />
107 <div id='logo-text'> 119 <div id='logo-text'>
108 <span><b>PORTAL 2</b></span><br /> 120 <span><b>PORTAL 2</b></span><br />
109 <span>Least Portals</span> 121 <span>Least Portals Hub</span>
110 </div> 122 </div>
111 </div> 123 </div>
112 </Link> 124 </Link>
@@ -140,14 +152,21 @@ const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => {
140 <div id='sidebar-bottomlist'> 152 <div id='sidebar-bottomlist'>
141 <span></span> 153 <span></span>
142 154
155 {
156 profile ?
157 <button id='upload-run' className='submit-run-button' onClick={() => onUploadRun()}><img src={UploadIcon} alt="upload" /><span>Submit&nbsp;a&nbsp;Run</span></button>
158 :
159 <span></span>
160 }
161
143 <Login setToken={setToken} profile={profile} setProfile={setProfile} /> 162 <Login setToken={setToken} profile={profile} setProfile={setProfile} />
144 163
145 <Link to="/rules" tabIndex={-1}> 164 <Link to="/rules" tabIndex={-1}>
146 <button className='sidebar-button'><img src={BookIcon} alt="leaderboardrules" /><span>Leaderboard&nbsp;Rules</span></button> 165 <button className='sidebar-button'><img src={BookIcon} alt="rules" /><span>Leaderboard&nbsp;Rules</span></button>
147 </Link> 166 </Link>
148 167
149 <Link to="/about" tabIndex={-1}> 168 <Link to="/about" tabIndex={-1}>
150 <button className='sidebar-button'><img src={HelpIcon} alt="aboutp2lp" /><span>About&nbsp;P2LP</span></button> 169 <button className='sidebar-button'><img src={HelpIcon} alt="about" /><span>About&nbsp;LPHUB</span></button>
151 </Link> 170 </Link>
152 </div> 171 </div>
153 </div> 172 </div>