design: use entityheaders for instance and community cards
This commit is contained in:
8 files changed
+161
-122
No files matched your search
@@ -7,8 +7,6 @@
|
||||
import Markdown from '$lib/app/markdown/Markdown.svelte'
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
import { fullCommunityName, userLink } from '$lib/app/util.svelte'
|
||||
import Avatar from '$lib/ui/generic/Avatar.svelte'
|
||||
import Entity from '$lib/ui/generic/Entity.svelte'
|
||||
import ItemList from '$lib/ui/generic/ItemList.svelte'
|
||||
import LabelStat from '$lib/ui/info/LabelStat.svelte'
|
||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||
@@ -108,6 +106,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import EntityHeader from '$lib/ui/generic/EntityHeader.svelte'
|
||||
|
||||
let loading = $state({
|
||||
blocking: false,
|
||||
subscribing: false,
|
||||
@@ -170,24 +170,19 @@
|
||||
clazz,
|
||||
]}
|
||||
>
|
||||
<div class="px-3 overflow-hidden">
|
||||
<Entity
|
||||
name={community_view.community.title}
|
||||
label="!{fullCommunityName(
|
||||
<EntityHeader
|
||||
name={community_view.community.title}
|
||||
avatar={community_view.community.icon}
|
||||
banner={community_view.community.banner}
|
||||
avatarCircle={false}
|
||||
>
|
||||
{#snippet nameDetail()}
|
||||
!{fullCommunityName(
|
||||
community_view.community.name,
|
||||
community_view.community.actor_id,
|
||||
)}"
|
||||
>
|
||||
{#snippet customIcon()}
|
||||
<Avatar
|
||||
width={32}
|
||||
url={community_view.community.icon}
|
||||
alt={community_view.community.name}
|
||||
circle={false}
|
||||
/>
|
||||
{/snippet}
|
||||
</Entity>
|
||||
</div>
|
||||
)}
|
||||
{/snippet}
|
||||
</EntityHeader>
|
||||
|
||||
<EndPlaceholder size="xs" margin="sm">
|
||||
{$t('form.post.community')}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
import Markdown from '$lib/app/markdown/Markdown.svelte'
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
import { userLink } from '$lib/app/util.svelte'
|
||||
import Avatar from '$lib/ui/generic/Avatar.svelte'
|
||||
import EntityHeader from '$lib/ui/generic/EntityHeader.svelte'
|
||||
import ItemList from '$lib/ui/generic/ItemList.svelte'
|
||||
import LabelStat from '$lib/ui/info/LabelStat.svelte'
|
||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||
import SidebarButton from '$lib/ui/sidebar/SidebarButton.svelte'
|
||||
import { Badge, Expandable } from 'mono-svelte'
|
||||
import { Badge, Expandable, Popover } from 'mono-svelte'
|
||||
import {
|
||||
BuildingOffice,
|
||||
Icon,
|
||||
@@ -17,7 +17,6 @@
|
||||
ServerStack,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
|
||||
import { optimizeImageURL } from '../post'
|
||||
|
||||
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||
site: SiteView
|
||||
@@ -36,20 +35,13 @@
|
||||
clazz,
|
||||
]}
|
||||
>
|
||||
{#if site.site.banner}
|
||||
<div class="rounded-xl bg-slate-100 dark:bg-zinc-925">
|
||||
<img
|
||||
src={optimizeImageURL(site.site.banner, 512)}
|
||||
alt="Site banner"
|
||||
class="h-32 object-cover w-full"
|
||||
style="border-radius: inherit;"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mx-3 space-y-3">
|
||||
<Avatar width={32} url={site.site.icon} alt="" circle={false} />
|
||||
<h2 class="font-medium text-lg -my-2">{site.site.name}</h2>
|
||||
</div>
|
||||
<EntityHeader
|
||||
name={site.site.name}
|
||||
avatar={site.site.icon}
|
||||
banner={site.site.banner}
|
||||
compact="always"
|
||||
avatarCircle={false}
|
||||
/>
|
||||
<div class="flex flex-col gap-1">
|
||||
{#if taglines && taglines.length > 0}
|
||||
<Markdown
|
||||
@@ -96,11 +88,34 @@
|
||||
content={site.counts.comments.toString()}
|
||||
formatted
|
||||
/>
|
||||
<LabelStat
|
||||
label={$t('cards.community.activeDay')}
|
||||
content={site.counts.users_active_day.toString()}
|
||||
formatted
|
||||
/>
|
||||
<Popover openOnHover placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<button class="text-left cursor-pointer" {@attach attachment}>
|
||||
<LabelStat
|
||||
label={$t('cards.community.activeDay')}
|
||||
content={site.counts.users_active_day.toString()}
|
||||
formatted
|
||||
/>
|
||||
</button>
|
||||
{/snippet}
|
||||
<div class="flex flex-row gap-4 flex-wrap px-3">
|
||||
<LabelStat
|
||||
label={$t('filter.sort.top.time.week')}
|
||||
content={site.counts.users_active_week.toString()}
|
||||
formatted
|
||||
/>
|
||||
<LabelStat
|
||||
label={$t('filter.sort.top.time.month')}
|
||||
content={site.counts.users_active_month.toString()}
|
||||
formatted
|
||||
/>
|
||||
<LabelStat
|
||||
label={$t('filter.sort.top.time.6months')}
|
||||
content={site.counts.users_active_half_year.toString()}
|
||||
formatted
|
||||
/>
|
||||
</div>
|
||||
</Popover>
|
||||
<LabelStat
|
||||
label={$t('content.communities')}
|
||||
content={site.counts.communities.toString()}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
onclick={() => castVote(vote == targetNum ? 0 : targetNum)}
|
||||
class={[
|
||||
'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2 active:brightness-90',
|
||||
'first:rounded-l-3xl last:rounded-r-3xl',
|
||||
'first:rounded-l-[inherit] last:rounded-r-[inherit]',
|
||||
'last:flex-row-reverse',
|
||||
vote == targetNum
|
||||
? shouldShowVoteColor(
|
||||
@@ -137,7 +137,7 @@
|
||||
<div
|
||||
class={[
|
||||
buttonColor.ghost,
|
||||
'rounded-3xl h-full font-medium flex relative hover:bg-transparent!',
|
||||
'rounded-full h-full font-medium flex relative hover:bg-transparent!',
|
||||
voteRatio < 85 && settings.voteRatioBar && 'vote-ratio',
|
||||
]}
|
||||
aria-label={$t('aria.vote.group')}
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
import { profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { settings, type View } from '$lib/app/settings.svelte'
|
||||
import { instanceToURL } from '$lib/app/util.svelte'
|
||||
import { save } from '$lib/feature/legacy/contentview'
|
||||
import { publishedToDate } from '$lib/ui/util/date'
|
||||
import FormattedNumber from '$lib/ui/util/FormattedNumber.svelte'
|
||||
import { Button, Menu, Modal, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
Button,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuDivider,
|
||||
Modal,
|
||||
Spinner,
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
import {
|
||||
Bookmark,
|
||||
BookmarkSlash,
|
||||
@@ -14,7 +23,10 @@
|
||||
ChatBubbleOvalLeft,
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
EllipsisHorizontal,
|
||||
GlobeAlt,
|
||||
Icon,
|
||||
MapPin,
|
||||
Share,
|
||||
ShieldCheck,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import { PostVote } from '..'
|
||||
@@ -42,6 +54,21 @@
|
||||
}: Props = $props()
|
||||
let buttonHeight = $derived(view == 'compact' ? 'h-7.5' : 'h-8')
|
||||
let buttonSquare = $derived(view == 'compact' ? 'w-7.5 h-7.5' : 'w-8 h-8')
|
||||
|
||||
function share(global: boolean = true) {
|
||||
const link = global
|
||||
? post.post.ap_id
|
||||
: `${instanceToURL(profile.current.instance)}/post/${post.post.id}`
|
||||
|
||||
if (navigator.share)
|
||||
navigator.share?.({
|
||||
url: link,
|
||||
})
|
||||
else {
|
||||
navigator.clipboard.writeText(link)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if editing}
|
||||
@@ -116,6 +143,7 @@
|
||||
<FormattedNumber number={post.counts.comments} />
|
||||
</Button>
|
||||
<div class="flex-1"></div>
|
||||
|
||||
{#if settings.debugInfo}
|
||||
{#if debug}
|
||||
{#await import('$lib/ui/util/debug/DebugObject.svelte') then { default: DebugObject }}
|
||||
@@ -170,6 +198,30 @@
|
||||
></Button>
|
||||
{/if}
|
||||
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button
|
||||
{@attach post.post.local ? () => {} : attachment}
|
||||
rounding="pill"
|
||||
color="ghost"
|
||||
size="custom"
|
||||
class={buttonSquare}
|
||||
onclick={() => {
|
||||
if (post.post.local) share()
|
||||
}}
|
||||
icon={Share}
|
||||
title={$t('post.actions.more.share')}
|
||||
/>
|
||||
{/snippet}
|
||||
<MenuDivider showLabel>{$t('post.actions.more.share.from')}</MenuDivider>
|
||||
<MenuButton onclick={() => share(true)} icon={GlobeAlt}>
|
||||
{$t('post.actions.more.share.global')}
|
||||
</MenuButton>
|
||||
<MenuButton onclick={() => share(false)} icon={MapPin}>
|
||||
{$t('post.actions.more.share.local')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target(popover)}
|
||||
<Button
|
||||
|
||||
@@ -7,20 +7,15 @@
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { setSessionStorage } from '$lib/app/session'
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
import { instanceToURL } from '$lib/app/util.svelte'
|
||||
import { deleteItem, markAsRead } from '$lib/feature/legacy/contentview'
|
||||
import { report } from '$lib/feature/moderation/moderation'
|
||||
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
||||
import { MenuButton } from 'mono-svelte'
|
||||
import {
|
||||
ArrowTopRightOnSquare,
|
||||
EllipsisHorizontal,
|
||||
Eye,
|
||||
EyeSlash,
|
||||
Flag,
|
||||
GlobeAlt,
|
||||
MapPin,
|
||||
PencilSquare,
|
||||
Share,
|
||||
Trash,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
@@ -33,21 +28,6 @@
|
||||
}
|
||||
|
||||
let { post = $bindable(), onhide, editing = $bindable() }: Props = $props()
|
||||
|
||||
function share(global: boolean = true) {
|
||||
const link = global
|
||||
? post.post.ap_id
|
||||
: `${instanceToURL(profile.current.instance)}/post/${post.post.id}`
|
||||
|
||||
if (navigator.share)
|
||||
navigator.share?.({
|
||||
url: link,
|
||||
})
|
||||
else {
|
||||
navigator.clipboard.writeText(link)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
||||
@@ -68,36 +48,6 @@
|
||||
: $t('post.actions.more.markRead')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<div class="flex flex-row">
|
||||
<MenuButton
|
||||
onclick={() => share()}
|
||||
class={['flex-1', !post.post.local && 'rounded-r-lg']}
|
||||
icon={Share}
|
||||
>
|
||||
{$t('post.actions.more.share')}
|
||||
</MenuButton>
|
||||
{#if !post.post.local}
|
||||
<Menu>
|
||||
{#snippet target(attachment)}
|
||||
<Button
|
||||
{@attach attachment}
|
||||
aria-label={$t('post.actions.more.label')}
|
||||
color="tertiary"
|
||||
size="custom"
|
||||
class="w-6 h-6 self-center"
|
||||
data-autoclose="false"
|
||||
icon={EllipsisHorizontal}
|
||||
></Button>
|
||||
{/snippet}
|
||||
<MenuButton onclick={() => share(true)} icon={GlobeAlt}>
|
||||
{$t('filter.location.global')}
|
||||
</MenuButton>
|
||||
<MenuButton onclick={() => share(false)} icon={MapPin}>
|
||||
{$t('filter.location.local')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
</div>
|
||||
{#if profile.current?.jwt}
|
||||
<MenuButton
|
||||
onclick={() => {
|
||||
|
||||
Reference in new issue
Block a user