misc: make community cards consistent
This commit is contained in:
1 parent
dd1dce9b6b
commit
eef339bf4c
9 files changed
+47
-131
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import ItemList from './generic/ItemList.svelte'
|
||||
import { userLink } from '$lib/lemmy/generic'
|
||||
import { t } from '$lib/translations'
|
||||
import Entity from '../ui/Entity.svelte'
|
||||
|
||||
export let site: SiteView
|
||||
export let taglines: Tagline[] | undefined = undefined
|
||||
@@ -26,22 +27,15 @@
|
||||
</script>
|
||||
|
||||
<StickyCard class="w-full {$$props.class} text-slate-600 dark:text-zinc-400">
|
||||
<div class="flex flex-row gap-3 items-center">
|
||||
{#if site.site.icon}
|
||||
<Avatar
|
||||
width={32}
|
||||
url={site.site.icon}
|
||||
alt={site.site.name}
|
||||
circle={false}
|
||||
/>
|
||||
{/if}
|
||||
<div class="flex flex-col">
|
||||
<h1 class="font-bold text-base">{site.site.name}</h1>
|
||||
<span class="text-sm opacity-60">
|
||||
{new URL(site.site.actor_id).hostname}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<Entity name={site.site.name} label={new URL(site.site.actor_id).hostname}>
|
||||
<Avatar
|
||||
width={32}
|
||||
url={site.site.icon}
|
||||
alt={site.site.name}
|
||||
circle={false}
|
||||
slot="icon"
|
||||
/>
|
||||
</Entity>
|
||||
<div class="flex flex-row gap-1 !border-0">
|
||||
<Button
|
||||
href="/modlog"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { client, getClient } from '$lib/lemmy.js'
|
||||
import { addSubscription } from '$lib/lemmy/user.js'
|
||||
import { addSubscription, hasFavorite } from '$lib/lemmy/user.js'
|
||||
import { fullCommunityName } from '$lib/util.js'
|
||||
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
|
||||
import { Button } from 'mono-svelte'
|
||||
@@ -37,6 +37,7 @@
|
||||
NoSymbol,
|
||||
PencilSquare,
|
||||
Plus,
|
||||
Star,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
@@ -47,6 +48,7 @@
|
||||
import ItemList from '../generic/ItemList.svelte'
|
||||
import { communityLink, userLink } from '$lib/lemmy/generic'
|
||||
import { t } from '$lib/translations'
|
||||
import Entity from '$lib/components/ui/Entity.svelte'
|
||||
|
||||
export let community_view: CommunityView
|
||||
export let moderators: CommunityModeratorView[] = []
|
||||
@@ -188,35 +190,24 @@
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
<StickyCard class="min-w-full pt-0 {$$props.class}">
|
||||
<div class="flex flex-row gap-3 items-center">
|
||||
<CommunityLink
|
||||
name={false}
|
||||
avatar
|
||||
avatarSize={32}
|
||||
community={community_view.community}
|
||||
<StickyCard
|
||||
class="min-w-full pt-0 text-slate-600 dark:text-zinc-400 {$$props.class}"
|
||||
>
|
||||
<Entity
|
||||
name={community_view.community.title}
|
||||
label="!{fullCommunityName(
|
||||
community_view.community.name,
|
||||
community_view.community.actor_id
|
||||
)}"
|
||||
>
|
||||
<Avatar
|
||||
width={32}
|
||||
url={community_view.community.icon}
|
||||
alt={community_view.community.name}
|
||||
circle={false}
|
||||
slot="icon"
|
||||
/>
|
||||
<div class="flex flex-col gap-0">
|
||||
<h1 class="font-bold text-lg">
|
||||
<a
|
||||
href="/c/{fullCommunityName(
|
||||
community_view.community.name,
|
||||
community_view.community.actor_id
|
||||
)}"
|
||||
>
|
||||
{community_view.community.title}
|
||||
</a>
|
||||
</h1>
|
||||
<span
|
||||
class="dark:text-zinc-400 text-slate-600 text-sm break-words max-w-full"
|
||||
style="word-break: break-all;"
|
||||
>
|
||||
!{community_view.community.name}@{new URL(
|
||||
community_view.community.actor_id
|
||||
).hostname}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Entity>
|
||||
|
||||
<div
|
||||
class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 [&>*]:py-3"
|
||||
@@ -267,7 +258,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-row items-center gap-2 sticky bottom-0 drop-shadow-xl w-full"
|
||||
class="flex flex-row items-center gap-1 sticky bottom-0 drop-shadow-xl w-full"
|
||||
>
|
||||
{#if $profile?.jwt}
|
||||
<Button
|
||||
|
||||
@@ -39,12 +39,14 @@
|
||||
class="aspect-square object-cover overflow-hidden {$$props.class}"
|
||||
style="width: {width}px; height: {width}px;"
|
||||
class:rounded-full={circle}
|
||||
class:rounded-md={!circle}
|
||||
/>
|
||||
{:else}
|
||||
<div
|
||||
style="width: {width}px; height: {width}px;"
|
||||
class="aspect-square object-cover overflow-hidden {$$props.class}"
|
||||
class:rounded-full={circle}
|
||||
class:rounded-md={!circle}
|
||||
>
|
||||
{@html createAvatar(initials, {
|
||||
seed: alt,
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<Avatar url={icon} width={32} />
|
||||
<slot name="icon">
|
||||
<Avatar url={icon} width={32} />
|
||||
</slot>
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{name}</span>
|
||||
<span class="font-bold text-base">{name}</span>
|
||||
<span class="text-sm">{label}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,73 +101,6 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
|
||||
{#if $profile}
|
||||
<div
|
||||
class="px-2 border-r border-l border-slate-200 dark:border-zinc-900
|
||||
flex flex-row items-center gap-2 [&>*]:flex-shrink-0 overflow-x-auto overflow-y-hidden
|
||||
md:max-w-64 sm:max-w-48 max-w-36 w-full max-[424px]:hidden"
|
||||
>
|
||||
{#each $profile.favorites ?? [] as favorite (favorite.id)}
|
||||
<div
|
||||
class="h-10 w-10 flex"
|
||||
transition:scale={{
|
||||
start: 0.7,
|
||||
easing: backOut,
|
||||
duration: 400,
|
||||
delay: 0,
|
||||
}}
|
||||
animate:flip={{
|
||||
easing: backOut,
|
||||
duration: 400,
|
||||
delay: 0,
|
||||
}}
|
||||
>
|
||||
<NavButton
|
||||
class="w-full h-full bg-slate-100 dark:bg-zinc-900 relative"
|
||||
title={favorite.name}
|
||||
href={favorite.url.toString()}
|
||||
label={favorite.name}
|
||||
>
|
||||
{#if favorite.type == 'post'}
|
||||
<div
|
||||
class="relative w-full h-full grid place-items-center overflow-visible"
|
||||
>
|
||||
{#if favorite.subdivision}
|
||||
<Avatar
|
||||
alt={favorite.subdivision.name}
|
||||
url={favorite.subdivision.avatar}
|
||||
width={32}
|
||||
res={64}
|
||||
class=""
|
||||
/>
|
||||
<Icon
|
||||
src={PencilSquare}
|
||||
mini
|
||||
size="20"
|
||||
class="absolute -bottom-1 -right-1 rounded-full bg-slate-100 dark:bg-zinc-900 p-0.5"
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<Avatar
|
||||
alt={favorite.name}
|
||||
url={favorite.avatar}
|
||||
res={64}
|
||||
width={32}
|
||||
class="w-full"
|
||||
/>
|
||||
<Icon
|
||||
src={Newspaper}
|
||||
mini
|
||||
size="20"
|
||||
class="absolute -bottom-1 -right-1 rounded-full bg-slate-100 dark:bg-zinc-900 p-0.5"
|
||||
/>
|
||||
{/if}
|
||||
</NavButton>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="ml-auto" />
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<NavButton
|
||||
|
||||
@@ -354,7 +354,9 @@
|
||||
"modlog": "Modlog",
|
||||
"block": "Block",
|
||||
"unblock": "Unblock",
|
||||
"blockInstance": "Block instance"
|
||||
"blockInstance": "Block instance",
|
||||
"favorite": "Favorite",
|
||||
"unfavorite": "Remove Favorite"
|
||||
}
|
||||
},
|
||||
"admin": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile, type Profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { trycatch } from '$lib/util.js'
|
||||
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
||||
@@ -62,3 +62,6 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
||||
person_id: user.person.person.id,
|
||||
})
|
||||
})
|
||||
|
||||
export const hasFavorite = (profile: Profile, id: number): boolean =>
|
||||
profile?.favorites?.map((i) => i.id).includes(id) ?? false
|
||||
+3
-2
@@ -105,6 +105,7 @@ export const defaultSettings: Settings = {
|
||||
},
|
||||
expandSidebar: toBool(env.PUBLIC_EXPAND_SIDEBAR) ?? true,
|
||||
expandCommunities: toBool(env.PUBLIC_EXPAND_COMMUNITIES) ?? true,
|
||||
expandFavorites: toBool(env.PUBLIC_EXPAND_FAVORITES) ?? true,
|
||||
displayNames: toBool(env.PUBLIC_DISPLAY_NAMES) ?? true,
|
||||
nsfwBlur: toBool(env.PUBLIC_NSFW_BLUR) ?? true,
|
||||
moderation: {
|
||||
@@ -144,8 +145,8 @@ export const defaultSettings: Settings = {
|
||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
||||
showHidden: false,
|
||||
},
|
||||
language: null,
|
||||
translator: undefined,
|
||||
language: env.PUBLIC_LANGUAGE ?? null,
|
||||
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
@@ -36,18 +36,6 @@
|
||||
)
|
||||
})
|
||||
|
||||
afterNavigate(() => {
|
||||
if ($profile) {
|
||||
addResumable({
|
||||
avatar: data.community.community_view.community.icon,
|
||||
id: data.community.community_view.community.id,
|
||||
url: $page.url,
|
||||
name: data.community.community_view.community.title,
|
||||
type: 'community',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
if (browser) {
|
||||
if ($navigating?.to?.route?.id == '/create/post') return
|
||||
|
||||
Reference in new issue
Block a user