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 3 commits
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
52 changes: 25 additions & 27 deletions src/lib/components/drip-list-badge/drip-list-badge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,51 @@
import ensStore from '$lib/stores/ens';
import formatAddress from '$lib/utils/format-address';

export let listName: string;
export let listId: string;
export let owner: string;
export let listName: string | undefined = undefined;
export let owner: string | undefined = undefined;

export let showAvatar = true;
export let showName = true;
export let isLinked = true;
export let showAvatar = true;
export let avatarSize: 'small' | 'default' = 'default';

$: ensStore.connected && ensStore.lookup(owner);
$: ens = $ensStore[owner];

$: username = ens?.name ? ens.name : formatAddress(owner);
// lookup ens name if owner is provided
$: owner && ensStore.connected && ensStore.lookup(owner);
$: ens = owner ? $ensStore[owner] : {};
$: username = ens?.name || (owner && formatAddress(owner));
</script>

<svelte:element
this={isLinked ? 'a' : 'div'}
href={isLinked ? `/app/drip-lists/${listId}` : undefined}
tabindex={isLinked ? 0 : -1}
class="drip-list-badge flex gap-2 items-center"
class="drip-list-badge outline-none flex gap-2 items-center"
>
{#if showAvatar}
<div class="drip-list-icon">
<DripListIcon style="fill: var(--color-primary)" />
<div
class="flex items-center justify-center rounded-full flex-shrink-0 bg-primary-level-1 {avatarSize ===
'small'
? 'w-6 h-6'
: 'w-8 h-8'}"
>
<DripListIcon
style="fill: var(--color-primary); {avatarSize === 'small'
? 'width:18px; height:18px;'
: ''}"
/>
</div>
{/if}
{#if showName}
{#if listName}
<div class="name typo-text text-foreground flex-1 min-w-0 truncate">
<span><span class="text-foreground-level-5">{username}/</span>{listName}</span>
<span
>{#if username}<span class="text-foreground-level-5">{username}/</span
>{/if}{@html listName}</span
evvvritt marked this conversation as resolved.
Show resolved Hide resolved
>
</div>
{/if}
</svelte:element>

<style>
.drip-list-icon {
background-color: var(--color-primary-level-1);
height: 2rem;
width: 2rem;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1rem;
flex-shrink: 0;
}

a.drip-list-badge {
outline: none;
}
a.drip-list-badge:focus-visible .name > span {
background: var(--color-primary-level-1);
border-radius: 0.25rem;
Expand Down
3 changes: 0 additions & 3 deletions src/lib/components/splits/components/split/split.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
component: DripListBadge,
props: {
listId: s.listId,
listName: s.listName,
owner: s.listOwner,
showName: false,
},
} as ComponentAndProps;
case 'project-split':
Expand Down
46 changes: 21 additions & 25 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,16 @@
import IdentityBadge from '$lib/components/identity-badge/identity-badge.svelte';
import { z } from 'zod';
import type { AddressDriverAccount, NFTDriverAccount } from '$lib/stores/streams/types';
import DripListIcon from 'radicle-design-system/icons/DripList.svelte';
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';

export let context: CellContext<unknown, unknown>;

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

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

Expand All @@ -24,35 +29,26 @@
]);

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;" />
</div>
<span class="typo-text">Your Drip List</span>
</div>
<DripListBadge
listName={dripList ? dripList.name : '<span class="animate-pulse">...</span>'}
listId={user.accountId}
avatarSize="small"
isLinked={false}
/>
{/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
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export function slotsTemplate(state: State, stepIndex: number): Slots {
component: DripListBadge,
props: {
listId: item.list.id,
listName: item.list.name,
owner: item.list.owner,
showName: false,
},
};
}
Expand Down
Loading