@@ -71,6 +71,7 @@ const Main = () => {
71
71
const teams = useCurrentTeams ( )
72
72
const scores = useCurrentScores ( )
73
73
const mapWinners = useCurrentMapWinners ( )
74
+ const data = useLeaderboard ( )
74
75
75
76
return (
76
77
< div className = "absolute inset-0 text-white flex flex-col items-center justify-evenly z-10" >
@@ -111,7 +112,7 @@ const Main = () => {
111
112
initial = "hidden"
112
113
animate = "show"
113
114
exit = "hidden"
114
- className = "flex items-center justify-center h-[36rem] gap-8 p-12"
115
+ className = "flex items-center justify-center h-[36rem] w-full gap-8 p-12"
115
116
>
116
117
{ screen === "maplist" &&
117
118
round . value . map ( ( game , i ) => (
@@ -149,7 +150,7 @@ const Main = () => {
149
150
< >
150
151
< Section
151
152
className = { clsx (
152
- "flex-1 h-full !w-[36rem] flex flex-col justify-between text-4xl" ,
153
+ "flex-1 h-full max-w-xl w-full flex flex-col justify-between text-4xl" ,
153
154
"items-start"
154
155
) }
155
156
>
@@ -165,7 +166,7 @@ const Main = () => {
165
166
</ motion . div >
166
167
< Section
167
168
className = { clsx (
168
- "flex-1 h-full !w-[36rem] flex flex-col justify-between text-4xl" ,
169
+ "flex-1 h-full max-w-xl w-full flex flex-col justify-between text-4xl" ,
169
170
"items-end"
170
171
) }
171
172
>
@@ -175,6 +176,41 @@ const Main = () => {
175
176
</ Section >
176
177
</ >
177
178
) }
179
+ { screen === "leaderboard" && data && (
180
+ < >
181
+ < Section
182
+ className = { clsx (
183
+ "flex-1 h-full max-w-2xl flex flex-col justify-between text-4xl"
184
+ ) }
185
+ >
186
+ { data . slice ( 0 , 5 ) . map ( ( v , i ) => (
187
+ < Row
188
+ placement = { i + 1 }
189
+ key = { i }
190
+ weapons = { v . weapons }
191
+ name = { v . splashtag }
192
+ points = { v . points }
193
+ />
194
+ ) ) }
195
+ </ Section >
196
+ < span />
197
+ < Section
198
+ className = { clsx (
199
+ "flex-1 h-full max-w-2xl flex flex-col justify-between text-4xl"
200
+ ) }
201
+ >
202
+ { data . slice ( 5 , 10 ) . map ( ( v , i ) => (
203
+ < Row
204
+ placement = { i + 6 }
205
+ key = { i }
206
+ weapons = { v . weapons }
207
+ name = { v . splashtag }
208
+ points = { v . points }
209
+ />
210
+ ) ) }
211
+ </ Section >
212
+ </ >
213
+ ) }
178
214
</ motion . div >
179
215
) }
180
216
< AnimatePresence mode = "popLayout" >
@@ -490,80 +526,11 @@ const Commentator = ({ left, right, comm }) => (
490
526
</ div >
491
527
)
492
528
493
- const LeaderboardSection = ( ) => {
494
- const data = useLeaderboard ( )
495
- if ( data === undefined ) {
496
- return (
497
- < div className = "w-full flex flex-col gap-3 animate-pulse" >
498
- { Array . from ( { length : 9 } ) . map ( ( v , i ) => (
499
- < div key = { i } style = { { opacity : `calc(100% - ${ ( i + 1 ) * 10 } %)` } } >
500
- < Row name = { `\u200B` } />
501
- </ div >
502
- ) ) }
503
- </ div >
504
- )
505
- }
506
- if ( data ?. message ) {
507
- return (
508
- < div className = "w-full flex flex-col gap-3" >
509
- < div className = "max-w-2xl w-full rounded-lg p-5 mx-auto text-xl text-center text-red-400 bg-red-400/20" >
510
- Something went wrong, try again later.
511
- </ div >
512
- </ div >
513
- )
514
- }
515
-
516
- if ( data . length === 0 ) {
517
- return (
518
- < div className = "w-full flex flex-col gap-3" >
519
- < Row
520
- name = {
521
- < div className = "text-center w-full text-3xl overflow-auto whitespace-normal" >
522
- Qualifiers have not begun yet, so standings are not avaliable.
523
- Check back soon!
524
- </ div >
525
- }
526
- />
527
- { Array . from ( { length : 5 } ) . map ( ( v , i ) => (
528
- < div key = { i } style = { { opacity : `calc(100% - ${ ( i + 1 ) * 10 } %)` } } >
529
- < Row name = { `\u200B` } />
530
- </ div >
531
- ) ) }
532
- </ div >
533
- )
534
- }
529
+ const Row = ( { placement, name, weapons, points } ) => {
535
530
return (
536
- < div className = "w-full flex flex-col gap-3" >
537
- { data . map ( ( v , i ) => (
538
- < Row
539
- placement = { i + 1 }
540
- key = { i }
541
- name = {
542
- < div className = "flex items-center gap-3" >
543
- < span > { v . splashtag } </ span >
544
- < div className = "flex items-center gap-2" >
545
- { v . weapons . map ( ( weapon ) => (
546
- < img
547
- key = { weapon . id }
548
- src = { `https://raw.githubusercontent.com/Sendouc/sendou.ink/rewrite/public/static-assets/img/main-weapons-outlined/${ weapon . id } .png` }
549
- className = "h-7 w-7 sm:h-8 sm:w-8"
550
- />
551
- ) ) }
552
- </ div >
553
- </ div >
554
- }
555
- points = { v . points }
556
- />
557
- ) ) }
558
- </ div >
559
- )
560
- }
561
-
562
- const Row = ( { placement, name, points } ) => (
563
- < Section className = "!p-4 flex items-center text-3xl sm:text-2xl max-w-3xl mx-auto w-full" >
564
- { placement && (
531
+ < div className = "flex gap-8 items-center text-4xl max-w-3xl mx-auto w-full justify-between" >
565
532
< div
566
- className = { `shrink-0 pr-4 sm:pr-0 sm:w-16 sm: text-center font-black text-fabl-indigo-light ${
533
+ className = { `shrink-0 font-mono text-center text-4xl font-black text-fabl-indigo-light ${
567
534
placement <= 1
568
535
? "!text-fabl-gold"
569
536
: placement <= 3
@@ -573,23 +540,25 @@ const Row = ({ placement, name, points }) => (
573
540
>
574
541
{ placement }
575
542
</ div >
576
- ) }
577
- < div
578
- className = { `flex-1 text-xl gap-4 rounded-md font-medium overflow-hidden py-3 px-4 flex items-center justify-between ${
579
- placement % 2 === 0 ? "bg-fabl-indigo-darker" : "bg-fabl-indigo-darker"
580
- } `}
581
- >
582
- < div className = "flex-1" > { name } </ div >
583
- { points && (
584
- < div className = "font-mono shrink-0" >
585
- < span className = "font-bold" > { points } </ span > { " " }
586
- < span className = "hidden sm:inline" > points</ span >
543
+ < div className = "flex-1 truncate flex items-center gap-3" >
544
+ < span > { name } </ span >
545
+ < div className = "flex shrink-0 items-center gap-1" >
546
+ { weapons . map ( ( weapon ) => (
547
+ < img
548
+ key = { weapon . id }
549
+ src = { `https://raw.githubusercontent.com/Sendouc/sendou.ink/rewrite/public/static-assets/img/main-weapons-outlined/${ weapon . id } .png` }
550
+ className = "h-12 shrink-0"
551
+ />
552
+ ) ) }
587
553
</ div >
588
- ) }
554
+ </ div >
555
+ < span className = "font-bold font-mono" >
556
+ { Object . values ( points ) . reduce ( ( a , b ) => a + b , 0 ) }
557
+ < span className = "font-sans" > p</ span >
558
+ </ span >
589
559
</ div >
590
- { placement && < div className = "sm:w-16" > </ div > }
591
- </ Section >
592
- )
560
+ )
561
+ }
593
562
594
563
const useLeaderboard = ( ) => {
595
564
const [ data , setData ] = useState ( )
@@ -598,7 +567,9 @@ const useLeaderboard = () => {
598
567
fetch (
599
568
"https://us-central1-off-the-dial-26e93.cloudfunctions.net/fabl-standings"
600
569
)
601
- . then ( ( res ) => res . json ( ) )
570
+ . then ( ( res ) => {
571
+ if ( res . ok ) return res . json ( )
572
+ } )
602
573
. then ( ( data ) => setData ( data ) )
603
574
} , [ ] )
604
575
0 commit comments