design: change weird profile overlap to a list

This commit is contained in:
Xylight committed 2024-05-30 18:15:04 -07:00
1 parent 6c6a3e3e72
commit 1834b90375
5 files changed
+88 -49

No files matched your search

+11 -22
View File
@@ -22,6 +22,8 @@
} from 'svelte-hero-icons'
import Expandable from '../ui/Expandable.svelte'
import LabelStat from '../ui/LabelStat.svelte'
import ItemList from './generic/ItemList.svelte'
import { userLink } from '$lib/lemmy/generic'
export let site: SiteView
export let taglines: Tagline[] | undefined = undefined
@@ -111,28 +113,15 @@
<svelte:fragment slot="title">
<Icon src={UserGroup} size="15" mini /> Admins
</svelte:fragment>
<div
class="flex items-center flex-wrap group transition-all
cursor-pointer"
>
{#each admins as admin}
<Popover openOnHover placement="top">
<a
class="block ring rounded-full ring-slate-50 dark:ring-zinc-950 transition-all -mx-0.5 group-hover:mx-0.5"
href="/u/{admin.person.name}@{new URL(admin.person.actor_id)
.hostname}"
slot="target"
>
<Avatar
width={28}
url={admin.person.avatar}
alt={admin.person.name}
/>
</a>
<span class="font-bold">{admin.person.name}</span>
</Popover>
{/each}
</div>
<ItemList
items={admins.map((a) => ({
id: a.person.id,
name: a.person.name,
url: userLink(a.person),
avatar: a.person.avatar,
instance: new URL(a.person.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
@@ -0,0 +1,47 @@
<script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { Button } from 'mono-svelte'
import { flip } from 'svelte/animate'
import { expoOut } from 'svelte/easing'
export let items: {
avatar?: string
name: string
instance?: string
id: number
url: string
}[]
</script>
{#each items.sort((a, b) => a.name.localeCompare(b.name)) as item (item.id)}
<div
class="inline-flex w-full"
animate:flip={{ duration: 500, easing: expoOut }}
>
<Button
class="font-normal w-full h-max"
color="tertiary"
alignment="left"
href={item.url}
>
<div class="flex-none">
<Avatar
url={item.avatar}
alt={item.name}
title={item.name}
width={24}
slot="prefix"
/>
</div>
<div class="flex flex-col max-w-full break-words">
<span>{item.name}</span>
{#if item.instance}
<span class="text-xs text-slate-600 dark:text-zinc-400">
{item.instance}
</span>
{/if}
</div>
</Button>
</div>
{/each}
@@ -26,7 +26,7 @@
url={follow.icon}
alt={follow.name}
title={follow.title}
width={20}
width={24}
slot="prefix"
/>
</div>
+8
View File
@@ -0,0 +1,8 @@
import { fullCommunityName } from "$lib/util";
import type { Community, Person } from "lemmy-js-client";
export const communityLink = (community: Community, prefix: string = '') =>
`${prefix}/c/${fullCommunityName(community.name, community.actor_id)}`
export const userLink = (person: Person, prefix: string = '') =>
`${prefix}/c/${person.name}@${new URL(person.actor_id).hostname}`
+21 -26
View File
@@ -41,6 +41,9 @@
import PrivateMessageModal from '$lib/components/lemmy/modal/PrivateMessageModal.svelte'
import LabelStat from '$lib/components/ui/LabelStat.svelte'
import PostBody from '$lib/components/lemmy/post/PostBody.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import { communityLink } from '$lib/lemmy/generic.js'
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
export let data
@@ -243,32 +246,24 @@
/>
</div>
{#if (data.moderates ?? []).length > 0}
<div class="flex flex-col gap-2 max-w-full">
<span class="font-bold">Moderates</span>
<div
class="flex items-center -space-x-1 flex-wrap hover:space-x-1 transition-all
cursor-pointer"
>
{#each data.moderates as moderator}
<Popover openOnHover placement="top" class="transition-all">
<a
class="block ring rounded-full ring-slate-50 dark:ring-zinc-950 transition-all"
href="/c/{moderator.community.name}@{new URL(
moderator.community.actor_id
).hostname}"
slot="target"
>
<Avatar
width={28}
url={moderator.community.icon}
alt={moderator.community.title}
/>
</a>
<span class="font-bold">{moderator.community.title}</span>
</Popover>
{/each}
</div>
</div>
<Expandable
class="border-y w-full py-3
dark:border-zinc-800 text-slate-700 dark:text-zinc-300 transition-colors"
>
<span slot="title" class="flex items-center gap-1">
<ShieldIcon width={14} filled />
Moderates
</span>
<ItemList
items={data.moderates.map((m) => ({
id: m.community.id,
name: m.community.title,
url: communityLink(m.community),
avatar: m.community.icon,
instance: new URL(m.community.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
{#if $profile?.user && $profile.jwt && data.person_view.person.id != $profile.user.local_user_view.person.id}
<div class="flex items-center gap-2 w-full">