misc: update post page

This commit is contained in:
Xylight committed 2024-04-30 17:56:31 -07:00
1 parent 0ebb4df0f7
commit 8e6d705f2b
3 files changed
+52 -47

No files matched your search

+6 -1
View File
@@ -32,7 +32,12 @@
<StickyCard class="w-full {$$props.class} text-slate-600 dark:text-zinc-400"> <StickyCard class="w-full {$$props.class} text-slate-600 dark:text-zinc-400">
<div class="flex flex-row gap-3 items-center"> <div class="flex flex-row gap-3 items-center">
{#if site.site.icon} {#if site.site.icon}
<Avatar width={32} url={site.site.icon} alt={site.site.name} /> <Avatar
width={32}
url={site.site.icon}
alt={site.site.name}
circle={false}
/>
{/if} {/if}
<div class="flex flex-col"> <div class="flex flex-col">
<h1 class="font-bold text-base">{site.site.name}</h1> <h1 class="font-bold text-base">{site.site.name}</h1>
+2 -2
View File
@@ -12,7 +12,7 @@
import { page } from '$app/stores' import { page } from '$app/stores'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { Icon, XMark } from 'svelte-hero-icons' import { Icon, XMark } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing' import { backOut, expoOut } from 'svelte/easing'
import { fade, scale } from 'svelte/transition' import { fade, scale } from 'svelte/transition'
/** /**
@@ -40,7 +40,7 @@
height={400} height={400}
src={$page.state.openImage} src={$page.state.openImage}
class="w-full h-auto object-contain max-w-screen-sm mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900" class="w-full h-auto object-contain max-w-screen-sm mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900"
transition:scale={{ start: 0.9, easing: expoOut }} transition:scale={{ start: 0.9, easing: backOut }}
{alt} {alt}
/> />
</div> </div>
@@ -15,30 +15,17 @@
ArrowLeft, ArrowLeft,
ArrowPath, ArrowPath,
ChevronDoubleUp, ChevronDoubleUp,
ExclamationTriangle,
Icon, Icon,
InformationCircle, InformationCircle,
Plus, Home,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte' import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte' import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { import { Material, Select, removeToast, toast } from 'mono-svelte'
Badge,
Disclosure,
Material,
Select,
Spinner,
removeToast,
toast,
} from 'mono-svelte'
import type { CommentSortType } from 'lemmy-js-client' import type { CommentSortType } from 'lemmy-js-client'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import { instance } from '$lib/instance.js' import { instance } from '$lib/instance.js'
import { afterNavigate, goto } from '$app/navigation' import { afterNavigate, goto } from '$app/navigation'
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
import Link from '$lib/components/input/Link.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte' import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
@@ -54,6 +41,7 @@
import Post from '$lib/components/lemmy/post/Post.svelte' import Post from '$lib/components/lemmy/post/Post.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte' import Expandable from '$lib/components/ui/Expandable.svelte'
import { addResumable } from '$lib/lemmy/item.js' import { addResumable } from '$lib/lemmy/item.js'
import { Popover } from 'mono-svelte'
export let data export let data
@@ -74,17 +62,6 @@
afterNavigate(async () => { afterNavigate(async () => {
// reactivity hack // reactivity hack
post = data.post post = data.post
if ($page.params.instance.toLowerCase() != $instance.toLowerCase()) {
if (!$profile?.jwt) return
toast({
content: 'Do you want to open this post on your home instance?',
action: () => {
if ($profile?.jwt) fetchOnHome($profile.jwt)
},
duration: 9999 * 1000,
})
}
if ($profile) { if ($profile) {
addResumable({ addResumable({
avatar: post.post_view.post.thumbnail_url avatar: post.post_view.post.thumbnail_url
@@ -144,6 +121,9 @@
} }
let commenting = false let commenting = false
$: remoteView =
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
</script> </script>
<svelte:head> <svelte:head>
@@ -164,23 +144,43 @@
{/if} {/if}
</svelte:head> </svelte:head>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2 {remoteView ? '' : ''}">
{#if $page.params.instance?.toLowerCase() != $instance.toLowerCase()} {#if remoteView}
<Material <div
class="p-4 flex flex-row gap-1 border class="sticky top-0 bg-slate-50 dark:bg-zinc-950 z-20
border-yellow-300 dark:bg-yellow-950/30 dark:border-yellow-900 bg-yellow-50" border-b border-zinc-800
-mx-4 -mt-4 md:-mt-6 md:-mx-6 sticky-header px-4 py-2
flex items-center gap-2 mb-4 h-12
"
> >
<Icon <Popover openOnHover>
src={ExclamationTriangle} <Icon
width={24} src={InformationCircle}
solid size="24"
class="text-yellow-500" solid
/> slot="target"
<p class="text-sm text-yellow-700 dark:text-yellow-300"> class="bg-slate-200 dark:bg-zinc-700 p-0.5 rounded-full text-primary-900 dark:text-primary-100"
This URL is for a different instance than you're logged into. You />
probably won't be able to vote or comment. This post was fetched from a different server than your account's. Many actions
</p> won't work.
</Material> </Popover>
<span class="text-primary-900 dark:text-primary-100 font-bold">
Remote View
</span>
{#if $profile?.jwt}
<Button
class="ml-auto"
on:click={() => {
if ($profile?.jwt) {
fetchOnHome($profile?.jwt)
}
}}
>
<Icon src={Home} mini size="16" />
Local View
</Button>
{/if}
</div>
{/if} {/if}
<div class="flex flex-row justify-between items-center gap-2 flex-wrap"> <div class="flex flex-row justify-between items-center gap-2 flex-wrap">
@@ -280,8 +280,8 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
elevation="max" elevation="max"
padding="none" padding="none"
color="distinct" color="distinct"
class="py-2 px-4 text-sm flex flex-row justify-between items-center class="py-2 px-4 text-sm flex sm:flex-row justify-between items-center
flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4" sm:gap-4 sticky top-20 w-full box-border z-20 mt-4 flex-col gap-2"
> >
<p class="font-medium text-sm flex items-center gap-2"> <p class="font-medium text-sm flex items-center gap-2">
<Icon src={InformationCircle} mini size="20" /> <Icon src={InformationCircle} mini size="20" />