fix: move badges back to normal spot

This commit is contained in:
Xylight committed 2024-07-01 11:34:24 -07:00
1 parent 5f34a102c3
commit 5407a0e62d
1 file changed
+58 -48
+58 -48
View File
@@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte' import CommunityLink from "$lib/components/lemmy/community/CommunityLink.svelte";
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from "$lib/components/ui/Avatar.svelte";
import { Badge } from 'mono-svelte' import { Badge } from "mono-svelte";
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from "$lib/components/lemmy/user/UserLink.svelte";
import RelativeDate from '$lib/components/util/RelativeDate.svelte' import RelativeDate from "$lib/components/util/RelativeDate.svelte";
import type { Community, Person, SubscribedType } from 'lemmy-js-client' import type { Community, Person, SubscribedType } from "lemmy-js-client";
import { import {
Bookmark, Bookmark,
Check, Check,
@@ -14,23 +14,23 @@
Megaphone, Megaphone,
Plus, Plus,
Trash, Trash,
} from 'svelte-hero-icons' } from "svelte-hero-icons";
import { getInstance } from '$lib/lemmy.js' import { getInstance } from "$lib/lemmy.js";
import { profile } from '$lib/auth.js' import { profile } from "$lib/auth.js";
import Subscribe from '../../../../routes/communities/Subscribe.svelte' import Subscribe from "../../../../routes/communities/Subscribe.svelte";
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from "../moderation/ShieldIcon.svelte";
import { userSettings } from '$lib/settings' import { userSettings } from "$lib/settings";
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from "$lib/components/markdown/Markdown.svelte";
import { t } from '$lib/translations' import { t } from "$lib/translations";
export let community: Community | undefined = undefined export let community: Community | undefined = undefined;
export let subscribed: SubscribedType | undefined = undefined export let subscribed: SubscribedType | undefined = undefined;
export let user: Person | undefined = undefined export let user: Person | undefined = undefined;
export let published: Date | undefined = undefined export let published: Date | undefined = undefined;
export let title: string | undefined = undefined export let title: string | undefined = undefined;
export let id: number | undefined = undefined export let id: number | undefined = undefined;
export let read: boolean = false export let read: boolean = false;
// Badges // Badges
export let badges = { export let badges = {
@@ -42,23 +42,25 @@
locked: false, locked: false,
moderator: false, moderator: false,
admin: false, admin: false,
} };
</script> </script>
<div <div
class="grid w-full meta {community class="grid w-full meta {community
? 'grid-rows-2' ? 'grid-rows-2'
: 'grid-rows-1'} text-xs min-w-0 max-w-full" : 'grid-rows-1'} text-xs min-w-0 max-w-full"
style={$$props.style ?? ''} style={$$props.style ?? ""}
> >
{#if community} {#if community}
<Subscribe let:subscribe let:subscribing> <Subscribe let:subscribe let:subscribing>
<button <button
on:click={async () => { on:click={async () => {
if (!community) return if (!community) return;
await subscribe(community.id, subscribed) await subscribe(community.id, subscribed);
subscribed = subscribed =
subscribed == 'NotSubscribed' ? 'Subscribed' : 'NotSubscribed' subscribed == "NotSubscribed"
? "Subscribed"
: "NotSubscribed";
}} }}
class="relative cursor-pointer pr-2 row-span-2 flex-shrink-0" class="relative cursor-pointer pr-2 row-span-2 flex-shrink-0"
> >
@@ -71,14 +73,15 @@
/> />
{#if subscribed != undefined && $profile?.jwt} {#if subscribed != undefined && $profile?.jwt}
<div <div
class="absolute w-3.5 h-3.5 {subscribed == 'NotSubscribed' class="absolute w-3.5 h-3.5 {subscribed ==
'NotSubscribed'
? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black' ? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black'
: 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border : 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border
ring-slate-50 dark:ring-zinc-950 ring-slate-50 dark:ring-zinc-950
-bottom-1 right-1 grid place-items-center transition-all" -bottom-1 right-1 grid place-items-center transition-all"
> >
<Icon <Icon
src={subscribed == 'NotSubscribed' ? Plus : Check} src={subscribed == "NotSubscribed" ? Plus : Check}
mini mini
size="12" size="12"
/> />
@@ -119,51 +122,63 @@
style="grid-area: badges;" style="grid-area: badges;"
> >
{#if badges.nsfw} {#if badges.nsfw}
<Badge label={$t('post.badges.nsfw')} color="red-subtle" allowIconOnly> <Badge
label={$t("post.badges.nsfw")}
color="red-subtle"
allowIconOnly
>
<Icon src={ExclamationTriangle} size="14" micro slot="icon" /> <Icon src={ExclamationTriangle} size="14" micro slot="icon" />
{$t('post.badges.nsfw')} {$t("post.badges.nsfw")}
</Badge> </Badge>
{/if} {/if}
{#if badges.saved} {#if badges.saved}
<Badge <Badge
label={$t('post.badges.saved')} label={$t("post.badges.saved")}
color="yellow-subtle" color="yellow-subtle"
allowIconOnly allowIconOnly
> >
<Icon src={Bookmark} micro size="14" slot="icon" /> <Icon src={Bookmark} micro size="14" slot="icon" />
{$t('post.badges.saved')} {$t("post.badges.saved")}
</Badge> </Badge>
{/if} {/if}
{#if badges.locked} {#if badges.locked}
<Badge <Badge
label={$t('post.badges.locked')} label={$t("post.badges.locked")}
color="yellow-subtle" color="yellow-subtle"
allowIconOnly allowIconOnly
> >
<Icon src={LockClosed} micro size="14" slot="icon" /> <Icon src={LockClosed} micro size="14" slot="icon" />
<span class="max-md:hidden">{$t('post.badges.locked')}</span> <span class="max-md:hidden">{$t("post.badges.locked")}</span>
</Badge> </Badge>
{/if} {/if}
{#if badges.removed} {#if badges.removed}
<Badge label={$t('post.badges.removed')} color="red-subtle" allowIconOnly> <Badge
label={$t("post.badges.removed")}
color="red-subtle"
allowIconOnly
>
<Icon src={Trash} micro size="14" slot="icon" /> <Icon src={Trash} micro size="14" slot="icon" />
<span class="max-md:hidden">{$t('post.badges.removed')}</span> <span class="max-md:hidden">{$t("post.badges.removed")}</span>
</Badge> </Badge>
{/if} {/if}
{#if badges.deleted} {#if badges.deleted}
<Badge label={$t('post.badges.deleted')} color="red-subtle" allowIconOnly> <Badge
label={$t("post.badges.deleted")}
color="red-subtle"
allowIconOnly
>
<Icon src={Trash} micro size="14" slot="icon" /> <Icon src={Trash} micro size="14" slot="icon" />
<span class="max-md:hidden">{$t('post.badges.deleted')}</span> <span class="max-md:hidden">{$t("post.badges.deleted")}</span>
</Badge> </Badge>
{/if} {/if}
{#if badges.featured} {#if badges.featured}
<Badge <Badge
label={$t('post.badges.featured')} label={$t("post.badges.featured")}
color="green-subtle" color="green-subtle"
allowIconOnly allowIconOnly
> >
<Icon src={Megaphone} micro size="14" slot="icon" /> <Icon src={Megaphone} micro size="14" slot="icon" />
<span class="max-md:hidden">{$t('post.badges.featured')}</span> <span class="max-md:hidden">{$t("post.badges.featured")}</span>
</Badge> </Badge>
{/if} {/if}
<slot name="badges" /> <slot name="badges" />
@@ -189,15 +204,10 @@
.meta { .meta {
display: grid; display: grid;
grid-template-areas: grid-template-areas:
'avatar community' "avatar community badges"
'avatar stats' "avatar stats badges";
'badges badges';
gap: 0; gap: 0;
grid-template-rows: auto auto auto; grid-template-rows: auto auto;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
} }
.badges:not(:empty) {
padding-top: 0.5rem;
}
</style> </style>