blob: 667e551b6c6b7b0a8335cde94f13575da232eda2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
<script lang="ts" context="module">
export async function load() {
const res = await fetch("/api/matches", {
headers: {
"Content-Type": "application/json",
},
});
if (res.ok) {
return {
props: {
matches: await res.json(),
},
};
}
return {
status: res.status,
error: new Error("failed to load matches"),
};
}
</script>
<script lang="ts">
import { goto } from "$app/navigation";
import dayjs from "dayjs";
export let matches: object[];
function match_url(match: object) {
return `/matches/${match["id"]}`;
}
</script>
<div class="container">
<table class="matches-table">
<tr>
<th class="header-timestamp">timestamp</th>
<th class="col-player-1">player 1</th>
<th></th>
<th></th>
<th class="col-player-2">player 2</th>
</tr>
{#each matches as match}
<tr class="match-table-row" on:click={() => goto(match_url(match))}>
<td class="col-timestamp">
{dayjs(match["timestamp"]).format("YYYY-MM-DD HH:mm")}
</td>
<td class="col-player-1">
{match["players"][0]["bot_name"]}
</td>
{#if match["winner"] == null}
<td class="col-score-player-1">
TIE
</td>
<td class="col-score-player-2">
TIE
</td>
{:else if match["winner"] == 0}
<td class="col-score-player-1">
WIN
</td>
<td class="col-score-player-2">
LOSS
</td>
{:else if match["winner"] == 1}
<td class="col-score-player-1">
LOSS
</td>
<td class="col-score-player-2">
WIN
</td>
{/if}
<td class="col-player-2">
{match["players"][1]["bot_name"]}
</td>
</tr>
{/each}
</table>
</div>
<style lang="scss">
.container {
width: 800px;
margin: 0 auto;
}
.matches-table td,
.matches-table th {
padding: 8px 16px;
// width: 100%;
}
.header-timestamp {
text-align: left;
}
.col-timestamp {
color: #555;
}
.col-player-1 {
text-align: left;
}
.col-player-2 {
text-align: right;
}
@mixin col-player-score {
text-transform: uppercase;
font-weight: 600;
font-size: 14px;
font-family: "Open Sans", sans-serif;
}
.col-score-player-1 {
@include col-player-score;
text-align: right;
}
.col-score-player-2 {
@include col-player-score;
text-align: left;
}
.matches-table {
margin: 12px auto;
border-collapse: collapse;
}
.match-table-row:hover {
cursor: pointer;
background-color: #eee;
}
</style>
|