File size: 3,716 Bytes
6710512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303b4b7
6710512
 
 
 
 
 
 
 
 
 
 
d9c705e
6710512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9c705e
 
 
 
 
6710512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<script lang="ts">
  import { onMount } from 'svelte';
  import { getAllMonsters } from '$lib/db/monsters';
  import type { Monster } from '$lib/db/schema';
  
  let monsters: Monster[] = $state([]);
  let isLoading = $state(true);
  
  onMount(async () => {
    try {
      monsters = await getAllMonsters();
    } catch (err) {
      console.error('Failed to load monsters:', err);
    } finally {
      isLoading = false;
    }
  });
</script>

<div class="pictuary-page">
  <header class="page-header">
    <h2>Your Pictuary</h2>
    <p class="monster-count">{monsters.length} Piclets collected</p>
  </header>
  
  {#if isLoading}
    <div class="loading-state">
      <div class="spinner"></div>
      <p>Loading collection...</p>
    </div>
  {:else if monsters.length === 0}
    <div class="empty-state">
      <img 
        src="https://huggingface.co/spaces/Fraser/piclets/resolve/main/assets/pictuary_logo.png" 
        alt="Pictuary" 
        class="empty-icon"
      />
      <h3>No Piclets Yet</h3>
      <p>Start scanning photos to build your collection!</p>
    </div>
  {:else}
    <div class="monster-grid">
      {#each monsters as monster}
        <div class="monster-card">
          <img 
            src={monster.imageData || monster.imageUrl} 
            alt={monster.name}
            class="monster-image"
          />
          <h4 class="monster-name">{monster.name}</h4>
          <p class="monster-date">
            {new Date(monster.createdAt).toLocaleDateString()}
          </p>
        </div>
      {/each}
    </div>
  {/if}
</div>

<style>
  .pictuary-page {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .page-header {
    padding: 1.5rem 1rem;
    background: white;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .page-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
  }
  
  .monster-count {
    margin: 0.25rem 0 0;
    color: #666;
    font-size: 0.9rem;
  }
  
  .loading-state,
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100% - 100px);
    padding: 2rem;
    text-align: center;
  }
  
  .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
  }
  
  .empty-icon {
    width: 80px;
    opacity: 0.5;
    margin-bottom: 1rem;
  }
  
  .empty-state h3 {
    margin: 0 0 0.5rem;
    color: #333;
  }
  
  .empty-state p {
    margin: 0;
    color: #666;
  }
  
  .monster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }
  
  .monster-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
  }
  
  .monster-card:active {
    transform: scale(0.95);
  }
  
  .monster-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
                linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
  }
  
  .monster-name {
    margin: 0;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
  }
  
  .monster-date {
    margin: 0;
    padding: 0 0.75rem 0.75rem;
    font-size: 0.75rem;
    color: #999;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
</style>