diff options
Diffstat (limited to 'frontend/src/components/Sidebar.tsx')
| -rw-r--r-- | frontend/src/components/Sidebar.tsx | 33 |
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 @@ | |||
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import { Link, useLocation } from 'react-router-dom'; | 2 | import { Link, useLocation } from 'react-router-dom'; |
| 3 | 3 | ||
| 4 | import { BookIcon, FlagIcon, HelpIcon, HomeIcon, LogoIcon, NewsIcon, PortalIcon, SearchIcon, TableIcon } from '../images/Images'; | 4 | import { BookIcon, FlagIcon, HelpIcon, HomeIcon, LogoIcon, PortalIcon, SearchIcon, UploadIcon } from '../images/Images'; |
| 5 | import Login from './Login'; | 5 | import Login from './Login'; |
| 6 | import { UserProfile } from '../types/Profile'; | 6 | import { UserProfile } from '../types/Profile'; |
| 7 | import { Search } from '../types/Search'; | 7 | import { 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 | ||
| 17 | const Sidebar: React.FC<SidebarProps> = ({ setToken, profile, setProfile }) => { | 18 | const 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 a 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 Rules</span></button> | 165 | <button className='sidebar-button'><img src={BookIcon} alt="rules" /><span>Leaderboard 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 P2LP</span></button> | 169 | <button className='sidebar-button'><img src={HelpIcon} alt="about" /><span>About LPHUB</span></button> |
| 151 | </Link> | 170 | </Link> |
| 152 | </div> | 171 | </div> |
| 153 | </div> | 172 | </div> |