aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components
diff options
context:
space:
mode:
authorNidboj132 <lol2s@vp.plm>2023-09-05 18:23:00 +0200
committerNidboj132 <lol2s@vp.plm>2023-09-05 18:23:00 +0200
commit06f4af2e791343fc636302c6e38adb450427a040 (patch)
treebcc7bbcc1303a36a36986dc12431ba07ef279a3c /frontend/src/components
parentdocs: update license name in disclaimer (diff)
downloadlphub-06f4af2e791343fc636302c6e38adb450427a040.tar.gz
lphub-06f4af2e791343fc636302c6e38adb450427a040.tar.bz2
lphub-06f4af2e791343fc636302c6e38adb450427a040.zip
added graph and fixed some css
Former-commit-id: b0370b8679f2a7b20c2f277c3814401fbc78d54d
Diffstat (limited to 'frontend/src/components')
-rw-r--r--frontend/src/components/pages/summary.css162
-rw-r--r--frontend/src/components/pages/summary.js115
2 files changed, 208 insertions, 69 deletions
diff --git a/frontend/src/components/pages/summary.css b/frontend/src/components/pages/summary.css
index e97dc0f..a0f2f5d 100644
--- a/frontend/src/components/pages/summary.css
+++ b/frontend/src/components/pages/summary.css
@@ -1,4 +1,3 @@
1
2#background-image{ 1#background-image{
3 z-index: -1; 2 z-index: -1;
4 position: absolute; 3 position: absolute;
@@ -19,14 +18,10 @@
19 background: linear-gradient(to top, #161723, #0000); 18 background: linear-gradient(to top, #161723, #0000);
20} 19}
21 20
22/* Section 1: map name + difficulty*/ 21/* Section 1: map name*/
23 22
24#section1{ 23#section1{
25 margin: 20px 0 0 0; 24 margin: 20px 0 0 0;
26 width: 100%;
27
28 display:grid;
29 grid-template-columns: auto 470px;
30 cursor: default; 25 cursor: default;
31} 26}
32 27
@@ -34,7 +29,7 @@
34 height: 40px; 29 height: 40px;
35 background-color: #2b2e46; 30 background-color: #2b2e46;
36 31
37 color: #cdcfdf;; 32 color: inherit;
38 font-size: 18px; 33 font-size: 18px;
39 font-family: inherit; 34 font-family: inherit;
40 border: none; 35 border: none;
@@ -45,16 +40,12 @@
45.nav-button>span{padding: 0 8px 0 8px;} 40.nav-button>span{padding: 0 8px 0 8px;}
46.nav-button:hover{background-color: #202232;cursor: pointer;} 41.nav-button:hover{background-color: #202232;cursor: pointer;}
47 42
48
49
50/* Section 2: navbar */ 43/* Section 2: navbar */
51
52#section2{ 44#section2{
53 margin: 40px 0 0 0; 45 margin: 40px 0 0 0;
54 width: 100%;
55 46
56 display: grid; 47 display: grid; gap: 2px;
57 grid-template-columns: auto auto auto; 48 grid-template-columns: 1fr 1fr 1fr;
58} 49}
59 50
60#section2>.nav-button{ 51#section2>.nav-button{
@@ -63,24 +54,20 @@
63 display: flex; 54 display: flex;
64 justify-content: center; 55 justify-content: center;
65 place-items: center; 56 place-items: center;
66
67} 57}
68#section2>.nav-button>img{scale: 1.2;} 58#section2>.nav-button>img{scale: 1.2;}
69#section2>.nav-button:nth-child(1){border-radius: 30px 0 0 30px;} 59#section2>.nav-button:nth-child(1){border-radius: 30px 0 0 30px;}
70#section2>.nav-button:nth-child(2){margin-left:2px;} 60#section2>.nav-button:nth-child(3){border-radius: 0 30px 30px 0;}
71#section2>.nav-button:nth-child(3){border-radius: 0 30px 30px 0;margin-left: 2px;}
72 61
73 62
74/* Section 3: category + history */ 63/* Section 3: category + history */
75 64
76#section3{ 65#section3{
77 margin: 40px 0 0 0; 66 margin: 40px 0 0 0;
78 height: auto;
79 67
80 display: grid; 68 display: grid;
81 grid-template-columns: 50% 50%; 69 grid-template-columns: 1fr 1fr;
82 gap: 20px; 70 gap: 20px;
83
84} 71}
85 72
86#category{ 73#category{
@@ -92,7 +79,6 @@
92} 79}
93#category>p{ 80#category>p{
94 margin-bottom: 20px; 81 margin-bottom: 20px;
95 display: inline;
96 text-align: center; 82 text-align: center;
97 font-size: 50px; 83 font-size: 50px;
98 cursor: default; 84 cursor: default;
@@ -104,7 +90,6 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
104#category-image{ 90#category-image{
105 transform: translate(-20%, -15%); 91 transform: translate(-20%, -15%);
106 z-index: -1; 92 z-index: -1;
107 border-radius: 20px;
108 overflow: hidden; 93 overflow: hidden;
109 width: 125%; 94 width: 125%;
110 margin: 22px; 95 margin: 22px;
@@ -116,49 +101,44 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
116 background-color: #202232; 101 background-color: #202232;
117 102
118 display: grid; 103 display: grid;
119 grid-template-columns: auto auto auto auto; 104 grid-template-columns: 1fr 1fr 1fr 1fr;
120 gap: 2px; 105 gap: 2px;
121} 106}
122#category>span>button{ 107#category>span>button{
123 font-family: BarlowSemiCondensed-Regular; 108 font-family: inherit;
124 font-size: 18px; 109 font-size: 18px;
125 border: none; 110 border: none;
126 height: 40px; 111 height: 40px;
127 color: #cdcfdf; 112 color: inherit;
128 background-color: #2b2e46;
129 113
130 cursor: pointer; 114 cursor: pointer;
131 transition: background-color .1s; 115 transition: background-color .1s;
132} 116}
133#category>span>button:hover{background-color: #202232;}
134 117
135 118
136 119
137#history>div>hr{border: 1px solid #2b2e46;margin: 4px 20px 4px 20px;} 120#history>div>hr{border: 1px solid #2b2e46;margin: 8px 20px 0px 20px;}
138#history{ 121#history{
139 height: 350px;
140 min-width: 560px; 122 min-width: 560px;
141 background-color: #202232; 123 background-color: #202232;
142 border-radius: 30px; 124 border-radius: 30px;
143 125
144} 126}
145 127
146#history>div{height: 290px;} 128#records{overflow-y: auto; height: 256px;}
147#records{overflow-y: auto; height: 255px;} 129#records::-webkit-scrollbar{display: none;}
130
148.record-top, .record{ 131.record-top, .record{
149 font-size: 18px; 132 font-size: 18px;
150
151 display: grid; 133 display: grid;
152 text-align: center; 134 text-align: center;
153 grid-template-columns: calc(100%/3) calc(100%/3) calc(100%/3); 135 grid-template-columns: 1fr 1fr 1fr;
154} 136}
155.record-top{font-weight: bold;margin: 20px 20px 0 20px;} 137.record-top{font-weight: bold;margin: 20px 20px 0 20px;cursor: default;}
156.record{ 138.record{
157 margin: 10px 20px 0 20px; 139 margin: 10px 20px 10px 20px;
158 height: 44px; width: calc(100% - 40px); 140 height: 44px; width: calc(100% - 40px);
159 141
160
161 background-color: #2b2e46;
162 color: inherit; 142 color: inherit;
163 border-radius: 40px; 143 border-radius: 40px;
164 place-items: center; 144 place-items: center;
@@ -167,47 +147,110 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
167 cursor: pointer; 147 cursor: pointer;
168 transition: background-color .1s; 148 transition: background-color .1s;
169} 149}
170.record:hover{background-color: #161723;}
171
172#history>span{ 150#history>span{
151 border-top: #202232 solid 2px;
173 display: grid; 152 display: grid;
174 grid-template-columns: 50% 50%; 153 grid-template-columns: 1fr 1fr;
175} 154}
176#history>span>button{ 155#history>span>button{
177
178 width: 100%; height: 40px; 156 width: 100%; height: 40px;
179 font-family: BarlowSemiCondensed-Regular; 157 font-family: inherit;
180 font-size: 18px; 158 font-size: 18px;
181 border: none; 159 border: none;
182 160 color: inherit;
183 color: #cdcfdf;
184 background-color: #2b2e46;
185 161
186 cursor: pointer; 162 cursor: pointer;
187 transition: background-color .1s; 163 transition: background-color .1s;
188} 164}
189#history>span>button:hover{background-color: #202232 !important;}
190#history>span>button:nth-child(1){border-radius: 0 0 0 30px;} 165#history>span>button:nth-child(1){border-radius: 0 0 0 30px;}
191#history>span>button:nth-child(2){border-radius: 0 0 30px 0;} 166#history>span>button:nth-child(2){border-radius: 0 0 30px 0;}
192 167
168#graph{
169 display: grid;
170 grid-template-columns: 20px 1fr;
171 grid-template-rows: 1fr 20px;
172 height: 293px;
173
174 margin: 10px 10px 5px 10px;
175 overflow: hidden;
176}
177#graph>div:nth-child(1){ /* numbers */
178 width: 20px;
179 display: grid;
180 place-items: center;
181 /* background-color: blue; */
182}
183#graph>div:nth-child(1)>span{
184 font-size: 12px;
185 line-height: 0;
186}
187
188#graph>div:nth-child(2){ /* big graph */
189 position: relative;
190 display: grid;
191}
192#graph>div:nth-child(2)>tr{
193 display: flex;
194 align-items: center;
195 grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
196}
197#graph>div:nth-child(2)>tr>td.graph_hor{
198 width: 100%;
199 height: 0;
200 padding: 0;
201
202 outline: 1px solid red;
203}
204#graph>div:nth-child(2)>tr>td.graph_ver{
205 width: 0;
206 height: 100%;
207 padding: 0;
208
209 outline: 1px solid blue;
210 transform: translateY(50%);
211 z-index: 0;
212 overflow: hidden;
213}
214
215#graph>div:nth-child(3){ /* dates */
216 padding-right: 20px;
217 z-index: 1;
218 height: 16px;
219 background-color: #202232;
220 grid-column: 1 /3;
221 font-size: 12px;
222 display: grid;
223 padding-top: 8px;
224 grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
225}
226
227.graph-button{
228 position: absolute;
229 padding: 0;
230 border: 5px solid white;
231 border-radius: 20px;
232 cursor: pointer;
233 transform: translateX(-50%);
234}
235
236#history>div>h5{text-align: center;height: 197px;}
237
238
193/* Section 4: Difficulty + count */ 239/* Section 4: Difficulty + count */
194 240
195#section4{ 241#section4{
196 display: grid; 242 display: grid;
197 grid-template-columns: 50% 50%; 243 grid-template-columns: 1fr 1fr;
198 margin: 40px 0 20px 0; 244 gap: 20px;
199 width: 100%; 245 margin: 40px 0 0 0;
200 gap: 8px;
201} 246}
202 247
203#difficulty, 248#difficulty,
204#count { 249#count {
205 background-color: #202232; 250 background-color: #202232;
206 width: 100%; height: 100px;
207 min-width: 250px; 251 min-width: 250px;
208 margin: 10px;
209
210 text-align: center; 252 text-align: center;
253 cursor: default;
211 254
212 border-radius: 20px; 255 border-radius: 20px;
213 display: grid; 256 display: grid;
@@ -221,12 +264,10 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
221} 264}
222#difficulty>span:nth-child(2){ 265#difficulty>span:nth-child(2){
223 font-size: 40px; 266 font-size: 40px;
224 color:lime
225} 267}
226#difficulty>div{ 268#difficulty>div{
227 width: 250px;
228 display: grid; 269 display: grid;
229 grid-template-columns: auto auto auto auto auto; 270 grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
230 padding: 0 calc(50% - 125px) 0 calc(50% - 125px); 271 padding: 0 calc(50% - 125px) 0 calc(50% - 125px);
231 place-items: center; 272 place-items: center;
232} 273}
@@ -296,9 +337,7 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
296 justify-content: center; 337 justify-content: center;
297 align-items: center; 338 align-items: center;
298 } 339 }
299/* }
300 340
301@media screen and (max-width: 1280px) { */
302 #section1{ 341 #section1{
303 grid-template-columns: auto; 342 grid-template-columns: auto;
304 place-items: center; 343 place-items: center;
@@ -311,12 +350,7 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;}
311 width: 450px; 350 width: 450px;
312 margin: 40px auto 0 auto; 351 margin: 40px auto 0 auto;
313 } 352 }
314 #section2>.nav-button{
315 margin: 1px 0 1px 0 !important;
316 }
317 #section2>.nav-button:nth-child(1){border-radius: 30px 30px 0 0;} 353 #section2>.nav-button:nth-child(1){border-radius: 30px 30px 0 0;}
318 #section2>.nav-button:nth-child(2){border-radius: 0;} 354 #section2>.nav-button:nth-child(2){border-radius: 0;}
319 #section2>.nav-button:nth-child(3){border-radius: 0 0 30px 30px;} 355 #section2>.nav-button:nth-child(3){border-radius: 0 0 30px 30px;}
320
321
322} \ No newline at end of file 356} \ No newline at end of file
diff --git a/frontend/src/components/pages/summary.js b/frontend/src/components/pages/summary.js
index 2665d66..276389f 100644
--- a/frontend/src/components/pages/summary.js
+++ b/frontend/src/components/pages/summary.js
@@ -66,6 +66,7 @@ function HisClick() {
66 const btn = document.querySelectorAll("#section3 #history span button"); 66 const btn = document.querySelectorAll("#section3 #history span button");
67 btn.forEach((e) => {e.style.backgroundColor = "#2b2e46"}); 67 btn.forEach((e) => {e.style.backgroundColor = "#2b2e46"});
68 btn[hisState].style.backgroundColor = "#202232"; 68 btn[hisState].style.backgroundColor = "#202232";
69
69}} 70}}
70 71
71const [selectedRun,setSelectedRun] = React.useState(0) 72const [selectedRun,setSelectedRun] = React.useState(0)
@@ -84,6 +85,96 @@ function selectRun(x,y){
84 } 85 }
85} 86}
86 87
88function graph(state) {
89 // this is such a mess
90 let graph = data.summary.routes.filter(e=>e.category.id===catState)
91 let graph_score = []
92 data.summary.routes.filter(e=>e.category.id===catState).forEach(e=>graph_score.push(e.history.score_count))
93 let graph_dates = []
94 data.summary.routes.filter(e=>e.category.id===catState).forEach(e=>graph_dates.push(e.history.date.split("T")[0]))
95 let graph_max = graph[graph.length-1].history.score_count
96 let graph_numbers = []
97 for (let i=graph_max;i>=0;i--){
98 graph_numbers[i]=i
99 }
100
101 switch (state) {
102 case 1: //numbers
103 return graph_numbers
104 .reverse().map(e=>(
105 graph_score.includes(e) || e===0 ?
106 <span>{e}<br/></span>
107 :
108 <span><br/></span>
109 ))
110 case 2: // graph
111 let i = 1
112 let g = 0
113 let h = 0
114 return graph_numbers.map((e,j)=>(
115 <tr id={'graph_row-'+(graph_max-j)}
116 data-graph={ graph_score.includes(graph_max-j) ? g++ : 0}
117 data-graph2={h=0}
118
119 >
120 {
121 graph_score.map((e,i)=>(
122 <>
123 <td className='graph_ver'
124 data-graph={ h++ }
125 style={{outline:
126 g==h-1 ?
127 "1px solid #2b2e46" : g>=h ? "1px dashed white" : "0" }}
128 ></td>
129
130 {g==h && graph_score.includes(graph_max-j) ?
131 <button className='graph-button'
132 onClick={()=>{
133 selectRun(graph_dates.length-(i-1),catState);
134 }}
135 style={{left: `calc(100% / ${graph_dates.length} * ${h-1})`}}
136 ></button>
137 : ""}
138
139 <td className='graph_hor' id={'graph_table-'+i++}
140 style={{
141 outline:
142 graph_score.includes(graph_max-j) ?
143 g>=h ?
144 g-1>=h ? "1px dashed #2b2e46" : "1px solid white" : "0"
145 : "0"}}
146 ></td>
147
148
149
150 <td className='graph_hor' id={'graph_table-'+i++}
151 style={{outline:
152 graph_score.includes(graph_max-j) ?
153 g>=h ?
154 g-1>=h ? "1px dashed #2b2e46" : "1px solid white" : "0"
155 : "0"}}
156 ></td>
157
158 </>
159 ))
160
161 }
162
163 </tr>
164 ))
165
166 case 3: // dates
167 return graph_dates
168 .reverse().map(e=>(
169 <span>{e}</span>
170 ))
171 default:
172 break;
173
174 }
175
176}
177
87const [vid,setVid] = React.useState("") 178const [vid,setVid] = React.useState("")
88React.useEffect(()=>{ 179React.useEffect(()=>{
89 if(data!==null){ 180 if(data!==null){
@@ -140,7 +231,10 @@ return (
140 </div> 231 </div>
141 232
142 <div id='history'> 233 <div id='history'>
143 <div> 234
235 <div style={{display: hisState ? "none" : "block"}}>
236 {data.summary.routes.filter(e=>e.category.id===catState).length===0 ? <h5>There are no records for this map.</h5> :
237 <>
144 <div className='record-top'> 238 <div className='record-top'>
145 <span>Date</span> 239 <span>Date</span>
146 <span>Record</span> 240 <span>Record</span>
@@ -163,17 +257,28 @@ return (
163 <span>{r.history.runner_name}</span> 257 <span>{r.history.runner_name}</span>
164 </button> 258 </button>
165 ))} 259 ))}
166
167 </div> 260 </div>
168 </div> 261 </>
262 }
263 </div>
264
265 <div style={{display: hisState ? "block" : "none"}}>
266 {data.summary.routes.filter(e=>e.category.id===catState).length===0 ? <h5>There are no records for this map.</h5> :
267 <div id='graph'>
268 <div>{graph(1)}</div>
269 <div>{graph(2)}</div>
270 <div>{graph(3)}</div>
271 </div>
272 }
273 </div>
169 <span> 274 <span>
170 <button onClick={()=>setHisState(0)}>List</button> 275 <button onClick={()=>setHisState(0)}>List</button>
171 <button onClick={()=>setHisState(1)}>Graph</button> 276 <button onClick={()=>setHisState(1)}>Graph</button>
172 </span> 277 </span>
173 </div> 278 </div>
279
174 280
175 </section> 281 </section>
176
177 <section id='section4'> 282 <section id='section4'>
178 <div id='difficulty'> 283 <div id='difficulty'>
179 <span>Difficulty</span> 284 <span>Difficulty</span>