|
11 | 11 | projectSort as sortOptions, |
12 | 12 | uploadQueue |
13 | 13 | } from '$globalStore'; |
| 14 | + import { tagColors } from '$lib/constants'; |
14 | 15 | import logger from '$lib/logger'; |
15 | 16 | import type { Project } from '$lib/types'; |
16 | 17 |
|
17 | | - import ProjectDialogs from './ProjectDialogs.svelte'; |
18 | 18 | import ExportProjectButton from './ExportProjectButton.svelte'; |
| 19 | + import ProjectDialogs from './ProjectDialogs.svelte'; |
| 20 | + import ProjectsThumbsFetch from './ProjectsThumbsFetch.svelte'; |
19 | 21 | import { m } from '$lib/paraglide/messages'; |
20 | 22 | import { getLocale } from '$lib/paraglide/runtime'; |
21 | 23 | import InputText from '$lib/components/InputText.svelte'; |
|
53 | 55 | { id: 'updated_at', title: m['sortable.updated_at'](), Icon: SortByIcon } |
54 | 56 | ]; |
55 | 57 |
|
| 58 | + let projectsThumbs = $state<{ [projectID: string]: string }>({}); |
| 59 | +
|
56 | 60 | let searchQuery = $state(''); |
57 | 61 | let isLoadingSearch = $state(false); |
58 | 62 |
|
|
206 | 210 | const offset = target.scrollHeight - target.clientHeight - target.scrollTop; |
207 | 211 | const LOAD_THRESHOLD = 1000; |
208 | 212 |
|
209 | | - if (offset < LOAD_THRESHOLD && !isLoadingProjects && !moreProjectsFinished) { |
| 213 | + if ( |
| 214 | + orgProjects.length > 0 && |
| 215 | + offset < LOAD_THRESHOLD && |
| 216 | + !isLoadingProjects && |
| 217 | + !moreProjectsFinished |
| 218 | + ) { |
| 219 | + fetchController?.abort('Duplicate'); |
210 | 220 | await getProjects(); |
211 | 221 | } |
212 | 222 | }; |
|
330 | 340 |
|
331 | 341 | {#if !loadingProjectsError} |
332 | 342 | <div |
333 | | - style="grid-auto-rows: 128px;" |
| 343 | + style="grid-auto-rows: 240px;" |
334 | 344 | class="grid grow grid-flow-row grid-cols-[minmax(15rem,1fr)] gap-4 px-1 pb-4 pt-1 sm:grid-cols-[repeat(auto-fill,_minmax(300px,_1fr))]" |
335 | 345 | > |
336 | 346 | {#if isLoadingProjects} |
|
347 | 357 | title={project.id} |
348 | 358 | class="flex flex-col rounded-lg border border-[#E5E5E5] bg-white transition-[transform,box-shadow] hover:-translate-y-0.5 hover:shadow-float data-dark:border-[#333] data-dark:bg-[#42464E]" |
349 | 359 | > |
350 | | - <div class="flex grow items-start justify-between p-3"> |
351 | | - <div class="flex items-start gap-1.5"> |
352 | | - <span class="rounded bg-[#FFEFF2] p-1"> |
353 | | - <Clipboard class="h-4 w-4 flex-[0_0_auto] text-[#950048]" /> |
354 | | - </span> |
| 360 | + <div class="relative p-2"> |
| 361 | + {#if projectsThumbs[project.id]} |
| 362 | + <!-- Temp fix for url --> |
| 363 | + <img |
| 364 | + src={projectsThumbs[project.id].replace('http://', 'https://')} |
| 365 | + class="h-28 w-full rounded-md object-cover" |
| 366 | + alt="" |
| 367 | + /> |
| 368 | + {:else if !project.cover_picture_url} |
| 369 | + <div class="flex h-28 items-center justify-center rounded-md bg-secondary"> |
| 370 | + <Clipboard class="h-10 w-10 text-white" /> |
| 371 | + </div> |
| 372 | + {:else} |
| 373 | + <div class="flex h-28 items-center justify-center"> |
| 374 | + <LoadingSpinner class="h-4 w-4 text-secondary" /> |
| 375 | + </div> |
| 376 | + {/if} |
| 377 | + |
| 378 | + <div class="absolute right-0 top-0 flex flex-wrap justify-end gap-1 p-3"> |
| 379 | + {#each (project.tags ?? []).slice(0, 5) as tag, index} |
| 380 | + <span |
| 381 | + style="background-color: {tagColors[index % tagColors.length]};" |
| 382 | + class="select-none rounded-md px-1.5 py-[3px] text-xs text-white" |
| 383 | + > |
| 384 | + {tag} |
| 385 | + </span> |
| 386 | + {/each} |
| 387 | + |
| 388 | + {#if (project.tags ?? []).slice(5).length > 0} |
| 389 | + <span |
| 390 | + class="select-none rounded-md bg-black px-1.5 py-[3px] text-xs text-white" |
| 391 | + > |
| 392 | + +{(project.tags ?? []).slice(5).length} |
| 393 | + </span> |
| 394 | + {/if} |
| 395 | + </div> |
| 396 | + </div> |
| 397 | + |
| 398 | + <div class="flex grow items-start justify-between px-3 pb-1 pt-1"> |
| 399 | + <div class="flex h-full flex-col items-start gap-1"> |
355 | 400 | <span class="line-clamp-2 text-[#475467] [word-break:break-word]"> |
356 | 401 | {project.name} |
357 | 402 | </span> |
| 403 | + |
| 404 | + <p class="h-1 grow overflow-auto text-sm text-[#667085]"> |
| 405 | + {project.description ?? ''} |
| 406 | + </p> |
358 | 407 | </div> |
359 | 408 |
|
360 | 409 | <DropdownMenu.Root> |
|
456 | 505 | {orgProjects} |
457 | 506 | {refetchProjects} |
458 | 507 | /> |
| 508 | +<ProjectsThumbsFetch {orgProjects} bind:projectsThumbs /> |
0 commit comments