misc: Switch to thumbnails for avatars
This commit is contained in:
1 parent
cf372442d8
commit
ce19dd3a17
9 files changed
+45
-29
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import type { Community } from 'lemmy-js-client'
|
import type { Community } from 'lemmy-js-client'
|
||||||
|
|
||||||
export let community: Community
|
export let community: Community
|
||||||
@@ -16,14 +17,11 @@
|
|||||||
href={linkFromCommunity(community)}
|
href={linkFromCommunity(community)}
|
||||||
>
|
>
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<img
|
<Avatar
|
||||||
src={community.icon ??
|
url={community.icon ??
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${community.name}`}
|
`https://api.dicebear.com/6.x/initials/svg?seed=${community.name}`}
|
||||||
alt=""
|
alt={community.name}
|
||||||
width={avatarSize}
|
width={avatarSize}
|
||||||
height={avatarSize}
|
|
||||||
class="rounded-full aspect-square object-cover"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{community.title}
|
{community.title}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
DEFAULT_INSTANCE_URL,
|
DEFAULT_INSTANCE_URL,
|
||||||
authData,
|
authData,
|
||||||
getClient,
|
getClient,
|
||||||
|
getInstance,
|
||||||
user,
|
user,
|
||||||
} from '$lib/lemmy.js'
|
} from '$lib/lemmy.js'
|
||||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||||
@@ -75,7 +76,7 @@
|
|||||||
<span class="opacity-50 capitalize" />
|
<span class="opacity-50 capitalize" />
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
href="/post/{postRes.post.id}"
|
href="/post/{getInstance()}/{postRes.post.id}"
|
||||||
class="font-bold {postRes.read ? 'opacity-50' : ''}"
|
class="font-bold {postRes.read ? 'opacity-50' : ''}"
|
||||||
>
|
>
|
||||||
{postRes.post.name}
|
{postRes.post.name}
|
||||||
@@ -90,7 +91,10 @@
|
|||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if isImage(postRes.post.url)}
|
{#if isImage(postRes.post.url)}
|
||||||
<a href="/post/{postRes.post.id}" class="inline self-start">
|
<a
|
||||||
|
href="/post/{getInstance()}/{postRes.post.id}"
|
||||||
|
class="inline self-start"
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
src={postRes.post.url}
|
src={postRes.post.url}
|
||||||
alt={postRes.post.name}
|
alt={postRes.post.name}
|
||||||
@@ -100,7 +104,10 @@
|
|||||||
</a>
|
</a>
|
||||||
{:else if isVideo(postRes.post.url)}
|
{:else if isVideo(postRes.post.url)}
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
<a href="/post/{postRes.post.id}" class="inline self-start">
|
<a
|
||||||
|
href="/post/{getInstance()}/{postRes.post.id}"
|
||||||
|
class="inline self-start"
|
||||||
|
>
|
||||||
<video class="rounded-md max-h-64 max-w-full" preload="metadata">
|
<video class="rounded-md max-h-64 max-w-full" preload="metadata">
|
||||||
<source src={postRes.post.url} />
|
<source src={postRes.post.url} />
|
||||||
</video>
|
</video>
|
||||||
@@ -127,7 +134,7 @@
|
|||||||
bg-slate-100 dark:bg-zinc-800 hover:bg-slate-200
|
bg-slate-100 dark:bg-zinc-800 hover:bg-slate-200
|
||||||
dark:hover:bg-zinc-700 transition-colors border border-slate-200
|
dark:hover:bg-zinc-700 transition-colors border border-slate-200
|
||||||
dark:border-zinc-700"
|
dark:border-zinc-700"
|
||||||
href="/post/{postRes.post.id}"
|
href="/post/{getInstance()}/{postRes.post.id}"
|
||||||
>
|
>
|
||||||
<Icon src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
<Icon src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
||||||
<span class="text-sm">
|
<span class="text-sm">
|
||||||
@@ -142,9 +149,7 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
`${$page.url.origin}/post/${
|
`${$page.url.origin}/post/${getInstance()}/${postRes.post.id}`
|
||||||
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
|
||||||
}/${postRes.post.id}`
|
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
import MarkdownLink from '$lib/components/markdown/MarkdownLink.svelte'
|
import MarkdownLink from '$lib/components/markdown/MarkdownLink.svelte'
|
||||||
import MarkdownQuote from '$lib/components/markdown/MarkdownQuote.svelte'
|
import MarkdownQuote from '$lib/components/markdown/MarkdownQuote.svelte'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
|
import MarkdownList from '$lib/components/markdown/MarkdownList.svelte'
|
||||||
|
|
||||||
export let source: string | undefined
|
export let source: string | undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="break-words">
|
<div class="break-words flex flex-col gap-1">
|
||||||
<SvelteMarkdown
|
<SvelteMarkdown
|
||||||
{source}
|
{source}
|
||||||
renderers={{
|
renderers={{
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
heading: MarkdownHeader,
|
heading: MarkdownHeader,
|
||||||
hr: MarkdownHr,
|
hr: MarkdownHr,
|
||||||
blockquote: MarkdownQuote,
|
blockquote: MarkdownQuote,
|
||||||
|
list: MarkdownList,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if depth == 1}
|
{#if depth == 1}
|
||||||
<h1 class="font-bold text-3xl"><slot /></h1>
|
<h1 class="font-bold text-3xl my-2"><slot /></h1>
|
||||||
{:else if depth == 2}
|
{:else if depth == 2}
|
||||||
<h2 class="font-bold text-2xl"><slot /></h2>
|
<h2 class="font-bold text-2xl my-2"><slot /></h2>
|
||||||
{:else if depth == 3}
|
{:else if depth == 3}
|
||||||
<h3 class="font-bold text-xl"><slot /></h3>
|
<h3 class="font-bold text-xl my-2"><slot /></h3>
|
||||||
{:else if depth == 4}
|
{:else if depth == 4}
|
||||||
<h4 class="font-bold text-lg"><slot /></h4>
|
<h4 class="font-bold text-lg my-2"><slot /></h4>
|
||||||
{:else if depth == 5}
|
{:else if depth == 5}
|
||||||
<h5 class="font-bold text-base"><slot /></h5>
|
<h5 class="font-bold text-base my-2"><slot /></h5>
|
||||||
{:else if depth == 6}
|
{:else if depth == 6}
|
||||||
<h6 class="font-bold text-sm"><slot /></h6>
|
<h6 class="font-bold text-sm my-2"><slot /></h6>
|
||||||
{:else}
|
{:else}
|
||||||
<slot />
|
<slot />
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1 +1 @@
|
|||||||
<hr class="w-[90%] mx-auto my-4 opacity-80" />
|
<hr class="w-[90%] mx-auto my-4 opacity-50" />
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let ordered: boolean
|
||||||
|
export let start: number
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if ordered}
|
||||||
|
<ol {start} class="list-decimal pl-3"><slot /></ol>
|
||||||
|
{:else}
|
||||||
|
<ul class="list-disc pl-3"><slot /></ul>
|
||||||
|
{/if}
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
src={url ?? `https://api.dicebear.com/6.x/initials/svg?seed=${alt}`}
|
src={`${url}?format=webp&thumbnail=${width * 2}` ??
|
||||||
|
`https://api.dicebear.com/6.x/initials/svg?seed=${alt}`}
|
||||||
{alt}
|
{alt}
|
||||||
{width}
|
{width}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import type { Person } from 'lemmy-js-client'
|
import type { Person } from 'lemmy-js-client'
|
||||||
|
|
||||||
export let user: Person
|
export let user: Person
|
||||||
@@ -16,14 +17,11 @@
|
|||||||
href={linkFromCommunity(user)}
|
href={linkFromCommunity(user)}
|
||||||
>
|
>
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<img
|
<Avatar
|
||||||
src={user.avatar ??
|
url={user.avatar ??
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${user.name}`}
|
`https://api.dicebear.com/6.x/initials/svg?seed=${user.name}`}
|
||||||
alt=""
|
alt={user.name}
|
||||||
width={avatarSize}
|
width={avatarSize}
|
||||||
height={avatarSize}
|
|
||||||
class="rounded-full aspect-square object-cover"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{user.name}
|
{user.name}
|
||||||
|
|||||||
+3
-1
@@ -6,7 +6,7 @@ import {
|
|||||||
import { get, writable } from 'svelte/store'
|
import { get, writable } from 'svelte/store'
|
||||||
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
||||||
|
|
||||||
export const DEFAULT_INSTANCE_URL = 'lemm.ee'
|
export const DEFAULT_INSTANCE_URL = 'lemmy.world'
|
||||||
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
||||||
|
|
||||||
export function buildBaseUrl(instance?: string) {
|
export function buildBaseUrl(instance?: string) {
|
||||||
@@ -25,6 +25,8 @@ export function getClient(instance?: string): LemmyHttp {
|
|||||||
return new LemmyHttp(`${PUBLIC_PROXY_URL}/cors/${instance}`)
|
return new LemmyHttp(`${PUBLIC_PROXY_URL}/cors/${instance}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getInstance = () => get(authData)?.instance ?? DEFAULT_INSTANCE_URL
|
||||||
|
|
||||||
export interface AuthData {
|
export interface AuthData {
|
||||||
token: string
|
token: string
|
||||||
username: string
|
username: string
|
||||||
|
|||||||
Reference in new issue
Block a user