fix: respect nsfw rules in compact mode
This commit is contained in:
1 parent
1401e30a09
commit
6291e7e3d3
5 files changed
+55
-6
No files matched your search
@@ -1,7 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
|
import { t } from '$lib/translations'
|
||||||
import type { Community } from 'lemmy-js-client'
|
import type { Community } from 'lemmy-js-client'
|
||||||
|
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let community: Community
|
export let community: Community
|
||||||
|
|
||||||
@@ -10,6 +12,10 @@
|
|||||||
export let avatarSize: number = 24
|
export let avatarSize: number = 24
|
||||||
export let showInstance: boolean = $userSettings.showInstances.community
|
export let showInstance: boolean = $userSettings.showInstances.community
|
||||||
export let displayName: boolean = true
|
export let displayName: boolean = true
|
||||||
|
|
||||||
|
export let badges = {
|
||||||
|
nsfw: false,
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
@@ -43,6 +49,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if badges}
|
||||||
|
{#if badges.nsfw}
|
||||||
|
<Icon
|
||||||
|
src={ExclamationTriangle}
|
||||||
|
size="14"
|
||||||
|
micro
|
||||||
|
title={$t('post.badges.nsfw')}
|
||||||
|
class="text-red-600 dark:text-red-400"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
removed: post.post.removed,
|
removed: post.post.removed,
|
||||||
locked: post.post.locked,
|
locked: post.post.locked,
|
||||||
featured: post.post.featured_local || post.post.featured_community,
|
featured: post.post.featured_local || post.post.featured_community,
|
||||||
nsfw: post.post.nsfw,
|
nsfw: post.post.nsfw || post.community.nsfw,
|
||||||
saved: post.saved,
|
saved: post.saved,
|
||||||
admin: post.creator_is_admin,
|
admin: post.creator_is_admin,
|
||||||
moderator: post.creator_is_moderator,
|
moderator: post.creator_is_moderator,
|
||||||
@@ -154,6 +154,7 @@
|
|||||||
? 'mr-3'
|
? 'mr-3'
|
||||||
: 'ml-3'} flex-shrink no-list-margin"
|
: 'ml-3'} flex-shrink no-list-margin"
|
||||||
style="grid-area: media;"
|
style="grid-area: media;"
|
||||||
|
blur={rule == 'blur' ? true : undefined}
|
||||||
{view}
|
{view}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
{community}
|
{community}
|
||||||
style="grid-area: community;"
|
style="grid-area: community;"
|
||||||
class="flex-shrink no-list-margin"
|
class="flex-shrink no-list-margin"
|
||||||
|
badges={{
|
||||||
|
nsfw: community.nsfw,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -57,11 +57,11 @@
|
|||||||
src={bestImageURL(post, false, -1)}
|
src={bestImageURL(post, false, -1)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="max-h-[inherit] max-w-full h-auto z-30
|
class="max-h-[inherit] max-w-full h-auto z-30
|
||||||
transition-opacity duration-500 object-contain mx-auto
|
transition-opacity duration-500 object-contain mx-auto blur-[64px]
|
||||||
{imageLoaded === false ? 'opacity-0' : 'opacity-100'}"
|
{imageLoaded === false ? 'opacity-0' : 'opacity-100'}"
|
||||||
width={512}
|
width={512}
|
||||||
height={300}
|
height={300}
|
||||||
class:blur-3xl={blur}
|
class:blur-[64px]={blur}
|
||||||
alt={post.alt_text ?? ''}
|
alt={post.alt_text ?? ''}
|
||||||
on:load={() => (imageLoaded = true)}
|
on:load={() => (imageLoaded = true)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,11 +10,18 @@
|
|||||||
import { isImage } from '$lib/ui/image'
|
import { isImage } from '$lib/ui/image'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { Material, Popover } from 'mono-svelte'
|
import { Material, Popover } from 'mono-svelte'
|
||||||
import { DocumentText, Icon, Link, VideoCamera } from 'svelte-hero-icons'
|
import {
|
||||||
|
DocumentText,
|
||||||
|
Icon,
|
||||||
|
Link,
|
||||||
|
VideoCamera,
|
||||||
|
ExclamationTriangle,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let post: Post
|
export let post: Post
|
||||||
export let type: MediaType = 'none'
|
export let type: MediaType = 'none'
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
|
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
|
||||||
|
|
||||||
const thumbnailSize = (view: View) =>
|
const thumbnailSize = (view: View) =>
|
||||||
view == 'compact' ? 'w-22 h-22 sm:w-28' : 'w-24 h-24 sm:w-32'
|
view == 'compact' ? 'w-22 h-22 sm:w-28' : 'w-24 h-24 sm:w-32'
|
||||||
@@ -61,12 +68,15 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
{#if post.thumbnail_url || isImage(post.url)}
|
{#if post.thumbnail_url || isImage(post.url)}
|
||||||
|
<div class="relative overflow-hidden rounded-xl">
|
||||||
|
<picture class="relative">
|
||||||
<img
|
<img
|
||||||
src={optimizeImageURL(post.thumbnail_url || post.url || '', 196)}
|
src={optimizeImageURL(post.thumbnail_url || post.url || '', 256)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl
|
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl
|
||||||
transition-colors {size}"
|
transition-colors {size}"
|
||||||
alt={post.name}
|
alt={post.name}
|
||||||
|
class:blur-xl={blur}
|
||||||
/>
|
/>
|
||||||
{#if type != 'image'}
|
{#if type != 'image'}
|
||||||
<div
|
<div
|
||||||
@@ -74,7 +84,25 @@
|
|||||||
backdrop-blur-sm bg-slate-25/75 dark:bg-zinc-900/75 border border-slate-200/75 dark:border-zinc-700/75
|
backdrop-blur-sm bg-slate-25/75 dark:bg-zinc-900/75 border border-slate-200/75 dark:border-zinc-700/75
|
||||||
grid place-items-center"
|
grid place-items-center"
|
||||||
>
|
>
|
||||||
<Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" />
|
<Icon
|
||||||
|
src={type == 'iframe' ? VideoCamera : Link}
|
||||||
|
micro
|
||||||
|
size="16"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
|
{#if blur}
|
||||||
|
<div
|
||||||
|
class="absolute w-full h-full grid place-items-center inset-0 z-30"
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
src={ExclamationTriangle}
|
||||||
|
solid
|
||||||
|
size="32"
|
||||||
|
class="z-50 opacity-30"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
Reference in new issue
Block a user