-
Notifications
You must be signed in to change notification settings - Fork 0
/
_Piles.svelte
57 lines (51 loc) · 1.29 KB
/
_Piles.svelte
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
<script>
import Card from '$lib/components/Card.svelte';
import { discard, focused } from '../_store.js';
import { choose } from '$lib/utils/actions.js';
import { send, receive } from '$lib/utils/crossfade.js';
let shownDiscard = []
$: if ($discard) {
const entries = Object.entries($discard).reverse()
shownDiscard = entries.length > 6 ? entries.slice(entries.length - 5, entries.length) : entries
}
</script>
<div class="piles">
<div on:click={() => choose('draw')}>
{#each [0, 0, 0, 0] as _, index}
<div>
<Card
color="black"
symbol=""
floatLeft={false}
focused={$focused.location === 'draw' && index === 3}
/>
</div>
{/each}
</div>
<div on:click={() => choose('discard')}>
<div><Card color="" symbol="" style="silhouette" /></div>
{#each shownDiscard as [cardIndex, card], index (cardIndex)}
<div in:receive={{ key: cardIndex }} out:send={{ key: cardIndex }} >
<Card
{...card}
floatLeft={false}
focused={$focused.location === 'discard' && index === shownDiscard.length - 1}
/>
</div>
{/each}
</div>
</div>
<style lang="scss">
.piles {
display: flex;
justify-content: center;
grid-gap: max(4vw, 1rem);
padding-bottom: 1rem;
> div {
display: grid;
> div {
grid-area: 1/1/2/2;
}
}
}
</style>