impr: improve semantics and optimize elements
This commit is contained in:
15 files changed
+151
-179
No files matched your search
@@ -32,6 +32,7 @@
|
|||||||
icon?: import('svelte').Snippet
|
icon?: import('svelte').Snippet
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
resolveObject?: boolean
|
resolveObject?: boolean
|
||||||
|
actions?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
resolveObject,
|
resolveObject,
|
||||||
|
actions = true,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -64,12 +66,10 @@
|
|||||||
class="flex-1 w-full overflow-hidden"
|
class="flex-1 w-full overflow-hidden"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
<div
|
<div class="flex flex-row gap-2 items-center">
|
||||||
class="flex {view == 'cozy'
|
{#if icon}
|
||||||
? 'flex-col gap-2'
|
{@render icon()}
|
||||||
: 'flex-row'} gap-2 items-center"
|
{:else if community.community.nsfw && settings.nsfwBlur}
|
||||||
>
|
|
||||||
{#if icon}{@render icon()}{:else if community.community.nsfw && settings.nsfwBlur}
|
|
||||||
<div class="w-8 h-8 rounded-xl bg-red-400"></div>
|
<div class="w-8 h-8 rounded-xl bg-red-400"></div>
|
||||||
{:else}
|
{:else}
|
||||||
<Avatar
|
<Avatar
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{#if children}
|
{#if children || !actions}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-row items-center gap-2">
|
<div class="flex flex-row items-center gap-2">
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
-->
|
-->
|
||||||
<article
|
<article
|
||||||
class={[
|
class={[
|
||||||
'post relative max-w-full min-w-0 w-full cursor-pointer outline-hidden group/post',
|
'relative cursor-pointer group/post',
|
||||||
settings.leftAlign && 'left-align',
|
settings.leftAlign && 'left-align',
|
||||||
view == 'compact' && 'py-3 list-type compact',
|
view == 'compact' && 'py-3 list-type compact',
|
||||||
view == 'cozy' && 'py-5 flex flex-col gap-2',
|
view == 'cozy' && 'py-5 flex flex-col gap-2',
|
||||||
@@ -141,13 +141,6 @@
|
|||||||
{#if actions}
|
{#if actions}
|
||||||
<PostActions {onhide} bind:post style="grid-area: actions;" {view} />
|
<PostActions {onhide} bind:post style="grid-area: actions;" {view} />
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
|
||||||
class="absolute overflow-hidden inset-0
|
|
||||||
sm:rounded-xl bg-slate-50 dark:bg-zinc-900
|
|
||||||
opacity-0 transition-all -z-50 no-list-margin
|
|
||||||
group-hover/post:inset-y-0.5 group-hover/post:-inset-x-3 sm:group-hover/post:-inset-x-5 group-hover/post:opacity-100
|
|
||||||
duration-150"
|
|
||||||
></div>
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
|
|||||||
@@ -147,7 +147,6 @@
|
|||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
<button
|
<button
|
||||||
{@attach attachment}
|
{@attach attachment}
|
||||||
|
|
||||||
class={[
|
class={[
|
||||||
'row-span-2 shrink-0 mr-2 self-center group/btn',
|
'row-span-2 shrink-0 mr-2 self-center group/btn',
|
||||||
'bg-slate-200 dark:bg-zinc-800 rounded-lg cursor-pointer',
|
'bg-slate-200 dark:bg-zinc-800 rounded-lg cursor-pointer',
|
||||||
@@ -339,16 +338,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
<a
|
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
|
||||||
href={settings.posts.titleOpensUrl && postUrl
|
<h3
|
||||||
? postUrl
|
|
||||||
: `/post/${encodeURIComponent(instance.data)}/${id}`}
|
|
||||||
target={settings.posts.titleOpensUrl || settings.openLinksInNewTab
|
|
||||||
? '_blank'
|
|
||||||
: undefined}
|
|
||||||
class={[
|
class={[
|
||||||
'inline max-sm:mt-0!',
|
'max-sm:m-0!',
|
||||||
'hover:underline hover:text-primary-900 dark:hover:text-primary-100 transition-colors',
|
|
||||||
'font-medium text-balance max-w-xl',
|
'font-medium text-balance max-w-xl',
|
||||||
titleClass,
|
titleClass,
|
||||||
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
||||||
@@ -356,15 +349,24 @@
|
|||||||
]}
|
]}
|
||||||
style="grid-area: title;"
|
style="grid-area: title;"
|
||||||
>
|
>
|
||||||
{#if title}
|
<a
|
||||||
|
href={useAttachedUrl
|
||||||
|
? postUrl
|
||||||
|
: `/post/${encodeURIComponent(instance.data)}/${id}`}
|
||||||
|
target={useAttachedUrl
|
||||||
|
? '_blank'
|
||||||
|
: undefined}
|
||||||
|
rel={useAttachedUrl ? 'noopener noreferrer' : undefined}
|
||||||
|
class="inline-block hover:underline hover:text-primary-900 dark:hover:text-primary-100 transition-colors"
|
||||||
|
>
|
||||||
<Markdown
|
<Markdown
|
||||||
source={title}
|
source={title}
|
||||||
inline
|
inline
|
||||||
noStyle
|
noStyle
|
||||||
class={view == 'compact' ? '' : 'leading-[1.3]'}
|
class={view != 'compact' ? '' : 'leading-[1.3]'}
|
||||||
></Markdown>
|
/>
|
||||||
{/if}
|
|
||||||
</a>
|
</a>
|
||||||
|
</h3>
|
||||||
{:else}
|
{:else}
|
||||||
<div style="grid-area: title; margin: 0;"></div>
|
<div style="grid-area: title; margin: 0;"></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -49,8 +49,6 @@
|
|||||||
children,
|
children,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let loading = $state(false)
|
|
||||||
|
|
||||||
const castVote = async (newVote: number) => {
|
const castVote = async (newVote: number) => {
|
||||||
if (!profile.current?.jwt) {
|
if (!profile.current?.jwt) {
|
||||||
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
||||||
@@ -85,6 +83,53 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#snippet voteButton(
|
||||||
|
votes: number,
|
||||||
|
target: 'upvote' | 'downvote',
|
||||||
|
vote?: number,
|
||||||
|
)}
|
||||||
|
{@const targetNum = target == 'upvote' ? 1 : -1}
|
||||||
|
<button
|
||||||
|
onclick={() => castVote(vote == targetNum ? 0 : targetNum)}
|
||||||
|
class={[
|
||||||
|
'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2',
|
||||||
|
'first:rounded-l-3xl last:rounded-r-3xl',
|
||||||
|
'last:flex-row-reverse',
|
||||||
|
vote == targetNum
|
||||||
|
? shouldShowVoteColor(
|
||||||
|
vote,
|
||||||
|
target == 'upvote' ? 'upvotes' : 'downvotes',
|
||||||
|
)
|
||||||
|
: 'hover:bg-slate-100 dark:hover:bg-zinc-800',
|
||||||
|
]}
|
||||||
|
aria-pressed={vote == targetNum}
|
||||||
|
aria-label={$t(
|
||||||
|
target == 'upvote'
|
||||||
|
? 'post.actions.vote.upvote'
|
||||||
|
: 'post.actions.vote.downvote',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon src={target == 'upvote' ? ChevronUp : ChevronDown} size="20" micro />
|
||||||
|
{#if showCounts}
|
||||||
|
<div class="grid text-sm z-20">
|
||||||
|
{#key votes}
|
||||||
|
<span
|
||||||
|
style="grid-column: 1; grid-row: 1;"
|
||||||
|
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
||||||
|
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
||||||
|
aria-label={$t(
|
||||||
|
target == 'upvote' ? 'aria.vote.upvotes' : 'aria.vote.downvotes',
|
||||||
|
{ default: votes },
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<FormattedNumber number={votes ?? 0} />
|
||||||
|
</span>
|
||||||
|
{/key}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
{#if children}{@render children({ vote, score })}{:else}
|
{#if children}{@render children({ vote, score })}{:else}
|
||||||
{@const voteRatio = Math.floor(
|
{@const voteRatio = Math.floor(
|
||||||
((upvotes ?? 0) / ((upvotes ?? 0) + (downvotes ?? 0))) * 100,
|
((upvotes ?? 0) / ((upvotes ?? 0) + (downvotes ?? 0))) * 100,
|
||||||
@@ -92,71 +137,18 @@
|
|||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
buttonColor.secondary,
|
buttonColor.secondary,
|
||||||
'rounded-full h-full font-medium flex items-center *:p-2 relative',
|
'rounded-3xl h-full font-medium flex relative',
|
||||||
'hover:bg-white dark:hover:bg-zinc-900 overflow-hidden transition-colors shrink-0',
|
|
||||||
'text-inherit! divide-x divide-slate-200 dark:divide-zinc-800',
|
|
||||||
loading && 'animate-pulse opacity-75 pointer-events-none',
|
|
||||||
voteRatio < 85 && settings.voteRatioBar && 'vote-ratio',
|
voteRatio < 85 && settings.voteRatioBar && 'vote-ratio',
|
||||||
]}
|
]}
|
||||||
role="group"
|
|
||||||
aria-label={$t('aria.vote.group')}
|
aria-label={$t('aria.vote.group')}
|
||||||
style="--vote-ratio: {voteRatio}%;"
|
style="--vote-ratio: {voteRatio}%;"
|
||||||
>
|
>
|
||||||
<button
|
{@render voteButton(upvotes, 'upvote', vote)}
|
||||||
onclick={() => castVote(vote == 1 ? 0 : 1)}
|
<div
|
||||||
class={[
|
class="h-full p-0! border-l border-slate-200 dark:border-zinc-800"
|
||||||
'flex items-center gap-0.5 transition-colors relative cursor-pointer',
|
></div>
|
||||||
vote == 1
|
|
||||||
? shouldShowVoteColor(vote, 'upvotes')
|
|
||||||
: 'hover:bg-slate-100 dark:hover:bg-zinc-800',
|
|
||||||
]}
|
|
||||||
aria-pressed={vote == 1}
|
|
||||||
aria-label={$t('post.actions.vote.upvote')}
|
|
||||||
>
|
|
||||||
<Icon src={ChevronUp} size="20" micro />
|
|
||||||
{#if showCounts}
|
|
||||||
<span class="grid text-sm z-20">
|
|
||||||
{#key upvotes}
|
|
||||||
<span
|
|
||||||
style="grid-column: 1; grid-row: 1;"
|
|
||||||
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
|
||||||
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
|
||||||
aria-label={$t('aria.vote.upvotes', { default: upvotes })}
|
|
||||||
>
|
|
||||||
<FormattedNumber number={upvotes ?? 0} />
|
|
||||||
</span>
|
|
||||||
{/key}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
{#if site.data?.site_view.local_site.enable_downvotes ?? true}
|
{#if site.data?.site_view.local_site.enable_downvotes ?? true}
|
||||||
<button
|
{@render voteButton(downvotes, 'downvote', vote)}
|
||||||
onclick={() => castVote(vote == -1 ? 0 : -1)}
|
|
||||||
class={[
|
|
||||||
'flex items-center flex-row-reverse gap-0.5 transition-colors cursor-pointer',
|
|
||||||
vote == -1
|
|
||||||
? shouldShowVoteColor(vote, 'downvotes')
|
|
||||||
: 'hover:bg-slate-100 dark:hover:bg-zinc-800',
|
|
||||||
]}
|
|
||||||
aria-pressed={vote == -1}
|
|
||||||
aria-label={$t('post.actions.vote.downvote')}
|
|
||||||
>
|
|
||||||
<Icon src={ChevronDown} size="20" micro />
|
|
||||||
{#if showCounts}
|
|
||||||
<span class="grid text-sm">
|
|
||||||
{#key downvotes}
|
|
||||||
<span
|
|
||||||
style="grid-column: 1; grid-row: 1;"
|
|
||||||
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
|
||||||
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
|
||||||
aria-label={$t('aria.vote.downvotes', { default: downvotes })}
|
|
||||||
>
|
|
||||||
<FormattedNumber number={downvotes ?? 0} />
|
|
||||||
</span>
|
|
||||||
{/key}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -167,6 +159,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.vote-ratio::before {
|
.vote-ratio::before {
|
||||||
|
border-radius: var(--radius-3xl);
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
target={settings.openLinksInNewTab ? '_blank' : ''}
|
target={settings.openLinksInNewTab ? '_blank' : ''}
|
||||||
title={$t('post.actions.comments')}
|
aria-label={$t('post.actions.comments')}
|
||||||
>
|
>
|
||||||
{@const newComment =
|
{@const newComment =
|
||||||
publishedToDate(post.counts.newest_comment_time).getTime() >
|
publishedToDate(post.counts.newest_comment_time).getTime() >
|
||||||
@@ -124,7 +124,6 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
animations={{ scale: true, large: true }}
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={BugAnt} micro size="16" />
|
<Icon src={BugAnt} micro size="16" />
|
||||||
@@ -181,7 +180,6 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="custom"
|
size="custom"
|
||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
animations={{ scale: true, large: true }}
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||||
|
|||||||
@@ -206,7 +206,7 @@
|
|||||||
? { duration: 800, easing: expoOut, y: 24, delay: row * 50 }
|
? { duration: 800, easing: expoOut, y: 24, delay: row * 50 }
|
||||||
: { opacity: 1, duration: 0 }}
|
: { opacity: 1, duration: 0 }}
|
||||||
data-index={row}
|
data-index={row}
|
||||||
class={['relative post-container px-3 sm:px-6', row < 7 && '']}
|
class={['relative post-container', row < 7 && '']}
|
||||||
>
|
>
|
||||||
<Post
|
<Post
|
||||||
bind:post={posts[row]}
|
bind:post={posts[row]}
|
||||||
@@ -216,10 +216,10 @@
|
|||||||
settings.posts.compactFeatured
|
settings.posts.compactFeatured
|
||||||
? 'compact'
|
? 'compact'
|
||||||
: settings.view}
|
: settings.view}
|
||||||
class="transition-all duration-250"
|
|
||||||
onhide={() => {
|
onhide={() => {
|
||||||
posts = posts.toSpliced(row, 1)
|
posts = posts.toSpliced(row, 1)
|
||||||
}}
|
}}
|
||||||
|
class="px-3 sm:px-6 hover:bg-slate-100/50 hover:dark:bg-zinc-900/50 transition-colors"
|
||||||
></Post>
|
></Post>
|
||||||
</li>
|
</li>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
padding="sm"
|
padding="sm"
|
||||||
href={url}
|
href={url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
rel="noopener"
|
||||||
>
|
>
|
||||||
{#if thumbnail_url}
|
{#if thumbnail_url}
|
||||||
<img
|
<img
|
||||||
@@ -92,6 +93,7 @@
|
|||||||
<a
|
<a
|
||||||
href={url}
|
href={url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
class="flex flex-row text-slate-900 dark:text-zinc-400 items-center overflow-hidden group/link hover:underline space-x-1 my-1"
|
class="flex flex-row text-slate-900 dark:text-zinc-400 items-center overflow-hidden group/link hover:underline space-x-1 my-1"
|
||||||
>
|
>
|
||||||
<Icon src={Link} size="16" micro class="shrink-0" />
|
<Icon src={Link} size="16" micro class="shrink-0" />
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
type MediaType,
|
type MediaType,
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
} from '$lib/components/lemmy/post/helpers.js'
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import { isImage } from '$lib/ui/image'
|
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { modal } from 'mono-svelte'
|
import { modal } from 'mono-svelte'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
@@ -47,36 +47,33 @@
|
|||||||
@component
|
@component
|
||||||
Thumbnails for compact and list view posts.
|
Thumbnails for compact and list view posts.
|
||||||
-->
|
-->
|
||||||
<div class={[size, 'relative group/media', clazz]} {style}>
|
<div class={[size, 'relative group/media', clazz]} {style} role="presentation">
|
||||||
{#if post.alt_text}
|
|
||||||
<Button
|
|
||||||
rounding="pill"
|
|
||||||
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
|
||||||
onclick={() => modal({ title: 'Alt', body: post.alt_text ?? '' })}
|
|
||||||
>
|
|
||||||
ALT
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
<svelte:element
|
<svelte:element
|
||||||
this={!settings.expandImages || type != 'image' ? 'a' : 'button'}
|
this={!settings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||||
href={postLink(post)}
|
href={post.url ?? postLink(post)}
|
||||||
|
aria-label={type == 'image'
|
||||||
|
? $t('aria.postDecor.openImage', { default: post.name })
|
||||||
|
: type == 'embed'
|
||||||
|
? $t('aria.postDecor.openLink', {
|
||||||
|
default: post.embed_title ?? post.name,
|
||||||
|
})
|
||||||
|
: $t('aria.postDecor.openPost', { default: post.name })}
|
||||||
|
target={post.url ? '_blank' : undefined}
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
if (type == 'image') showImage(bestImageURL(post, false, -1))
|
if (type == 'image') showImage(bestImageURL(post, false, -1))
|
||||||
}}
|
}}
|
||||||
role="button"
|
role={type == 'image' ? 'button' : 'link'}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="cursor-pointer h-full"
|
class="cursor-pointer h-full block"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'relative overflow-hidden rounded-2xl max-h-full h-full',
|
'relative overflow-hidden rounded-2xl max-h-full h-full',
|
||||||
'border border-slate-200 dark:border-zinc-800 hover:border-slate-300 dark:hover:border-zinc-700',
|
'border border-slate-200 dark:border-zinc-800 hover-scale-effect',
|
||||||
'dark:bg-zinc-800 hover-scale-effect',
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{#if post.thumbnail_url || isImage(post.url)}
|
{#if post.thumbnail_url || type == 'image'}
|
||||||
{@const thumbnail =
|
{@const thumbnail = post.thumbnail_url != undefined && type != 'image'}
|
||||||
post.thumbnail_url != undefined && !isImage(post.url)}
|
|
||||||
<picture>
|
<picture>
|
||||||
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
|
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
|
||||||
{#each ['webp'] as format}
|
{#each ['webp'] as format}
|
||||||
@@ -105,28 +102,22 @@
|
|||||||
src={bestImageURL(post, thumbnail, -1, null)}
|
src={bestImageURL(post, thumbnail, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
class={[
|
||||||
'object-cover relative overflow-hidden rounded-xl h-full bg-slate-200 dark:bg-zinc-900',
|
'object-cover relative overflow-hidden rounded-xl h-full',
|
||||||
size,
|
size,
|
||||||
]}
|
]}
|
||||||
alt={post.alt_text ?? ' '}
|
alt={post.alt_text ?? ' '}
|
||||||
class:blur-xl={blur}
|
class:blur-xl={blur}
|
||||||
/>
|
/>
|
||||||
|
</picture>
|
||||||
{#if type != 'image'}
|
{#if type != 'image'}
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'absolute w-8 h-8 m-1 bottom-0 left-0 rounded-xl text-slate-800 dark:text-zinc-200',
|
'absolute w-8 h-8 bottom-1 left-1 rounded-xl bg-slate-25 dark:bg-zinc-900 grid place-items-center',
|
||||||
'bg-slate-25 dark:bg-zinc-900',
|
|
||||||
'grid place-items-center',
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" />
|
||||||
src={type == 'iframe' ? VideoCamera : Link}
|
|
||||||
micro
|
|
||||||
size="16"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</picture>
|
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
sm: 'mt-3 mb-1 px-3',
|
sm: 'mt-3 mb-1 px-3',
|
||||||
md: 'mt-4 mb-2',
|
md: 'mt-4 mb-2',
|
||||||
lg: 'mt-6 mb-2',
|
lg: 'mt-6 mb-2',
|
||||||
|
'bottom-sm': 'mb-1 px-3',
|
||||||
|
'bottom-md': 'mb-2',
|
||||||
|
'bottom-lg': 'mb-3',
|
||||||
}
|
}
|
||||||
|
|
||||||
const colors = {
|
const colors = {
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
border?: boolean
|
border?: boolean
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
action?: import('svelte').Snippet
|
action?: import('svelte').Snippet
|
||||||
|
element?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -38,6 +42,7 @@
|
|||||||
size = 'sm',
|
size = 'sm',
|
||||||
color = 'subtle',
|
color = 'subtle',
|
||||||
margin = 'none',
|
margin = 'none',
|
||||||
|
element = 'h3',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -50,9 +55,12 @@
|
|||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<h3 class="font-medium text-left flex flex-row gap-1 items-center">
|
<svelte:element
|
||||||
|
this={element}
|
||||||
|
class="font-medium text-left flex flex-row gap-1 items-center"
|
||||||
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</h3>
|
</svelte:element>
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'flex-1 border-slate-200/70 dark:border-zinc-800 border-b',
|
'flex-1 border-slate-200/70 dark:border-zinc-800 border-b',
|
||||||
|
|||||||
@@ -927,6 +927,11 @@
|
|||||||
"loading": "Loading",
|
"loading": "Loading",
|
||||||
"element": {
|
"element": {
|
||||||
"pageHeader": "Page header"
|
"pageHeader": "Page header"
|
||||||
|
},
|
||||||
|
"postDecor": {
|
||||||
|
"openImage": "Open image: {{default}}",
|
||||||
|
"openLink": "Open link: {{default}}",
|
||||||
|
"openPost": "Open post: {{default}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
title={label}
|
title={label}
|
||||||
>
|
>
|
||||||
{@render icon?.()}
|
{@render icon?.()}
|
||||||
<span class={allowIconOnly ? 'hidden md:contents' : 'contents'}>
|
<span class={allowIconOnly ? 'sr-only md:contents' : 'contents'}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -5,33 +5,24 @@
|
|||||||
|
|
||||||
export const buttonAlignment = {
|
export const buttonAlignment = {
|
||||||
left: 'justify-start text-left origin-left',
|
left: 'justify-start text-left origin-left',
|
||||||
center: 'justify-center text-center origin-center',
|
center: 'justify-center',
|
||||||
right: 'justify-end text-right origin-right',
|
right: 'justify-end text-right origin-right',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buttonColor = {
|
export const buttonColor = {
|
||||||
primary: `border border-transparent bg-primary-900 text-white
|
primary: `border border-transparent bg-primary-900 text-slate-50 dark:bg-primary-100 dark:text-black`,
|
||||||
dark:bg-primary-100 dark:text-black hover:brightness-125 dark:hover:brightness-90 active:brightness-90
|
secondary: `border border-slate-200 border-b-slate-300 dark:border-zinc-800 bg-white dark:bg-zinc-900`,
|
||||||
dark:active:brightness-75`,
|
|
||||||
|
|
||||||
secondary: `border border-slate-200 border-b-slate-300 dark:border-zinc-800 bg-white dark:bg-zinc-900
|
|
||||||
hover:bg-slate-100 dark:hover:bg-zinc-800 dark:hover:border-zinc-700 dark:active:bg-zinc-900 active:bg-slate-200`,
|
|
||||||
|
|
||||||
tertiary:
|
tertiary:
|
||||||
' bg-transparent hover:bg-slate-200/50 dark:hover:bg-zinc-700/30 dark:text-zinc-200',
|
' bg-transparent hover:bg-slate-200/50 dark:hover:bg-zinc-700/30 dark:text-zinc-200',
|
||||||
|
|
||||||
danger:
|
danger:
|
||||||
'border border-red-500 bg-red-500 hover:text-red-500 hover:bg-transparent text-white',
|
'border border-red-500 bg-red-500 hover:text-red-500 hover:bg-transparent text-white',
|
||||||
'danger-subtle': 'text-red-500 hover:bg-red-500 hover:text-inherit!',
|
'danger-subtle': 'text-red-500 hover:bg-red-500 hover:text-inherit!',
|
||||||
|
|
||||||
'success-subtle': 'text-green-500 hover:bg-green-500 hover:text-inherit!',
|
'success-subtle': 'text-green-500 hover:bg-green-500 hover:text-inherit!',
|
||||||
|
|
||||||
'warning-subtle': 'text-yellow-500 hover:bg-yellow-500 hover:text-inherit!',
|
'warning-subtle': 'text-yellow-500 hover:bg-yellow-500 hover:text-inherit!',
|
||||||
|
|
||||||
ghost: `border border-slate-200 dark:border-zinc-800 bg-transparent
|
ghost: `border border-slate-200 dark:border-zinc-800 bg-transparent
|
||||||
hover:bg-slate-100 dark:hover:bg-zinc-800 dark:hover:border-zinc-700 dark:text-zinc-400 hover:text-inherit
|
hover:bg-slate-100 dark:hover:bg-zinc-800 dark:hover:border-zinc-700 dark:text-zinc-400 hover:text-inherit
|
||||||
dark:hover:text-inherit`,
|
dark:hover:text-inherit`,
|
||||||
|
|
||||||
'blue-subtle': `text-blue-500 hover:bg-blue-500 hover:text-inherit!`,
|
'blue-subtle': `text-blue-500 hover:bg-blue-500 hover:text-inherit!`,
|
||||||
|
|
||||||
none: '',
|
none: '',
|
||||||
@@ -75,7 +66,6 @@
|
|||||||
rounding?: ButtonRoundness
|
rounding?: ButtonRoundness
|
||||||
alignment?: ButtonAlignment
|
alignment?: ButtonAlignment
|
||||||
shadow?: ButtonShadow
|
shadow?: ButtonShadow
|
||||||
column?: boolean
|
|
||||||
loaderWidth?: number | undefined
|
loaderWidth?: number | undefined
|
||||||
href?: string | undefined
|
href?: string | undefined
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
@@ -106,7 +96,6 @@
|
|||||||
rounding = size == 'lg' ? 'xl' : 'lg',
|
rounding = size == 'lg' ? 'xl' : 'lg',
|
||||||
alignment = 'center',
|
alignment = 'center',
|
||||||
shadow = color != 'tertiary' ? 'none' : 'none',
|
shadow = color != 'tertiary' ? 'none' : 'none',
|
||||||
column = false,
|
|
||||||
disabled,
|
disabled,
|
||||||
loaderWidth = undefined,
|
loaderWidth = undefined,
|
||||||
href = undefined,
|
href = undefined,
|
||||||
@@ -129,7 +118,10 @@
|
|||||||
buttonRounding[rounding],
|
buttonRounding[rounding],
|
||||||
buttonShadow[shadow],
|
buttonShadow[shadow],
|
||||||
buttonColor[color],
|
buttonColor[color],
|
||||||
'transition-all font-medium cursor-pointer duration-75 disabled:opacity-50 disabled:pointer-events-none disabled:shadow-none text-sm',
|
buttonAlignment[alignment],
|
||||||
|
'transition-all font-medium cursor-pointer disabled:opacity-50 disabled:pointer-events-none',
|
||||||
|
'hover:brightness-98 hover:dark:brightness-95 active:brightness-90 active:dark:brightness-85 text-sm',
|
||||||
|
'flex flex-row items-center gap-1.5',
|
||||||
(disabled || loading) && 'pointer-events-none opacity-50 shadow-none',
|
(disabled || loading) && 'pointer-events-none opacity-50 shadow-none',
|
||||||
alignment == 'center'
|
alignment == 'center'
|
||||||
? 'origin-center'
|
? 'origin-center'
|
||||||
@@ -139,14 +131,6 @@
|
|||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
type={submit ? 'submit' : 'button'}
|
type={submit ? 'submit' : 'button'}
|
||||||
>
|
|
||||||
<div
|
|
||||||
class={[
|
|
||||||
'flex',
|
|
||||||
column ? 'flex-col justify-center' : 'flex-row items-center',
|
|
||||||
'h-full gap-1.5 button-content w-full',
|
|
||||||
buttonAlignment[alignment],
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner width={loaderWidth ?? 16} />
|
<Spinner width={loaderWidth ?? 16} />
|
||||||
@@ -155,7 +139,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{@render suffix?.()}
|
{@render suffix?.()}
|
||||||
</div>
|
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -103,7 +103,8 @@
|
|||||||
buttonSize[size],
|
buttonSize[size],
|
||||||
buttonShadow[shadow],
|
buttonShadow[shadow],
|
||||||
buttonColor.secondary,
|
buttonColor.secondary,
|
||||||
'appearance-none transition-colors rounded-xl text-sm w-full min-w-full cursor-pointer pr-6',
|
'appearance-none transition-all rounded-xl text-sm w-full min-w-full cursor-pointer pr-6',
|
||||||
|
'hover:brightness-98 hover:dark:brightness-90',
|
||||||
selectClass,
|
selectClass,
|
||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
import { site } from '$lib/lemmy.svelte.js'
|
import { site } from '$lib/lemmy.svelte.js'
|
||||||
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
|
import { Material } from 'mono-svelte'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { ArrowRight, ChartBar, Icon } from 'svelte-hero-icons'
|
import { ArrowRight, ChartBar, Icon } from 'svelte-hero-icons'
|
||||||
@@ -76,15 +78,6 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<!-- <EndPlaceholder size="md">
|
|
||||||
{$t('cards.community.activeDay')}
|
|
||||||
{#snippet action()}
|
|
||||||
<span class="text-primary-900 dark:text-primary-100">
|
|
||||||
{site.data?.site_view.counts.users_active_day.toString()}
|
|
||||||
</span>
|
|
||||||
{/snippet}
|
|
||||||
</EndPlaceholder> -->
|
|
||||||
|
|
||||||
{#await data.feed.value}
|
{#await data.feed.value}
|
||||||
{#each new Array(5) as _, index}{_}
|
{#each new Array(5) as _, index}{_}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -87,12 +87,29 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{data.post.value.post_view.post.name}</title>
|
<title>
|
||||||
|
{data.post.value.post_view.community.title} | {data.post.value.post_view
|
||||||
|
.post.name}
|
||||||
|
</title>
|
||||||
<meta property="og:title" content={data.post.value.post_view.post.name} />
|
<meta property="og:title" content={data.post.value.post_view.post.name} />
|
||||||
|
{#if !data.post.value.post_view.post.local}
|
||||||
|
<meta name="robots" content="noindex, follow" />
|
||||||
|
{/if}
|
||||||
|
<link rel="canonical" href={data.post.value.post_view.post.ap_id} />
|
||||||
|
{#if data.post.value.post_view.post.body}
|
||||||
<meta
|
<meta
|
||||||
property="twitter:title"
|
property="description"
|
||||||
content={data.post.value.post_view.post.name}
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
/>
|
/>
|
||||||
|
<meta
|
||||||
|
property="og:description"
|
||||||
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
property="twitter:description"
|
||||||
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
<meta property="og:url" content={page.url.toString()} />
|
<meta property="og:url" content={page.url.toString()} />
|
||||||
{#if isImage(data.post.value.post_view.post.url)}
|
{#if isImage(data.post.value.post_view.post.url)}
|
||||||
<meta property="og:image" content={data.post.value.post_view.post.url} />
|
<meta property="og:image" content={data.post.value.post_view.post.url} />
|
||||||
@@ -110,23 +127,9 @@
|
|||||||
content={data.post.value.post_view.post.thumbnail_url}
|
content={data.post.value.post_view.post.thumbnail_url}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.post.value.post_view.post.body}
|
|
||||||
<meta
|
|
||||||
property="description"
|
|
||||||
content={data.post.value.post_view.post.body.slice(0, 500)}
|
|
||||||
/>
|
|
||||||
<meta
|
|
||||||
property="og:description"
|
|
||||||
content={data.post.value.post_view.post.body.slice(0, 500)}
|
|
||||||
/>
|
|
||||||
<meta
|
|
||||||
property="twitter:description"
|
|
||||||
content={data.post.value.post_view.post.body.slice(0, 500)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<article class="flex flex-col gap-2 animate-pop-in">
|
<article class="flex flex-col gap-2">
|
||||||
<header class="flex flex-col gap-2">
|
<header class="flex flex-col gap-2">
|
||||||
<div class="flex flex-row items-center gap-2 flex-wrap">
|
<div class="flex flex-row items-center gap-2 flex-wrap">
|
||||||
<PostMeta
|
<PostMeta
|
||||||
|
|||||||
Reference in new issue
Block a user