bgg-ottawa-sell-club/src/routes/stats/+page.svelte

51 lines
1.2 KiB
Svelte

<article>
<p>Currently listing {nbr_games} games from {nbr_sellers} sellers.</p>
{#each Object.keys($sellers).sort() as username (username)}
<div class="row">
<BggUser {username} />
<span class="max neighbourhood">
{#if $sellers[username].neighbourhood}
({$sellers[username].neighbourhood})
{/if}
</span>
<span class="nbr_games">
{nbr_games_for(username)}
</span>
</div>
{/each}
</article>
<script>
// TODO avatars?
import { getContext } from 'svelte';
import BggUser from '$lib/components/BggUser.svelte';
const games = getContext('games');
const sellers = getContext('sellers');
$: nbr_games = $games.length;
$: nbr_sellers = Object.values($sellers).length;
const nbr_games_for = (username) =>
$games.filter((game) => game.username === username).length;
</script>
<style>
.nbr_games:after {
content: ' games';
}
.nbr_games:before {
content: 'selling ';
}
div {
margin-left: 2em;
margin-right: 2em;
}
article {
font-size: var(--font-size-10);
}
</style>