diff options
| author | Nidboj132 <lol2s@vp.pl> | 2023-05-06 16:17:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-06 16:17:52 +0200 |
| commit | 5e29c7e9d65f77c0597d81de611a89268cadef1c (patch) | |
| tree | 4d04c0cdea26e0e497134b99c0e34a7d9d478f34 /frontend/src/components/sidebar.js | |
| parent | fix: allow credentials cors (diff) | |
| parent | Merge branch 'pektezol:main' into main (diff) | |
| download | lphub-5e29c7e9d65f77c0597d81de611a89268cadef1c.tar.gz lphub-5e29c7e9d65f77c0597d81de611a89268cadef1c.tar.bz2 lphub-5e29c7e9d65f77c0597d81de611a89268cadef1c.zip | |
Merge pull request #41 from Nidboj132/main
login test
Diffstat (limited to 'frontend/src/components/sidebar.js')
| -rw-r--r-- | frontend/src/components/sidebar.js | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index d5a55fd..aaaf196 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -13,8 +13,9 @@ import img6 from "../imgs/6.png" | |||
| 13 | import img7 from "../imgs/7.png" | 13 | import img7 from "../imgs/7.png" |
| 14 | import img8 from "../imgs/8.png" | 14 | import img8 from "../imgs/8.png" |
| 15 | import img9 from "../imgs/9.png" | 15 | import img9 from "../imgs/9.png" |
| 16 | import Login from "./login.js" | ||
| 16 | 17 | ||
| 17 | export default function Sidebar(x) { | 18 | export default function Sidebar() { |
| 18 | 19 | ||
| 19 | // Locks search button for 300ms before it can be clicked again, prevents spam | 20 | // Locks search button for 300ms before it can be clicked again, prevents spam |
| 20 | const [isLocked, setIsLocked] = React.useState(false); | 21 | const [isLocked, setIsLocked] = React.useState(false); |
| @@ -48,13 +49,18 @@ function SidebarHide(){ | |||
| 48 | const btn = document.querySelectorAll("button"); | 49 | const btn = document.querySelectorAll("button"); |
| 49 | const span = document.querySelectorAll("button>span"); | 50 | const span = document.querySelectorAll("button>span"); |
| 50 | const side = document.querySelector("#sidebar-list"); | 51 | const side = document.querySelector("#sidebar-list"); |
| 52 | const login = document.querySelectorAll(".login>button")[1]; | ||
| 51 | 53 | ||
| 52 | if(sidebar===1){ | 54 | if(sidebar===1){ |
| 53 | setSidebar(0) | 55 | setSidebar(0) |
| 54 | side.style.width="320px" | 56 | side.style.width="320px" |
| 55 | btn.forEach((e, i) =>{ | 57 | btn.forEach((e, i) =>{ |
| 56 | e.style.width="310px" | 58 | e.style.width="310px" |
| 57 | setTimeout(() => {span[i].style.opacity="1"}, 100) | 59 | setTimeout(() => { |
| 60 | span[i].style.opacity="1" | ||
| 61 | login.style.opacity="1" | ||
| 62 | |||
| 63 | }, 100) | ||
| 58 | }) | 64 | }) |
| 59 | side.style.zIndex="2" | 65 | side.style.zIndex="2" |
| 60 | } else { | 66 | } else { |
| @@ -64,10 +70,14 @@ if(sidebar===1){ | |||
| 64 | e.style.width="40px" | 70 | e.style.width="40px" |
| 65 | span[i].style.opacity="0" | 71 | span[i].style.opacity="0" |
| 66 | }) | 72 | }) |
| 67 | setTimeout(() => {side.style.zIndex="0"}, 300); | 73 | login.style.opacity="0" |
| 74 | setTimeout(() => { | ||
| 75 | side.style.zIndex="0" | ||
| 76 | }, 300); | ||
| 68 | } | 77 | } |
| 69 | } | 78 | } |
| 70 | 79 | ||
| 80 | // Links | ||
| 71 | const location = useLocation() | 81 | const location = useLocation() |
| 72 | React.useEffect(()=>{ | 82 | React.useEffect(()=>{ |
| 73 | if(location.pathname==="/"){SidebarClick(1)} | 83 | if(location.pathname==="/"){SidebarClick(1)} |
| @@ -77,12 +87,14 @@ React.useEffect(()=>{ | |||
| 77 | if(location.pathname.includes("discussions")){SidebarClick(5)} | 87 | if(location.pathname.includes("discussions")){SidebarClick(5)} |
| 78 | if(location.pathname.includes("scorelog")){SidebarClick(6)} | 88 | if(location.pathname.includes("scorelog")){SidebarClick(6)} |
| 79 | if(location.pathname.includes("profile")){SidebarClick(7)} | 89 | if(location.pathname.includes("profile")){SidebarClick(7)} |
| 80 | if(location.pathname.includes("rules")){SidebarClick(8)} | 90 | if(location.pathname.includes("rules")){SidebarClick(9)} |
| 81 | if(location.pathname.includes("about")){SidebarClick(9)} | 91 | if(location.pathname.includes("about")){SidebarClick(10)} |
| 92 | |||
| 82 | // console.log(location.pathname) | 93 | // console.log(location.pathname) |
| 83 | // eslint-disable-next-line react-hooks/exhaustive-deps | 94 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 84 | }, [location]) | 95 | }, [location]) |
| 85 | 96 | ||
| 97 | |||
| 86 | return ( | 98 | return ( |
| 87 | <div id='sidebar'> | 99 | <div id='sidebar'> |
| 88 | <div id='logo'> {/* logo */} | 100 | <div id='logo'> {/* logo */} |
| @@ -124,9 +136,7 @@ return ( | |||
| 124 | <div id='sidebar-bottomlist'> | 136 | <div id='sidebar-bottomlist'> |
| 125 | <span></span> | 137 | <span></span> |
| 126 | 138 | ||
| 127 | <Link to="/profile" tabIndex={-1}> | 139 | <Login/> |
| 128 | <button><img src={img1} alt="" /><span>Login</span></button> | ||
| 129 | </Link> | ||
| 130 | 140 | ||
| 131 | <Link to="/rules" tabIndex={-1}> | 141 | <Link to="/rules" tabIndex={-1}> |
| 132 | <button><img src={img8} alt="" /><span>Leaderboard Rules</span></button> | 142 | <button><img src={img8} alt="" /><span>Leaderboard Rules</span></button> |