misc: misc optimizations
This commit is contained in:
1 parent
fe262c1cc1
commit
68bd45b034
10 files changed
+154
-96
No files matched your search
@@ -1,10 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth.js'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { Person } from 'lemmy-js-client'
|
||||
import { Badge } from 'mono-svelte'
|
||||
import { Icon, NoSymbol } from 'svelte-hero-icons'
|
||||
|
||||
export let user: Person
|
||||
@@ -12,23 +10,14 @@
|
||||
export let avatarSize: number = 24
|
||||
export let badges: boolean = true
|
||||
export let inComment: boolean = false
|
||||
export let showInstance: boolean = false
|
||||
export let shownBadges = {
|
||||
admin: true,
|
||||
you: false,
|
||||
bot: true,
|
||||
banned: true,
|
||||
}
|
||||
|
||||
function linkFromCommunity(user: Person) {
|
||||
const domain = new URL(user.actor_id).hostname
|
||||
return `/u/${user.name}@${domain}`
|
||||
}
|
||||
export let showInstance: boolean =
|
||||
$userSettings.showInstances.user ||
|
||||
($userSettings.showInstances.comments && inComment)
|
||||
</script>
|
||||
|
||||
<a
|
||||
class="items-center inline-flex flex-row gap-1 hover:underline"
|
||||
href={linkFromCommunity(user)}
|
||||
href="/u/${user.name}@${new URL(user.actor_id).hostname}"
|
||||
>
|
||||
{#if avatar}
|
||||
<Avatar url={user.avatar} alt={user.name} width={avatarSize} />
|
||||
@@ -39,36 +28,27 @@
|
||||
class:text-red-500={user.admin}
|
||||
class:font-bold={user.admin}
|
||||
>
|
||||
<span
|
||||
class:font-medium={($userSettings.showInstances.comments && inComment) ||
|
||||
$userSettings.showInstances.user ||
|
||||
showInstance}
|
||||
>
|
||||
{$userSettings.displayNames ? user.display_name ?? user.name : user.name}
|
||||
<span class:font-medium={showInstance}>
|
||||
{user.name}
|
||||
</span>
|
||||
{#if $userSettings.showInstances.user || ($userSettings.showInstances.comments && inComment) || showInstance}
|
||||
{#if showInstance}
|
||||
<span class="text-slate-500 dark:text-zinc-500 font-normal">
|
||||
@{new URL(user.actor_id).hostname}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
{#if badges}
|
||||
{#if shownBadges.you}
|
||||
<Badge color="green-subtle" label="You" class="text-[10px] px-1 py-[1px]">
|
||||
You
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if shownBadges.admin && user.admin}
|
||||
{#if user.admin}
|
||||
<div class="text-red-500" title="Admin">
|
||||
<ShieldIcon width={12} filled />
|
||||
</div>
|
||||
{/if}
|
||||
{#if shownBadges.banned && user.banned}
|
||||
{#if user.banned}
|
||||
<div class="text-red-500" title="Banned">
|
||||
<Icon src={NoSymbol} mini size="12" />
|
||||
</div>
|
||||
{/if}
|
||||
{#if shownBadges.bot && user.bot_account}
|
||||
{#if user.bot_account}
|
||||
<div class="text-blue-500 font-bold" title="Bot">BOT</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user