File size: 3,292 Bytes
b4531e8 1f2c086 b4531e8 1f2c086 b4531e8 1f2c086 b4531e8 1f2c086 b4531e8 1f2c086 b4531e8 1f2c086 b4531e8 |
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 |
<script lang="ts">
import type { PicletInstance } from '$lib/db/schema';
import PicletCard from '../Piclets/PicletCard.svelte';
import DraggablePicletCard from '../Piclets/DraggablePicletCard.svelte';
import PicletDetail from '../Piclets/PicletDetail.svelte';
interface Props {
title: string;
type: 'storage' | 'discovered';
items: PicletInstance[];
onBack: () => void;
onItemsChanged?: () => void;
onDragStart?: (instance: PicletInstance) => void;
onDragEnd?: () => void;
}
let { title, type, items, onBack, onItemsChanged, onDragStart, onDragEnd }: Props = $props();
let selectedPiclet: PicletInstance | null = $state(null);
function handleItemClick(item: PicletInstance) {
selectedPiclet = item;
}
</script>
<div class="view-all-page">
<header class="page-header">
<button class="back-btn" onclick={onBack} aria-label="Back">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M19 12H5m0 0l7 7m-7-7l7-7"></path>
</svg>
</button>
<h1>{title}</h1>
<div class="header-spacer"></div>
</header>
<div class="content">
{#if items.length === 0}
<div class="empty-state">
<p>No {type === 'storage' ? 'piclets in storage' : 'discovered piclets'} yet.</p>
</div>
{:else}
<div class="items-grid">
{#each items as item}
{#if type === 'storage'}
<DraggablePicletCard
instance={item}
size={100}
onClick={() => handleItemClick(item)}
onDragStart={onDragStart}
onDragEnd={onDragEnd}
/>
{:else if type === 'discovered'}
<PicletCard
piclet={item}
size={100}
onClick={() => handleItemClick(item)}
/>
{/if}
{/each}
</div>
{/if}
</div>
{#if selectedPiclet}
<PicletDetail
instance={selectedPiclet}
onClose={() => selectedPiclet = null}
onDeleted={() => {
selectedPiclet = null;
onItemsChanged?.();
}}
/>
{/if}
</div>
<style>
.view-all-page {
height: 100%;
display: flex;
flex-direction: column;
background: white;
}
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5rem 1rem;
background: white;
position: sticky;
top: 0;
z-index: 10;
border-bottom: 1px solid #e5e5ea;
}
.page-header h1 {
margin: 0;
font-size: 1.5rem;
font-weight: bold;
color: #333;
}
.back-btn {
background: none;
border: none;
padding: 0.5rem;
cursor: pointer;
color: #007bff;
display: flex;
align-items: center;
justify-content: center;
}
.header-spacer {
width: 40px;
}
.content {
flex: 1;
overflow-y: auto;
padding: 1rem;
padding-bottom: 100px;
}
.empty-state {
display: flex;
align-items: center;
justify-content: center;
height: 200px;
color: #666;
text-align: center;
}
.items-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
gap: 1rem;
justify-items: center;
}
</style> |