-
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.
- Loading branch information
1 parent
a8f1c58
commit 5c03cbf
Showing
22 changed files
with
254 additions
and
79 deletions.
There are no files selected for viewing
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Loadable } from './loadable.svelte' | ||
export { default as LoadableQuery } from './loadable-query.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,14 @@ | ||
<script lang="ts"> | ||
import type { OperationResultStore } from '@urql/svelte' | ||
import Loadable from './loadable.svelte' | ||
type Data = $$Generic | ||
// not sure why this is needed, but svelte cannot type the forwarded slot prop without it | ||
type $$Slots = { default: { loaded: Data } } | ||
export let query: OperationResultStore<Data> | ||
</script> | ||
|
||
<Loadable error={$query.error} data={$query.data} let:loaded> | ||
<slot {loaded} /> | ||
</Loadable> |
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,23 @@ | ||
<script lang="ts"> | ||
import { ErrorMessage } from '../ErrorMessage' | ||
import { Loading } from '../Loading' | ||
type T = $$Generic | ||
export let error: unknown | ||
export let data: T | null | undefined | ||
$: loaded = data as T | ||
</script> | ||
|
||
<div class="grid h-full"> | ||
{#if error} | ||
<ErrorMessage {error} /> | ||
{:else if loaded} | ||
<slot {loaded} /> | ||
{:else} | ||
<div class="place-self-center"> | ||
<Loading /> | ||
</div> | ||
{/if} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Tokens } from './tokens.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,25 @@ | ||
<script lang="ts"> | ||
import { MaxItems } from '$lib/client/constants' | ||
import type { FetchPOAPTokensData } from '$lib/client/poap' | ||
import type { POAPEventMetadata, POAPTokenWithEvent } from '$lib/types/poap' | ||
import { collectItems } from '$lib/utils/items' | ||
import { Token } from '../Token' | ||
export let tokenData: FetchPOAPTokensData | ||
export let metadata: Record<string, POAPEventMetadata> = {} | ||
export let max = MaxItems | ||
const set = new Set<string>() | ||
let tokens: POAPTokenWithEvent[] = [] | ||
$: tokens = collectItems(set, max, tokens, tokenData.tokens, ({ id }) => id).sort( | ||
(a, b) => Number(b.created) - Number(a.created), | ||
) | ||
</script> | ||
|
||
<div class="grid grid-cols-1 auto-rows-min gap-2 py-2 w-full"> | ||
{#each tokens as token (token.id)} | ||
<Token {token} event={token.event} metadata={metadata[token.event.id]} /> | ||
{/each} | ||
</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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,17 @@ | ||
<script lang="ts"> | ||
import { queryPOAPTokens } from '$lib/client/poap' | ||
import { AppFrame } from '$lib/components/AppFrame' | ||
import { ErrorMessage } from '$lib/components/ErrorMessage' | ||
import { Loading } from '$lib/components/Loading' | ||
import { Token } from '$lib/components/Token' | ||
import type { POAPTokenWithEvent } from '$lib/types/poap' | ||
import { collectItems } from '$lib/utils/items' | ||
import { LoadableQuery } from '$lib/components/Loadable' | ||
import { Tokens } from '$lib/components/Tokens' | ||
import type { PageData } from './$types' | ||
export let data: PageData | ||
const query = queryPOAPTokens(data.max, data.initialData).poll() | ||
const set = new Set<string>() | ||
let tokens: POAPTokenWithEvent[] = [] | ||
$: tokens = collectItems(set, data.max, tokens, $query.data?.tokens, ({ id }) => id) | ||
</script> | ||
|
||
<AppFrame context={{ tokenId: tokens[0].id }}> | ||
<div class="grid h-full"> | ||
{#if $query.error} | ||
<ErrorMessage error={$query.error} /> | ||
{:else if tokens} | ||
<div class="grid grid-cols-1 auto-rows-min gap-2 py-2 w-full"> | ||
{#each tokens as token (token.id)} | ||
<Token {token} event={token.event} /> | ||
{/each} | ||
</div> | ||
{:else} | ||
<div class="place-self-center"> | ||
<Loading /> | ||
</div> | ||
{/if} | ||
</div> | ||
<AppFrame context={{ tokenId: $query.data?.tokens[0].id }}> | ||
<LoadableQuery {query} let:loaded> | ||
<Tokens tokenData={loaded} max={data.max} /> | ||
</LoadableQuery> | ||
</AppFrame> |
Oops, something went wrong.