diff options
| author | Nidboj132 <28981031+Nidboj132@users.noreply.github.com> | 2023-09-22 22:56:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 22:56:11 +0200 |
| commit | 93e2c912b50e5a8a5dc4048568cafdfed606e93e (patch) | |
| tree | 0b5f3e805120e9f98aa509d39c1c04ef78bc5e95 /frontend | |
| parent | docs: update search response (#77) (diff) | |
| download | lphub-93e2c912b50e5a8a5dc4048568cafdfed606e93e.tar.gz lphub-93e2c912b50e5a8a5dc4048568cafdfed606e93e.tar.bz2 lphub-93e2c912b50e5a8a5dc4048568cafdfed606e93e.zip | |
feat: map search (#78)
Former-commit-id: 660e8bfcde4b850abb3820e209af3def2353fd51
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/src/components/pages/summary.js | 3 | ||||
| -rw-r--r-- | frontend/src/components/sidebar.css | 72 | ||||
| -rw-r--r-- | frontend/src/components/sidebar.js | 34 |
3 files changed, 103 insertions, 6 deletions
diff --git a/frontend/src/components/pages/summary.js b/frontend/src/components/pages/summary.js index 4758c8e..c03d7b9 100644 --- a/frontend/src/components/pages/summary.js +++ b/frontend/src/components/pages/summary.js | |||
| @@ -28,7 +28,7 @@ const fakedata={} //for debug | |||
| 28 | if(d.data.summary.routes.length===0){d.data.summary.routes[0]={"category": "","history": {"score_count": 0,},"rating": 0,"description": "","showcase": ""}} | 28 | if(d.data.summary.routes.length===0){d.data.summary.routes[0]={"category": "","history": {"score_count": 0,},"rating": 0,"description": "","showcase": ""}} |
| 29 | }) | 29 | }) |
| 30 | // eslint-disable-next-line | 30 | // eslint-disable-next-line |
| 31 | }, []); | 31 | }, [location.pathname]); |
| 32 | 32 | ||
| 33 | const [pageNumber, setPageNumber] = React.useState(1); | 33 | const [pageNumber, setPageNumber] = React.useState(1); |
| 34 | const [lbData, setLbData] = React.useState(null); | 34 | const [lbData, setLbData] = React.useState(null); |
| @@ -438,7 +438,6 @@ return ( | |||
| 438 | <button onClick={()=>window.location.href=`https://lp.ardapektezol.com/api/v1/demos?uuid=${r.demo_id}`}><img src={img12} alt="download" /></button> | 438 | <button onClick={()=>window.location.href=`https://lp.ardapektezol.com/api/v1/demos?uuid=${r.demo_id}`}><img src={img12} alt="download" /></button> |
| 439 | </span> | 439 | </span> |
| 440 | )} | 440 | )} |
| 441 | {console.log(lbData)} | ||
| 442 | </span> | 441 | </span> |
| 443 | ))} | 442 | ))} |
| 444 | </div> | 443 | </div> |
diff --git a/frontend/src/components/sidebar.css b/frontend/src/components/sidebar.css index 8011a6e..29978db 100644 --- a/frontend/src/components/sidebar.css +++ b/frontend/src/components/sidebar.css | |||
| @@ -118,4 +118,74 @@ input#searchbar[type=text]{ | |||
| 118 | } | 118 | } |
| 119 | input[type=text]::placeholder{color:#2b2e46} | 119 | input[type=text]::placeholder{color:#2b2e46} |
| 120 | input[type=text]:focus{outline: inherit;} | 120 | input[type=text]:focus{outline: inherit;} |
| 121 | a{text-decoration: none;height: 40px;} \ No newline at end of file | 121 | a{text-decoration: none;height: 40px;} |
| 122 | |||
| 123 | |||
| 124 | #search-data{ | ||
| 125 | margin: 8px 0 8px 0; | ||
| 126 | overflow-y: auto; | ||
| 127 | max-height: calc(100vh - 172px); | ||
| 128 | } | ||
| 129 | #search-data::-webkit-scrollbar{display: none;} | ||
| 130 | .search-map{ | ||
| 131 | margin: 10px 6px 0 6px; | ||
| 132 | height: 80px; | ||
| 133 | |||
| 134 | border-radius: 20px; | ||
| 135 | text-align: center; | ||
| 136 | |||
| 137 | display: grid; | ||
| 138 | |||
| 139 | border: 0; | ||
| 140 | transition: background-color .1s; | ||
| 141 | background-color: #2b2e46; | ||
| 142 | grid-template-rows: 20% 20% 60%; | ||
| 143 | } | ||
| 144 | .search-map>span{ | ||
| 145 | color: #888; | ||
| 146 | font-size: 16px; | ||
| 147 | font-family: BarlowSemiCondensed-Regular; | ||
| 148 | } | ||
| 149 | .search-map>span:nth-child(3){ | ||
| 150 | font-size: 30px; | ||
| 151 | color: #CDCFDF; | ||
| 152 | } | ||
| 153 | |||
| 154 | .search-player{ | ||
| 155 | overflow: hidden; | ||
| 156 | margin: 10px 6px 0 6px; | ||
| 157 | height: 80px; | ||
| 158 | |||
| 159 | border-radius: 20px; | ||
| 160 | text-align: center; | ||
| 161 | color: #CDCFDF; | ||
| 162 | font-family: BarlowSemiCondensed-Regular; | ||
| 163 | |||
| 164 | display: grid; | ||
| 165 | place-items: center; | ||
| 166 | grid-template-columns: 20% 80%; | ||
| 167 | padding: 0 16px 0 16px; | ||
| 168 | |||
| 169 | border: 0; | ||
| 170 | transition: background-color .1s; | ||
| 171 | background-color: #2b2e46; | ||
| 172 | } | ||
| 173 | .search-player>img{ | ||
| 174 | height: 60px; | ||
| 175 | border-radius: 20px; | ||
| 176 | } | ||
| 177 | .search-player>span{ | ||
| 178 | width:154px; | ||
| 179 | font-size: 26px; | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 | |||
| 186 | |||
| 187 | |||
| 188 | |||
| 189 | |||
| 190 | |||
| 191 | |||
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index 77800bd..d9b8012 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -91,9 +91,17 @@ React.useEffect(()=>{ | |||
| 91 | if(location.pathname.includes("rules")){SidebarClick(9)} | 91 | if(location.pathname.includes("rules")){SidebarClick(9)} |
| 92 | if(location.pathname.includes("about")){SidebarClick(10)} | 92 | if(location.pathname.includes("about")){SidebarClick(10)} |
| 93 | 93 | ||
| 94 | // console.log(location.pathname) | ||
| 95 | // eslint-disable-next-line react-hooks/exhaustive-deps | 94 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 96 | }, [location]) | 95 | }, [location.pathname]) |
| 96 | |||
| 97 | const [search,setSearch] = React.useState(null) | ||
| 98 | const [searchData,setSearchData] = React.useState(null) | ||
| 99 | React.useEffect(()=>{ | ||
| 100 | fetch(`https://lp.ardapektezol.com/api/v1/search?q=${search}`) | ||
| 101 | .then(r=>r.json()) | ||
| 102 | .then(d=>setSearchData(d.data)) | ||
| 103 | |||
| 104 | }, [search]) | ||
| 97 | 105 | ||
| 98 | 106 | ||
| 99 | return ( | 107 | return ( |
| @@ -151,7 +159,27 @@ return ( | |||
| 151 | </div> | 159 | </div> |
| 152 | </div> | 160 | </div> |
| 153 | <div> | 161 | <div> |
| 154 | <input type="text" id='searchbar' placeholder='Search for map or a player...'/> | 162 | <input type="text" id='searchbar' placeholder='Search for map or a player...' onChange={()=>setSearch(document.querySelector("#searchbar").value)}/> |
| 163 | |||
| 164 | <div id='search-data'> | ||
| 165 | |||
| 166 | {searchData!==null?searchData.maps.map((q,index)=>( | ||
| 167 | <Link to={`/maps/${q.id}`} className='search-map' key={index}> | ||
| 168 | <span>{q.game}</span> | ||
| 169 | <span>{q.chapter}</span> | ||
| 170 | <span>{q.map}</span> | ||
| 171 | </Link> | ||
| 172 | )):""} | ||
| 173 | {searchData!==null?searchData.players.map((q,index)=> | ||
| 174 | ( | ||
| 175 | <Link className='search-player' key={index}> | ||
| 176 | <img src={q.avatar_link} alt='pfp'></img> | ||
| 177 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> | ||
| 178 | </Link> | ||
| 179 | |||
| 180 | )):""} | ||
| 181 | |||
| 182 | </div> | ||
| 155 | </div> | 183 | </div> |
| 156 | </div> | 184 | </div> |
| 157 | ) | 185 | ) |