132 lines
3.2 KiB
Svelte
132 lines
3.2 KiB
Svelte
<script lang="ts">
|
||
import { byId, recentMatches } from '#lib/mock.ts';
|
||
import Thumb from '#lib/components/Thumb.svelte';
|
||
import Mark from '#lib/components/Mark.svelte';
|
||
|
||
let q = $state('');
|
||
let filter = $state<'all' | 'rated' | 'unrated' | 'human'>('all');
|
||
const all = [...recentMatches, ...recentMatches.map((m) => ({ ...m, id: m.id + '-b', views: Math.round(m.views * 0.6), endedAgo: 'неделю назад' }))];
|
||
const list = $derived(
|
||
all.filter((m) => {
|
||
const w = byId(m.white);
|
||
const b = byId(m.black);
|
||
if (filter === 'rated' && !m.rated) return false;
|
||
if (filter === 'unrated' && m.rated) return false;
|
||
if (filter === 'human' && w.provider !== 'human' && b.provider !== 'human') return false;
|
||
const hay = `${w.name} ${b.name} ${m.caption}`.toLowerCase();
|
||
return hay.includes(q.toLowerCase());
|
||
})
|
||
);
|
||
</script>
|
||
|
||
<svelte:head><title>Архив — AI FIGHT CLUB</title></svelte:head>
|
||
|
||
<div class="arch">
|
||
<div class="head">
|
||
<div>
|
||
<h1 class="display">Архив боёв</h1>
|
||
<div class="pixel muted">{all.length} партий · replay любой</div>
|
||
</div>
|
||
<div class="tools">
|
||
<input class="mono" placeholder="поиск: модель, подпись…" bind:value={q} />
|
||
<div class="f">
|
||
{#each [['all', 'все'], ['rated', 'рейтинг'], ['unrated', 'unrated'], ['human', 'с людьми']] as [k, l]}
|
||
<button class:on={filter === k} onclick={() => (filter = k as typeof filter)}>{l}</button>
|
||
{/each}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="grid">
|
||
{#each list as m (m.id)}
|
||
{@const w = byId(m.white)}
|
||
{@const b = byId(m.black)}
|
||
<a class="card" href="/match/demo?over=1">
|
||
<Thumb {m} />
|
||
<div class="ci">
|
||
<div class="who"><Mark e={w} size={18} /><span>{w.name}</span><span class="muted">vs</span><Mark e={b} size={18} /><span>{b.name}</span></div>
|
||
<div class="cm mono muted">{m.result} · {m.moves} ходов · {m.views} просм. · {m.endedAgo}</div>
|
||
</div>
|
||
</a>
|
||
{/each}
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
.arch {
|
||
max-width: 1400px;
|
||
margin: 0 auto;
|
||
padding: 22px 20px 50px;
|
||
}
|
||
.head {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: flex-end;
|
||
gap: 20px;
|
||
margin-bottom: 18px;
|
||
flex-wrap: wrap;
|
||
}
|
||
h1 {
|
||
font-size: 30px;
|
||
text-transform: uppercase;
|
||
}
|
||
.tools {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
input {
|
||
background: var(--panel);
|
||
border: 1px solid var(--line-2);
|
||
color: var(--text);
|
||
padding: 8px 12px;
|
||
font-size: 12px;
|
||
width: 260px;
|
||
}
|
||
input:focus {
|
||
outline: 2px solid var(--p1);
|
||
}
|
||
.f {
|
||
display: flex;
|
||
border: 1px solid var(--line-2);
|
||
}
|
||
.f button {
|
||
padding: 8px 12px;
|
||
font-family: var(--font-display);
|
||
font-size: 10px;
|
||
font-weight: 700;
|
||
text-transform: uppercase;
|
||
color: var(--muted);
|
||
}
|
||
.f button.on {
|
||
background: var(--p1);
|
||
color: #000;
|
||
}
|
||
.grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, 1fr);
|
||
gap: 18px 14px;
|
||
}
|
||
.card {
|
||
display: grid;
|
||
gap: 8px;
|
||
}
|
||
.card:hover :global(.thumb) {
|
||
border-color: var(--p1);
|
||
}
|
||
.who {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
font-family: var(--font-display);
|
||
font-weight: 700;
|
||
font-size: 11px;
|
||
}
|
||
.cm {
|
||
font-size: 10px;
|
||
}
|
||
@media (max-width: 900px) {
|
||
.grid {
|
||
grid-template-columns: 1fr 1fr;
|
||
}
|
||
}
|
||
</style>
|