Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: use drip-list-badge in streams table (closes #700) #706

Merged
merged 6 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions src/lib/components/table/cells/user-badge.cell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import IdentityBadge from '$lib/components/identity-badge/identity-badge.svelte';
import { z } from 'zod';
import type { AddressDriverAccount, NFTDriverAccount } from '$lib/stores/streams/types';
import DripListBadge from '$lib/components/drip-list-badge/drip-list-badge.svelte';
import DripListService from '$lib/utils/driplist/DripListService';
import type { AccountId } from '$lib/utils/common-types';
import type { DripList } from '$lib/utils/metadata/types';
import DripListIcon from 'radicle-design-system/icons/DripList.svelte';

export let context: CellContext<unknown, unknown>;

let user: AddressDriverAccount | NFTDriverAccount;
let dripList: DripList | null | undefined;

$: {
const value = context.getValue();

Expand All @@ -24,35 +30,31 @@
]);

user = userSchema.parse(value);

if (user.driver === 'nft' && dripList === undefined) {
getDripList(user.accountId);
}
}

async function getDripList(listId: AccountId) {
const dripListService = await DripListService.new();
dripList = await dripListService.getByTokenId(listId);
}
</script>

{#if user.driver === 'address'}
<IdentityBadge address={user.address} />
{:else}
<!-- TODO: Donʼt presume any NFT account is a Drip List. -->
<div class="drip-list-badge">
<div class="icon">
<DripListIcon style="fill: var(--color-background); height: 1.25rem;" />
{#if dripList}
<DripListBadge
listName={dripList.name}
listId={user.accountId}
owner={dripList.account.owner.address}
/>
{:else}
<div class="flex items-center gap-2">
<DripListIcon /> <span class="animate-pulse">...</span>
</div>
<span class="typo-text">Your Drip List</span>
</div>
{/if}
{/if}

<style>
.drip-list-badge {
display: flex;
align-items: center;
gap: 0.5rem;
}

.icon {
height: 1.5rem;
width: 1.5rem;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-foreground);
border-radius: 50%;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if (stream) {
streamName =
stream.receiver.driver === 'nft'
? 'Drip List Support Stream'
? 'Drip List support stream'
: stream.name ?? 'Unnamed stream';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
// TODO: Donʼt presume that any stream to an NFT subaccount is going to a Drip List.
const streamName =
stream.receiver.driver === 'nft'
? 'Drip List Support Stream'
? 'Drip List support stream'
: stream.name ?? 'Unnamed stream';

return {
Expand Down
Loading