-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make paper view components async
- Loading branch information
1 parent
ad4eb59
commit 006741b
Showing
45 changed files
with
409 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 23 additions & 15 deletions
38
src/lib/components/composites/paper-components/PaperInfo.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
<script lang="ts"> | ||
import { Skeleton } from "$lib/components/primitives/skeleton"; | ||
import type { Paper, PaperSpec } from "$lib/model/backend"; | ||
import { getNames } from "$lib/utils/common-helper"; | ||
interface Props { | ||
paper: Paper | PaperSpec; | ||
loadingPaper: Promise<Paper | PaperSpec>; | ||
} | ||
const { paper }: Props = $props(); | ||
const { loadingPaper }: Props = $props(); | ||
</script> | ||
|
||
<div class="grid grid-flow-row gap-0"> | ||
<div class="flex flex-row gap-1 items-center truncate"> | ||
{#if "id" in paper} | ||
<div class="w-fit text-default-sb-nc text-neutral-500">#{paper.id}</div> | ||
{/if} | ||
<h2 class="place-content-center truncate">{paper.title}</h2> | ||
{#await loadingPaper} | ||
<div class="grid grid-flow-row gap-1.5"> | ||
<Skeleton class="h-6 w-56 sm:w-80 md:w-[30rem] lg:w-[44rem] rounded-full" /> | ||
<Skeleton class="h-[1.125rem] w-28 sm:w-40 md:w-[15rem] lg:w-[22rem] rounded-full" /> | ||
</div> | ||
<div class="flex flex-row items-center text-hint truncate"> | ||
{#if paper.authors.length > 0} | ||
<span class="place-content-start truncate">{getNames(paper.authors)}</span> | ||
{:else} | ||
<span class="italic">unknown authors</span> | ||
{/if} | ||
{:then paper} | ||
<div class="grid grid-flow-row gap-0"> | ||
<div class="flex flex-row gap-1 items-center truncate"> | ||
{#if "id" in paper} | ||
<div class="w-fit text-default-sb-nc text-neutral-500">#{paper.id}</div> | ||
{/if} | ||
<h2 class="place-content-center truncate">{paper.title}</h2> | ||
</div> | ||
<div class="flex flex-row items-center text-hint truncate"> | ||
{#if paper.authors.length > 0} | ||
<span class="place-content-start truncate">{getNames(paper.authors)}</span> | ||
{:else} | ||
<span class="italic">unknown authors</span> | ||
{/if} | ||
</div> | ||
</div> | ||
</div> | ||
{/await} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/lib/components/composites/paper-components/paper-view/PaperDetail.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<script lang="ts"> | ||
import Skeleton from "$lib/components/primitives/skeleton/skeleton.svelte"; | ||
import type { Paper } from "$lib/model/backend"; | ||
import { cn } from "$lib/utils/shadcn-helper"; | ||
import type { WithElementRef } from "bits-ui"; | ||
import ToggleableInput from "../../input/ToggleableInput.svelte"; | ||
import type { HTMLAttributes } from "svelte/elements"; | ||
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & { | ||
key: string; | ||
value: unknown; | ||
loadingPaper: Promise<Paper>; | ||
areDetailsInEditMode: boolean; | ||
}; | ||
const { key, value, loadingPaper, areDetailsInEditMode }: Props = $props(); | ||
</script> | ||
|
||
<!-- | ||
@component | ||
Paper Detail component to display a single detail of a paper. | ||
Usage: | ||
```svelte | ||
<PaperDetail id={key} {key} {value} {loadingPaper} {areDetailsInEditMode} /> | ||
``` | ||
--> | ||
<div class="flex flex-row gap-2"> | ||
<!-- Match top padding of input --> | ||
<span class="w-24 pt-[0.3125rem]">{key}</span> | ||
{#await loadingPaper} | ||
<div class="pt-2"> | ||
<Skeleton class={cn("flex h-[1.625rem] rounded-full", value as string)} /> | ||
</div> | ||
{:then} | ||
<ToggleableInput isEditable={areDetailsInEditMode} {value} /> | ||
{:catch error} | ||
<span class="pt-2 text-error">Coudn't load {key}: {error}</span> | ||
{/await} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.