bgg-ottawa-sell-club/src/routes/GameList.svelte

92 lines
2.2 KiB
Svelte
Raw Normal View History

2024-02-05 19:35:35 +00:00
<div class="options">
<label class="switch icon">
<input type="checkbox" bind:checked={show_hidden} />
<span> show hidden </span>
</label>
2024-02-05 20:29:19 +00:00
<div class="field label prefix border">
<i>search</i>
<input type="text" bind:value={search_text} />
<label>Search</label>
</div>
2024-02-05 19:35:35 +00:00
</div>
2024-02-01 22:40:56 +00:00
<div class="games">
2024-02-05 20:29:19 +00:00
{#each games.filter((game) => {
if (search_text.length < 3) return true;
const target = search_text.toLowerCase();
return game.name.toLowerCase().includes(target) || game.username
.toLowerCase()
.includes(target);
}) as game}
2024-02-09 17:49:22 +00:00
{#if show_hidden || !game.is_hidden}
2024-02-09 18:43:54 +00:00
<Game
on:toggle_visibility={() => toggle_visibility(game.id)}
2024-02-10 15:19:56 +00:00
on:toggle_cart={() => toggle_cart(game.id)}
2024-02-09 18:43:54 +00:00
{...game}
seller={sellers[game.username]} />
<div class="medium-divider"></div>
2024-02-05 19:35:35 +00:00
{/if}
2024-02-01 22:40:56 +00:00
{/each}
</div>
<script>
2024-02-09 17:49:22 +00:00
import { getContext, createEventDispatcher } from 'svelte';
2024-02-09 18:43:54 +00:00
import Game from './Game.svelte';
2024-02-05 19:35:35 +00:00
2024-02-09 17:49:22 +00:00
export let games = [];
2024-02-05 15:30:23 +00:00
export let sellers = {};
2024-02-01 22:40:56 +00:00
2024-02-05 19:35:35 +00:00
let show_hidden = false;
2024-02-05 20:29:19 +00:00
let search_text = '';
2024-02-09 17:49:22 +00:00
const dispatch = createEventDispatcher();
const toggle_visibility = (id) => dispatch('toggle_game_visibility', id);
2024-02-10 15:19:56 +00:00
const toggle_cart = (id) => dispatch('toggle_cart', id);
2024-02-09 17:49:22 +00:00
2024-02-01 22:40:56 +00:00
// add filter
// add sort (user, game, price)
</script>
<style>
.games {
margin-top: 3em;
}
a {
color: var(--primary);
text-decoration: underline;
}
.grid {
margin-right: 2em;
font-size: var(--font-size-10);
}
.notes {
margin-top: 1em;
margin-left: 1em;
}
.updated-at {
font-size: smaller;
text-align: left;
}
.updated-at::before {
content: 'last update: ';
}
2024-02-05 15:30:23 +00:00
.neighbourhood {
font-size: smaller;
}
2024-02-05 19:35:35 +00:00
.hidden {
opacity: 60%;
}
.switch span {
font-size: var(--font-size-10);
padding-left: 1em;
}
.options {
display: flex;
flex-direction: row-reverse;
}
2024-02-05 20:29:19 +00:00
.options > div {
margin-right: 1em;
}
2024-02-01 22:40:56 +00:00
</style>