migrate: convert most components to svelte 5
This commit is contained in:
1 parent
d670f39f0a
commit
10ef4123da
225 files changed
+5441
-3341
No files matched your search
@@ -4,7 +4,6 @@ about: Create a report to help us improve
|
|||||||
title: ''
|
title: ''
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
@@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
|
|||||||
|
|
||||||
**To Reproduce** (if applicable)
|
**To Reproduce** (if applicable)
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
1. Go to '...'
|
1. Go to '...'
|
||||||
2. Click on '....'
|
2. Click on '....'
|
||||||
3. Scroll down to '....'
|
3. Scroll down to '....'
|
||||||
@@ -24,6 +24,7 @@ A clear and concise description of what you expected to happen.
|
|||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Versions**
|
**Versions**
|
||||||
|
|
||||||
- Browser: Firefox
|
- Browser: Firefox
|
||||||
- Photon version: 0.5.1
|
- Photon version: 0.5.1
|
||||||
- check in the bottom of the main menu.
|
- check in the bottom of the main menu.
|
||||||
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
|
|||||||
title: ''
|
title: ''
|
||||||
labels: ''
|
labels: ''
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"arrowParens": "always",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"htmlWhitespaceSensitivity": "ignore",
|
||||||
|
|
||||||
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
|
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
||||||
|
}
|
||||||
Vendored
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"i18n-ally.localesPaths": ["src/lib/i18n"],
|
"i18n-ally.localesPaths": ["src/lib/i18n"],
|
||||||
"i18n-ally.keystyle": "nested"
|
"i18n-ally.keystyle": "nested",
|
||||||
|
"prettier.prettierPath": "prettier"
|
||||||
}
|
}
|
||||||
+11
-7
@@ -8,8 +8,8 @@
|
|||||||
"@sveltejs/adapter-auto": "^3.2.1",
|
"@sveltejs/adapter-auto": "^3.2.1",
|
||||||
"@sveltejs/adapter-node": "^2.0.0",
|
"@sveltejs/adapter-node": "^2.0.0",
|
||||||
"@sveltejs/adapter-vercel": "^5.1.0",
|
"@sveltejs/adapter-vercel": "^5.1.0",
|
||||||
"@sveltejs/kit": "^2.5.20",
|
"@sveltejs/kit": "^2.5.27",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tanstack/svelte-virtual": "^3.8.1",
|
"@tanstack/svelte-virtual": "^3.8.1",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
@@ -22,9 +22,11 @@
|
|||||||
"marked-linkify-it": "^3.1.10",
|
"marked-linkify-it": "^3.1.10",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"postcss": "^8.4.30",
|
"postcss": "^8.4.30",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"prettier-plugin-svelte": "^3.2.7",
|
||||||
"rollup-plugin-visualizer": "^5.9.2",
|
"rollup-plugin-visualizer": "^5.9.2",
|
||||||
"svelte": "^4.2.18",
|
"svelte": "^5.0.0",
|
||||||
"svelte-check": "^3.0.1",
|
"svelte-check": "^4.0.0",
|
||||||
"svelte-floating-ui": "^1.5.9",
|
"svelte-floating-ui": "^1.5.9",
|
||||||
"svelte-focus-trap": "^1.2.0",
|
"svelte-focus-trap": "^1.2.0",
|
||||||
"svelte-hero-icons": "^5.2.0",
|
"svelte-hero-icons": "^5.2.0",
|
||||||
@@ -33,9 +35,9 @@
|
|||||||
"sveltekit-i18n": "^2.4.2",
|
"sveltekit-i18n": "^2.4.2",
|
||||||
"tailwindcss": "^3.3.3",
|
"tailwindcss": "^3.3.3",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.5.0",
|
||||||
"ua-parser-js": "^1.0.38",
|
"ua-parser-js": "^1.0.38",
|
||||||
"vite": "^5.0.0",
|
"vite": "^5.4.4",
|
||||||
"vitest": "^1.0.0"
|
"vitest": "^1.0.0"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -47,7 +49,9 @@
|
|||||||
"start": "node build/index.js",
|
"start": "node build/index.js",
|
||||||
"bunstart": "bun build/index.js",
|
"bunstart": "bun build/index.js",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"format:specific": "prettier --write"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|||||||
+7
-7
@@ -94,7 +94,7 @@ export let profileData = writable<ProfileData>(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
profile: 1,
|
profile: 1,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
let fetchUser = {
|
let fetchUser = {
|
||||||
@@ -107,8 +107,8 @@ function profileStore(
|
|||||||
fn: (
|
fn: (
|
||||||
values: ProfileData,
|
values: ProfileData,
|
||||||
set: (value: Profile) => void,
|
set: (value: Profile) => void,
|
||||||
update: (fn: Updater<Profile>) => void
|
update: (fn: Updater<Profile>) => void,
|
||||||
) => any
|
) => any,
|
||||||
) {
|
) {
|
||||||
const derive: Readable<Profile> = derived(data, fn)
|
const derive: Readable<Profile> = derived(data, fn)
|
||||||
const { subscribe } = derive
|
const { subscribe } = derive
|
||||||
@@ -226,7 +226,7 @@ if (
|
|||||||
const result = await setUser(
|
const result = await setUser(
|
||||||
jwt,
|
jwt,
|
||||||
env.PUBLIC_INSTANCE_URL ?? '',
|
env.PUBLIC_INSTANCE_URL ?? '',
|
||||||
user?.user?.local_user_view.person.name
|
user?.user?.local_user_view.person.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
@@ -283,7 +283,7 @@ export async function setUser(jwt: string, inst: string, username?: string) {
|
|||||||
|
|
||||||
async function userFromJwt(
|
async function userFromJwt(
|
||||||
jwt: string,
|
jwt: string,
|
||||||
instance: string
|
instance: string,
|
||||||
): Promise<
|
): Promise<
|
||||||
{ user: PersonData | undefined; site: GetSiteResponse } | undefined
|
{ user: PersonData | undefined; site: GetSiteResponse } | undefined
|
||||||
> {
|
> {
|
||||||
@@ -296,7 +296,7 @@ async function userFromJwt(
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
loading: true,
|
loading: true,
|
||||||
}),
|
}),
|
||||||
5000
|
5000,
|
||||||
)
|
)
|
||||||
|
|
||||||
const site = await sitePromise
|
const site = await sitePromise
|
||||||
@@ -414,7 +414,7 @@ async function checkInbox() {
|
|||||||
const notifs = await getNotificationCount(
|
const notifs = await getNotificationCount(
|
||||||
jwt,
|
jwt,
|
||||||
amModOfAny(user) ?? false,
|
amModOfAny(user) ?? false,
|
||||||
user ? isAdmin(user) : false
|
user ? isAdmin(user) : false,
|
||||||
)
|
)
|
||||||
|
|
||||||
notifications.set({
|
notifications.set({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
interface PageScopedError {
|
interface PageScopedError {
|
||||||
@@ -24,17 +24,19 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { onDestroy } from 'svelte'
|
import { onDestroy } from 'svelte'
|
||||||
|
|
||||||
export let scope: string | undefined | null = undefined
|
|
||||||
|
|
||||||
$: scopedErrors = $errors.filter(
|
|
||||||
(e) => e.scope == scope || e.scope == 'global'
|
|
||||||
)
|
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
clearErrorScope(scope)
|
clearErrorScope(scope)
|
||||||
})
|
})
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
scope?: string | undefined | null
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { scope = undefined, class: clazz = '' }: Props = $props()
|
||||||
|
|
||||||
|
let scopedErrors = $derived(
|
||||||
|
$errors.filter((e) => e.scope == scope || e.scope == 'global'),
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if scopedErrors.length > 0}
|
{#if scopedErrors.length > 0}
|
||||||
|
|||||||
@@ -1 +1,11 @@
|
|||||||
<slot {...$$restProps} />
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet<[any]>} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props & { [key: string]: any }} */
|
||||||
|
let { children, ...rest } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{@render children?.({ ...rest })}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { tick } from 'svelte'
|
import { tick } from 'svelte'
|
||||||
|
|
||||||
export let label: string | undefined = undefined
|
let textarea: HTMLTextAreaElement = $state()
|
||||||
export let value: string
|
|
||||||
export let required: boolean = false
|
|
||||||
|
|
||||||
let textarea: HTMLTextAreaElement
|
|
||||||
|
|
||||||
$: adjustHeight(value)
|
|
||||||
async function adjustHeight(value: string) {
|
async function adjustHeight(value: string) {
|
||||||
await tick()
|
await tick()
|
||||||
if (textarea) {
|
if (textarea) {
|
||||||
@@ -16,8 +13,25 @@
|
|||||||
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
|
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
label?: string | undefined
|
||||||
|
value: string
|
||||||
|
required?: boolean
|
||||||
|
class?: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
label = undefined,
|
||||||
|
value = $bindable(),
|
||||||
|
required = false,
|
||||||
|
class: clazz = '',
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
run(() => {
|
||||||
|
adjustHeight(value)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="w-full">
|
<label class="w-full">
|
||||||
@@ -31,11 +45,11 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
bind:this={textarea}
|
bind:this={textarea}
|
||||||
on:input={() => adjustHeight(value)}
|
oninput={() => adjustHeight(value)}
|
||||||
bind:value
|
bind:value
|
||||||
{required}
|
{required}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
rows={1}
|
rows={1}
|
||||||
class="font-semibold text-2xl focus:outline-none w-full bg-transparent resize-none {clazz}"
|
class="font-semibold text-2xl focus:outline-none w-full bg-transparent resize-none {clazz}"
|
||||||
/>
|
></textarea>
|
||||||
</label>
|
</label>
|
||||||
@@ -13,9 +13,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<Label text={label} class="mb-1">
|
<Label text={label} class="mb-1" />
|
||||||
<slot name="label" />
|
|
||||||
</Label>
|
|
||||||
<label
|
<label
|
||||||
class="flex flex-col items-center px-8 py-4 mx-auto w-full rounded-xl
|
class="flex flex-col items-center px-8 py-4 mx-auto w-full rounded-xl
|
||||||
border border-slate-200 dark:border-zinc-800 bg-white dark:bg-black
|
border border-slate-200 dark:border-zinc-800 bg-white dark:bg-black
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
export const parseURL = (href: string) => {
|
export const parseURL = (href: string) => {
|
||||||
try {
|
try {
|
||||||
return new URL(href)
|
return new URL(href)
|
||||||
@@ -9,25 +9,38 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let href: string
|
interface Props {
|
||||||
export let highlight: boolean = false
|
href: string
|
||||||
export let nowrap: boolean = false
|
highlight?: boolean
|
||||||
|
nowrap?: boolean
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
class?: string
|
||||||
|
icon?: import('svelte').Snippet
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
$: richURL = $$slots.default ? undefined : parseURL(href)
|
let {
|
||||||
|
href,
|
||||||
|
highlight = false,
|
||||||
|
nowrap = false,
|
||||||
|
children,
|
||||||
|
class: clazz = '',
|
||||||
|
icon,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
let clazz: string = ''
|
let richURL = $derived(children ? undefined : parseURL(href))
|
||||||
export { clazz as class }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
{href}
|
{href}
|
||||||
class="{highlight
|
class="{highlight
|
||||||
? 'text-blue-500'
|
? 'text-blue-500'
|
||||||
: ''} hover:underline max-w-full inline-flex items-center gap-1 {clazz}"
|
: ''} hover:underline max-w-full inline-flex items-center gap-1 {clazz}"
|
||||||
>
|
>
|
||||||
<slot name="icon" />
|
{@render icon?.()}
|
||||||
<slot>
|
{#if children}{@render children()}{:else}
|
||||||
<span
|
<span
|
||||||
class="flex relative gap-0 {nowrap
|
class="flex relative gap-0 {nowrap
|
||||||
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
||||||
@@ -52,5 +65,5 @@
|
|||||||
{href}
|
{href}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let value: number
|
import { createBubbler } from 'svelte/legacy'
|
||||||
export let min: number = 0
|
|
||||||
export let max: number = 100
|
const bubble = createBubbler()
|
||||||
export let step: number = 1
|
interface Props {
|
||||||
|
value: number
|
||||||
|
min?: number
|
||||||
|
max?: number
|
||||||
|
step?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
let { value = $bindable(), min = 0, max = 100, step = 1 }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
@@ -11,10 +18,10 @@
|
|||||||
{min}
|
{min}
|
||||||
{max}
|
{max}
|
||||||
{step}
|
{step}
|
||||||
on:change
|
onchange={bubble('change')}
|
||||||
on:click
|
onclick={bubble('click')}
|
||||||
on:keydown
|
onkeydown={bubble('keydown')}
|
||||||
on:keypress
|
onkeypress={bubble('keypress')}
|
||||||
class="w-full appearance-none h-2 cursor-pointer bg-slate-100 dark:bg-zinc-800
|
class="w-full appearance-none h-2 cursor-pointer bg-slate-100 dark:bg-zinc-800
|
||||||
rounded-full range"
|
rounded-full range"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,24 +1,39 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
|
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
type T = $$Generic
|
type T = $$Generic
|
||||||
export let options: T[]
|
|
||||||
export let disabled: boolean[] = []
|
|
||||||
export let optionNames: string[] = []
|
|
||||||
export let selected: T
|
|
||||||
export let headless: boolean = false
|
|
||||||
|
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export let buttonClazz: string = ''
|
options: T[]
|
||||||
export { clazz as class }
|
disabled?: boolean[]
|
||||||
|
optionNames?: string[]
|
||||||
|
selected: T
|
||||||
|
headless?: boolean
|
||||||
|
class?: string
|
||||||
|
buttonClazz?: string
|
||||||
|
children?: import('svelte').Snippet<[any]>
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
options,
|
||||||
|
disabled = [],
|
||||||
|
optionNames = [],
|
||||||
|
selected = $bindable(),
|
||||||
|
headless = false,
|
||||||
|
class: clazz = '',
|
||||||
|
buttonClazz = '',
|
||||||
|
children,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ select: T }>()
|
const dispatcher = createEventDispatcher<{ select: T }>()
|
||||||
|
|
||||||
$: {
|
run(() => {
|
||||||
dispatcher('select', selected)
|
dispatcher('select', selected)
|
||||||
}
|
})
|
||||||
|
|
||||||
let containerClass = `
|
let containerClass = `
|
||||||
flex flex-row rtl:flex-row-reverse items-center w-max max-w-full overflow-auto
|
flex flex-row rtl:flex-row-reverse items-center w-max max-w-full overflow-auto
|
||||||
@@ -57,7 +72,7 @@
|
|||||||
{#each options as option, index}
|
{#each options as option, index}
|
||||||
<button
|
<button
|
||||||
class={buttonClass(selected == option)}
|
class={buttonClass(selected == option)}
|
||||||
on:click|preventDefault={() => (selected = option)}
|
onclick={preventDefault(() => (selected = option))}
|
||||||
disabled={disabled[index] ?? false}
|
disabled={disabled[index] ?? false}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@@ -65,9 +80,9 @@
|
|||||||
{#if headless && option == selected}
|
{#if headless && option == selected}
|
||||||
<div
|
<div
|
||||||
class="absolute -bottom-1 left-0 w-full border-b-2 rounded-t-sm border-black dark:border-white"
|
class="absolute -bottom-1 left-0 w-full border-b-2 rounded-t-sm border-black dark:border-white"
|
||||||
/>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<slot {selected} />
|
{@render children?.({ selected })}
|
||||||
@@ -7,15 +7,28 @@
|
|||||||
import { Icon, XCircle, ServerStack } from 'svelte-hero-icons'
|
import { Icon, XCircle, ServerStack } from 'svelte-hero-icons'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
export let type: 'community' | 'instance' = 'community'
|
interface Props {
|
||||||
export let q: string = ''
|
type?: 'community' | 'instance'
|
||||||
|
q?: string
|
||||||
|
instance?: string | undefined
|
||||||
|
listing_type?: ListingType
|
||||||
|
showWhenEmpty?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
export let instance: string | undefined = undefined
|
let {
|
||||||
export let listing_type: ListingType = 'Subscribed'
|
type = 'community',
|
||||||
export let showWhenEmpty: boolean = false
|
q = $bindable(''),
|
||||||
|
instance = undefined,
|
||||||
|
listing_type = 'Subscribed',
|
||||||
|
showWhenEmpty = false,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ select: Community | undefined }>()
|
const dispatcher = createEventDispatcher<{ select: Community | undefined }>()
|
||||||
$: instances = type == 'instance' && getClient().getFederatedInstances()
|
let instances = $derived(
|
||||||
|
type == 'instance' && getClient().getFederatedInstances(),
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if type == 'community'}
|
{#if type == 'community'}
|
||||||
@@ -35,33 +48,35 @@
|
|||||||
on:select
|
on:select
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{showWhenEmpty}
|
{showWhenEmpty}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
let:item
|
|
||||||
let:select
|
|
||||||
>
|
>
|
||||||
<div class="w-full h-full" slot="noresults">
|
{#snippet noresults()}
|
||||||
{#if q == '' && showWhenEmpty}
|
<div class="w-full h-full">
|
||||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
{#if q == '' && showWhenEmpty}
|
||||||
<Icon src={XCircle} size="16" mini />
|
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||||
|
<Icon src={XCircle} size="16" mini />
|
||||||
|
<div class="flex flex-col text-left">
|
||||||
|
<span>None</span>
|
||||||
|
</div>
|
||||||
|
</MenuButton>
|
||||||
|
{:else}
|
||||||
|
<span class="mx-auto my-auto">No results.</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet children({ item, select })}
|
||||||
|
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||||
|
<MenuButton on:click={() => select(item)}>
|
||||||
|
<Avatar url={item.icon} alt={item.title} width={24} />
|
||||||
<div class="flex flex-col text-left">
|
<div class="flex flex-col text-left">
|
||||||
<span>None</span>
|
<span>{item.title}</span>
|
||||||
|
<span class="text-xs opacity-80">
|
||||||
|
{new URL(item.actor_id).hostname}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{:else}
|
</div>
|
||||||
<span class="mx-auto my-auto">No results.</span>
|
{/snippet}
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
|
||||||
<MenuButton on:click={() => select(item)}>
|
|
||||||
<Avatar url={item.icon} alt={item.title} width={24} />
|
|
||||||
<div class="flex flex-col text-left">
|
|
||||||
<span>{item.title}</span>
|
|
||||||
<span class="text-xs opacity-80">
|
|
||||||
{new URL(item.actor_id).hostname}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</MenuButton>
|
|
||||||
</div>
|
|
||||||
</Search>
|
</Search>
|
||||||
{:else if type == 'instance'}
|
{:else if type == 'instance'}
|
||||||
<Search
|
<Search
|
||||||
@@ -70,7 +85,7 @@
|
|||||||
|
|
||||||
return q
|
return q
|
||||||
? (results.federated_instances?.linked || []).filter(
|
? (results.federated_instances?.linked || []).filter(
|
||||||
(i) => i.software === 'lemmy' && i.domain.includes(q)
|
(i) => i.software === 'lemmy' && i.domain.includes(q),
|
||||||
)
|
)
|
||||||
: []
|
: []
|
||||||
}}
|
}}
|
||||||
@@ -78,28 +93,30 @@
|
|||||||
on:select
|
on:select
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{showWhenEmpty}
|
{showWhenEmpty}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
let:item
|
|
||||||
let:select
|
|
||||||
>
|
>
|
||||||
<div class="w-full h-full" slot="noresults">
|
{#snippet noresults()}
|
||||||
{#if q == '' && showWhenEmpty}
|
<div class="w-full h-full">
|
||||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
{#if q == '' && showWhenEmpty}
|
||||||
|
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||||
|
<div class="flex flex-col text-left">
|
||||||
|
<span>None (Start typing to search)</span>
|
||||||
|
</div>
|
||||||
|
</MenuButton>
|
||||||
|
{:else}
|
||||||
|
<span class="mx-auto my-auto">No results.</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet children({ item, select })}
|
||||||
|
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||||
|
<MenuButton on:click={() => select(item)}>
|
||||||
|
<Icon src={ServerStack} size="16" mini />
|
||||||
<div class="flex flex-col text-left">
|
<div class="flex flex-col text-left">
|
||||||
<span>None (Start typing to search)</span>
|
<span>{item.domain}</span>
|
||||||
</div>
|
</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{:else}
|
</div>
|
||||||
<span class="mx-auto my-auto">No results.</span>
|
{/snippet}
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
|
||||||
<MenuButton on:click={() => select(item)}>
|
|
||||||
<Icon src={ServerStack} size="16" mini />
|
|
||||||
<div class="flex flex-col text-left">
|
|
||||||
<span>{item.domain}</span>
|
|
||||||
</div>
|
|
||||||
</MenuButton>
|
|
||||||
</div>
|
|
||||||
</Search>
|
</Search>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -22,12 +22,21 @@
|
|||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
import { optimizeImageURL } from './post/helpers'
|
import { optimizeImageURL } from './post/helpers'
|
||||||
|
|
||||||
export let site: SiteView
|
interface Props {
|
||||||
export let taglines: Tagline[] | undefined = undefined
|
site: SiteView
|
||||||
export let admins: PersonView[] | undefined = undefined
|
taglines?: Tagline[] | undefined
|
||||||
export let version: string | undefined = undefined
|
admins?: PersonView[] | undefined
|
||||||
let clazz: string = ''
|
version?: string | undefined
|
||||||
export { clazz as class }
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
site,
|
||||||
|
taglines = undefined,
|
||||||
|
admins = undefined,
|
||||||
|
version = undefined,
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<StickyCard class="w-full {clazz} text-slate-600 dark:text-zinc-400">
|
<StickyCard class="w-full {clazz} text-slate-600 dark:text-zinc-400">
|
||||||
@@ -45,13 +54,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Entity name={site.site.name} label={new URL(site.site.actor_id).hostname}>
|
<Entity name={site.site.name} label={new URL(site.site.actor_id).hostname}>
|
||||||
<Avatar
|
{#snippet customIcon()}
|
||||||
width={32}
|
<Avatar
|
||||||
url={site.site.icon}
|
width={32}
|
||||||
alt={site.site.name}
|
url={site.site.icon}
|
||||||
circle={false}
|
alt={site.site.name}
|
||||||
slot="icon"
|
circle={false}
|
||||||
/>
|
/>
|
||||||
|
{/snippet}
|
||||||
</Entity>
|
</Entity>
|
||||||
<div class="flex flex-row gap-1 !border-0">
|
<div class="flex flex-row gap-1 !border-0">
|
||||||
<Button
|
<Button
|
||||||
@@ -91,21 +101,25 @@
|
|||||||
|
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.about}>
|
<Expandable bind:open={$userSettings.expand.about}>
|
||||||
<span class="flex items-center gap-1 py-1 px-2" slot="title">
|
{#snippet title()}
|
||||||
<Icon src={InformationCircle} size="16" mini />
|
<span class="flex items-center gap-1 py-1 px-2">
|
||||||
{$t('cards.site.about')}
|
<Icon src={InformationCircle} size="16" mini />
|
||||||
</span>
|
{$t('cards.site.about')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<Markdown source={site.site.description} />
|
<Markdown source={site.site.description} />
|
||||||
<div class="my-4" />
|
<div class="my-4"></div>
|
||||||
<Markdown source={site.site.sidebar} />
|
<Markdown source={site.site.sidebar} />
|
||||||
</Expandable>
|
</Expandable>
|
||||||
|
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.stats}>
|
<Expandable bind:open={$userSettings.expand.stats}>
|
||||||
<span class="flex items-center gap-1 py-1 px-2" slot="title">
|
{#snippet title()}
|
||||||
<Icon src={ChartBar} size="16" mini />
|
<span class="flex items-center gap-1 py-1 px-2">
|
||||||
{$t('cards.site.stats')}
|
<Icon src={ChartBar} size="16" mini />
|
||||||
</span>
|
{$t('cards.site.stats')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<div class="flex flex-row gap-4 flex-wrap">
|
<div class="flex flex-row gap-4 flex-wrap">
|
||||||
<LabelStat
|
<LabelStat
|
||||||
label={$t('content.users')}
|
label={$t('content.users')}
|
||||||
@@ -128,10 +142,12 @@
|
|||||||
{#if admins}
|
{#if admins}
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.team}>
|
<Expandable bind:open={$userSettings.expand.team}>
|
||||||
<span class="flex items-center gap-1 py-1 px-2" slot="title">
|
{#snippet title()}
|
||||||
<Icon src={UserGroup} size="16" mini />
|
<span class="flex items-center gap-1 py-1 px-2">
|
||||||
{$t('cards.site.admins')}
|
<Icon src={UserGroup} size="16" mini />
|
||||||
</span>
|
{$t('cards.site.admins')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={admins.map((a) => ({
|
items={admins.map((a) => ({
|
||||||
id: a.person.id,
|
id: a.person.id,
|
||||||
@@ -146,7 +162,7 @@
|
|||||||
|
|
||||||
{#if version}
|
{#if version}
|
||||||
<div class="w-max">
|
<div class="w-max">
|
||||||
<Badge title="Lemmy version">
|
<Badge label="Lemmy version">
|
||||||
<Icon src={ServerStack} micro size="14" />
|
<Icon src={ServerStack} micro size="14" />
|
||||||
{version}
|
{version}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ArrowUp,
|
ArrowUp,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
@@ -30,25 +32,38 @@
|
|||||||
import { expoInOut, expoOut } from 'svelte/easing'
|
import { expoInOut, expoOut } from 'svelte/easing'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
|
||||||
export let node: CommentNodeI
|
interface Props {
|
||||||
export let postId: number
|
node: CommentNodeI
|
||||||
export let op: boolean = false
|
postId: number
|
||||||
|
op?: boolean
|
||||||
|
actions?: boolean
|
||||||
|
meta?: boolean
|
||||||
|
open?: boolean
|
||||||
|
replying?: boolean
|
||||||
|
contentClass?: string
|
||||||
|
class?: string
|
||||||
|
metaSuffix?: import('svelte').Snippet
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
export let actions: boolean = true
|
let {
|
||||||
export let meta: boolean = true
|
node = $bindable(),
|
||||||
|
postId,
|
||||||
|
op = false,
|
||||||
|
actions = true,
|
||||||
|
meta = true,
|
||||||
|
open = $bindable(true),
|
||||||
|
replying = $bindable(false),
|
||||||
|
contentClass = '',
|
||||||
|
class: clazz = '',
|
||||||
|
metaSuffix,
|
||||||
|
children,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
export let open = true
|
let editing = $state(false)
|
||||||
|
let newComment = $state(node.comment_view.comment.content)
|
||||||
|
|
||||||
export let replying = false
|
let editingLoad = $state(false)
|
||||||
|
|
||||||
let editing = false
|
|
||||||
let newComment = node.comment_view.comment.content
|
|
||||||
|
|
||||||
let editingLoad = false
|
|
||||||
|
|
||||||
export let contentClass: string = ''
|
|
||||||
let clazz: string = ''
|
|
||||||
export { clazz as class }
|
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!$profile?.jwt || newComment.length <= 0) return
|
if (!$profile?.jwt || newComment.length <= 0) return
|
||||||
@@ -84,13 +99,15 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let highlight = ''
|
let highlight = $state('')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if editing}
|
{#if editing}
|
||||||
<Modal bind:open={editing}>
|
<Modal bind:open={editing}>
|
||||||
<span slot="title">{$t('form.edit')}</span>
|
{#snippet customTitle()}
|
||||||
<form on:submit|preventDefault={save} class="contents">
|
<span>{$t('form.edit')}</span>
|
||||||
|
{/snippet}
|
||||||
|
<form onsubmit={preventDefault(save)} class="contents">
|
||||||
<CommentForm
|
<CommentForm
|
||||||
postId={node.comment_view.comment.id}
|
postId={node.comment_view.comment.id}
|
||||||
bind:value={newComment}
|
bind:value={newComment}
|
||||||
@@ -120,11 +137,11 @@
|
|||||||
>
|
>
|
||||||
{#if meta}
|
{#if meta}
|
||||||
<button
|
<button
|
||||||
on:click={() => (open = !open)}
|
onclick={() => (open = !open)}
|
||||||
class="flex flex-row cursor-pointer gap-2 items-center group text-[13px] flex-wrap w-full
|
class="flex flex-row cursor-pointer gap-2 items-center group text-[13px] flex-wrap w-full
|
||||||
z-0 group relative"
|
z-0 group relative"
|
||||||
>
|
>
|
||||||
<slot name="meta-suffix" />
|
{@render metaSuffix?.()}
|
||||||
<div
|
<div
|
||||||
class="absolute opacity-0 -z-10 inset-0 group-hover:block group-hover:opacity-100
|
class="absolute opacity-0 -z-10 inset-0 group-hover:block group-hover:opacity-100
|
||||||
bg-slate-100 dark:bg-zinc-900 group-hover:-inset-1 group-hover:-inset-x-2 rounded-full transition-all
|
bg-slate-100 dark:bg-zinc-900 group-hover:-inset-1 group-hover:-inset-x-2 rounded-full transition-all
|
||||||
@@ -154,14 +171,14 @@
|
|||||||
avatar
|
avatar
|
||||||
user={node.comment_view.creator}
|
user={node.comment_view.creator}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="badges">
|
{#snippet extraBadges()}
|
||||||
{#if node.comment_view.creator_is_moderator}
|
{#if node.comment_view.creator_is_moderator}
|
||||||
<ShieldIcon filled width={14} class="text-green-500" />
|
<ShieldIcon filled width={14} class="text-green-500" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if node.comment_view.creator_is_admin}
|
{#if node.comment_view.creator_is_admin}
|
||||||
<ShieldIcon filled width={14} class="text-red-500" />
|
<ShieldIcon filled width={14} class="text-red-500" />
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
</UserLink>
|
</UserLink>
|
||||||
{#if op}
|
{#if op}
|
||||||
<Icon mini size="16" src={Microphone} class="text-sky-600" />
|
<Icon mini size="16" src={Microphone} class="text-sky-600" />
|
||||||
@@ -254,7 +271,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="bg-transparent dark:bg-transparent">
|
<div class="bg-transparent dark:bg-transparent">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -30,14 +30,22 @@
|
|||||||
import { text } from '$lib/components/translate/translation'
|
import { text } from '$lib/components/translate/translation'
|
||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
|
|
||||||
export let comment: CommentView
|
interface Props {
|
||||||
export let replying: boolean = false
|
comment: CommentView
|
||||||
export let disabled = false
|
replying?: boolean
|
||||||
|
disabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
comment = $bindable(),
|
||||||
|
replying = $bindable(false),
|
||||||
|
disabled = false,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ edit: CommentView }>()
|
const dispatcher = createEventDispatcher<{ edit: CommentView }>()
|
||||||
|
|
||||||
let reply = ''
|
let reply = ''
|
||||||
let translating = false
|
let translating = $state(false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if translating}
|
{#if translating}
|
||||||
@@ -69,22 +77,19 @@
|
|||||||
<CommentModerationMenu bind:item={comment} />
|
<CommentModerationMenu bind:item={comment} />
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
<Button
|
{#snippet target()}
|
||||||
slot="target"
|
<Button
|
||||||
title={$t('comment.actions.label')}
|
title={$t('comment.actions.label')}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
class="text-slate-700 dark:text-zinc-300"
|
class="text-slate-700 dark:text-zinc-300"
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={EllipsisHorizontal}
|
<Icon src={EllipsisHorizontal} width={16} height={16} mini />
|
||||||
width={16}
|
{/snippet}
|
||||||
height={16}
|
</Button>
|
||||||
mini
|
{/snippet}
|
||||||
slot="prefix"
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
@@ -104,7 +109,9 @@
|
|||||||
translating = !translating
|
translating = !translating
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Language} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Language} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.translate')}
|
{$t('post.actions.more.translate')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -134,7 +141,7 @@
|
|||||||
comment.comment.deleted = await deleteItem(
|
comment.comment.deleted = await deleteItem(
|
||||||
comment,
|
comment,
|
||||||
!comment.comment.deleted,
|
!comment.comment.deleted,
|
||||||
$profile.jwt
|
$profile.jwt,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -154,5 +161,5 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</Menu>
|
</Menu>
|
||||||
<div class="flex-1 w-full" />
|
<div class="flex-1 w-full"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -12,26 +12,39 @@
|
|||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { Icon, XMark } from 'svelte-hero-icons'
|
import { Icon, XMark } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let postId: number
|
|
||||||
export let parentId: number | undefined = undefined
|
|
||||||
export let locked: boolean = false
|
|
||||||
export let banned: boolean = false
|
|
||||||
export let rows: number = 7
|
|
||||||
export let placeholder: string | undefined = undefined
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
const dispatch = createEventDispatcher<{
|
||||||
comment: CommentResponse
|
comment: CommentResponse
|
||||||
confirm: string
|
confirm: string
|
||||||
cancel: boolean
|
cancel: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
export let value = ''
|
interface Props {
|
||||||
export let actions = true
|
postId: number
|
||||||
|
parentId?: number | undefined
|
||||||
|
locked?: boolean
|
||||||
|
banned?: boolean
|
||||||
|
rows?: number
|
||||||
|
placeholder?: string | undefined
|
||||||
|
value?: string
|
||||||
|
actions?: boolean
|
||||||
|
preview?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
let previewAction = true
|
let {
|
||||||
export { previewAction as preview }
|
postId,
|
||||||
|
parentId = undefined,
|
||||||
|
locked = false,
|
||||||
|
banned = false,
|
||||||
|
rows = 7,
|
||||||
|
placeholder = undefined,
|
||||||
|
value = $bindable(''),
|
||||||
|
actions = true,
|
||||||
|
preview: previewAction = true,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
let loading = false
|
let loading = $state(false)
|
||||||
let preview = false
|
let preview = false
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
@@ -70,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
{rows}
|
{rows}
|
||||||
placeholder={locked
|
placeholder={locked
|
||||||
? $t('comment.locked')
|
? $t('comment.locked')
|
||||||
@@ -88,7 +101,7 @@
|
|||||||
on:focus
|
on:focus
|
||||||
previewButton={previewAction}
|
previewButton={previewAction}
|
||||||
>
|
>
|
||||||
<div class="flex-1" />
|
<div class="flex-1"></div>
|
||||||
{#if actions}
|
{#if actions}
|
||||||
<Button
|
<Button
|
||||||
size="custom"
|
size="custom"
|
||||||
|
|||||||
@@ -9,13 +9,23 @@
|
|||||||
import { Button, Material } from 'mono-svelte'
|
import { Button, Material } from 'mono-svelte'
|
||||||
import { ArrowUturnUp, Icon } from 'svelte-hero-icons'
|
import { ArrowUturnUp, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let comment: CommentView
|
interface Props {
|
||||||
export let view = $userSettings.view
|
comment: CommentView
|
||||||
export let community = false
|
view?: any
|
||||||
|
community?: boolean
|
||||||
|
meta?: boolean
|
||||||
|
class?: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
export let meta: boolean = true
|
let {
|
||||||
let clazz: string = ''
|
comment,
|
||||||
export { clazz as class }
|
view = $userSettings.view,
|
||||||
|
community = false,
|
||||||
|
meta = true,
|
||||||
|
class: clazz = '',
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Material
|
<Material
|
||||||
@@ -68,7 +78,7 @@
|
|||||||
node={{ children: [], comment_view: comment, depth: 1, ui: {} }}
|
node={{ children: [], comment_view: comment, depth: 1, ui: {} }}
|
||||||
replying={false}
|
replying={false}
|
||||||
{meta}
|
{meta}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Material>
|
</Material>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import type { CommentNodeI } from './comments'
|
import type { CommentNodeI } from './comments'
|
||||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
@@ -6,31 +8,37 @@
|
|||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
export let nodes: CommentNodeI[]
|
interface Props {
|
||||||
export let post: Post
|
nodes: CommentNodeI[]
|
||||||
export let scrollTo: string | undefined
|
post: Post
|
||||||
|
scrollTo: string | undefined
|
||||||
|
}
|
||||||
|
|
||||||
let virtualListEl: HTMLElement | undefined = undefined
|
let { nodes, post, scrollTo }: Props = $props()
|
||||||
|
|
||||||
$: virtualizer = createWindowVirtualizer({
|
let virtualListEl: HTMLElement | undefined = $state(undefined)
|
||||||
count: nodes.length,
|
|
||||||
estimateSize: () => 30,
|
|
||||||
scrollMargin: virtualListEl?.offsetTop,
|
|
||||||
initialRect: {
|
|
||||||
height: 1500,
|
|
||||||
width: 99999,
|
|
||||||
},
|
|
||||||
overscan: 5,
|
|
||||||
})
|
|
||||||
|
|
||||||
let virtualItemEls: HTMLElement[] = []
|
let virtualizer = $derived(
|
||||||
|
createWindowVirtualizer({
|
||||||
|
count: nodes.length,
|
||||||
|
estimateSize: () => 30,
|
||||||
|
scrollMargin: virtualListEl?.offsetTop,
|
||||||
|
initialRect: {
|
||||||
|
height: 1500,
|
||||||
|
width: 99999,
|
||||||
|
},
|
||||||
|
overscan: 5,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
$: items = $virtualizer.getVirtualItems()
|
let virtualItemEls: HTMLElement[] = $state([])
|
||||||
|
|
||||||
$: {
|
let items = $derived($virtualizer.getVirtualItems())
|
||||||
|
|
||||||
|
run(() => {
|
||||||
if (virtualItemEls.length)
|
if (virtualItemEls.length)
|
||||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||||
}
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (scrollTo) {
|
if (scrollTo) {
|
||||||
|
|||||||
@@ -18,10 +18,19 @@
|
|||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
export let vote: number = 0
|
interface Props {
|
||||||
export let upvotes: number
|
vote?: number
|
||||||
export let downvotes: number
|
upvotes: number
|
||||||
export let commentId: number
|
downvotes: number
|
||||||
|
commentId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
vote = $bindable(0),
|
||||||
|
upvotes = $bindable(),
|
||||||
|
downvotes = $bindable(),
|
||||||
|
commentId,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const castVote = async (newVote: number) => {
|
const castVote = async (newVote: number) => {
|
||||||
if (!$profile?.jwt) {
|
if (!$profile?.jwt) {
|
||||||
@@ -42,7 +51,7 @@
|
|||||||
class="h-full flex items-center overflow-hidden {buttonColor.ghost} rounded-full hover:bg-transparent"
|
class="h-full flex items-center overflow-hidden {buttonColor.ghost} rounded-full hover:bg-transparent"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
onclick={() => castVote(vote == 1 ? 0 : 1)}
|
||||||
class="flex items-center gap-0.5 transition-colors px-1.5 h-full
|
class="flex items-center gap-0.5 transition-colors px-1.5 h-full
|
||||||
{vote == 1
|
{vote == 1
|
||||||
? shouldShowVoteColor(vote, 'upvotes')
|
? shouldShowVoteColor(vote, 'upvotes')
|
||||||
@@ -65,7 +74,7 @@
|
|||||||
class="border-l h-4 w-0 !p-0 border-slate-200 dark:border-zinc-800"
|
class="border-l h-4 w-0 !p-0 border-slate-200 dark:border-zinc-800"
|
||||||
></div>
|
></div>
|
||||||
<button
|
<button
|
||||||
on:click={() => castVote(vote == -1 ? 0 : -1)}
|
onclick={() => castVote(vote == -1 ? 0 : -1)}
|
||||||
class="flex flex-row-reverse items-center gap-0.5 h-full transition-colors border-0 px-1.5
|
class="flex flex-row-reverse items-center gap-0.5 h-full transition-colors border-0 px-1.5
|
||||||
{vote == -1
|
{vote == -1
|
||||||
? shouldShowVoteColor(vote, 'downvotes')
|
? shouldShowVoteColor(vote, 'downvotes')
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Comments from './Comments.svelte'
|
||||||
import Comment from './Comment.svelte'
|
import Comment from './Comment.svelte'
|
||||||
import { buildCommentsTree, type CommentNodeI } from './comments'
|
import { buildCommentsTree, type CommentNodeI } from './comments'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
@@ -22,11 +23,15 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
|
||||||
export let nodes: CommentNodeI[]
|
interface Props {
|
||||||
export let isParent: boolean
|
nodes: CommentNodeI[]
|
||||||
export let post: Post
|
isParent: boolean
|
||||||
|
post: Post
|
||||||
|
}
|
||||||
|
|
||||||
let hydrated = false
|
let { nodes = $bindable(), isParent, post }: Props = $props()
|
||||||
|
|
||||||
|
let hydrated = $state(false)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
hydrated = true
|
hydrated = true
|
||||||
@@ -74,7 +79,7 @@
|
|||||||
// 0.18.2 -> 0.18.3 broke this
|
// 0.18.2 -> 0.18.3 broke this
|
||||||
// so i'm adding this check
|
// so i'm adding this check
|
||||||
const treeParent = tree.find(
|
const treeParent = tree.find(
|
||||||
(c) => c.comment_view.comment.id == parent.comment_view.comment.id
|
(c) => c.comment_view.comment.id == parent.comment_view.comment.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (treeParent) {
|
if (treeParent) {
|
||||||
@@ -113,10 +118,10 @@
|
|||||||
? 'divide-y dark:divide-zinc-900 divide-slate-100'
|
? 'divide-y dark:divide-zinc-900 divide-slate-100'
|
||||||
: ' border-slate-200 dark:border-zinc-800 my-1'}
|
: ' border-slate-200 dark:border-zinc-800 my-1'}
|
||||||
>
|
>
|
||||||
{#each nodes as node (node.comment_view.comment.id)}
|
{#each nodes as node, index (node.comment_view.comment.id)}
|
||||||
<Comment
|
<Comment
|
||||||
postId={post.id}
|
postId={post.id}
|
||||||
bind:node
|
bind:node={nodes[index]}
|
||||||
bind:open={node.ui.open}
|
bind:open={node.ui.open}
|
||||||
op={post.creator_id == node.comment_view.creator.id}
|
op={post.creator_id == node.comment_view.creator.id}
|
||||||
contentClass="pl-3 {node.children.length > 0 ||
|
contentClass="pl-3 {node.children.length > 0 ||
|
||||||
@@ -125,7 +130,7 @@
|
|||||||
: ''} ml-3 border-slate-200 dark:border-zinc-800"
|
: ''} ml-3 border-slate-200 dark:border-zinc-800"
|
||||||
>
|
>
|
||||||
{#if node.children?.length > 0}
|
{#if node.children?.length > 0}
|
||||||
<svelte:self {post} bind:nodes={node.children} isParent={false} />
|
<Comments {post} bind:nodes={nodes[index].children} isParent={false} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
|
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
|
||||||
<svelte:element
|
<svelte:element
|
||||||
@@ -143,7 +148,7 @@
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (node.depth > 4) {
|
if (node.depth > 4) {
|
||||||
goto(
|
goto(
|
||||||
`/comment/${$page.params.instance}/${node.comment_view.comment.id}#comments`
|
`/comment/${$page.params.instance}/${node.comment_view.comment.id}#comments`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
node.loading = true
|
node.loading = true
|
||||||
@@ -151,13 +156,14 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={ArrowDownCircle}
|
<Icon
|
||||||
micro
|
src={ArrowDownCircle}
|
||||||
size="16"
|
micro
|
||||||
slot="prefix"
|
size="16"
|
||||||
class="text-primary-900 dark:text-primary-100"
|
class="text-primary-900 dark:text-primary-100"
|
||||||
/>
|
/>
|
||||||
|
{/snippet}
|
||||||
{$t('comment.more', {
|
{$t('comment.more', {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
comments: node.comment_view.counts.child_count,
|
comments: node.comment_view.counts.child_count,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function getDepthFromComment(comment?: Comment): number | undefined {
|
|||||||
export function buildCommentsTree(
|
export function buildCommentsTree(
|
||||||
comments: CommentView[],
|
comments: CommentView[],
|
||||||
baseDepth: number = 0,
|
baseDepth: number = 0,
|
||||||
filter: (c: CommentView) => boolean = (c) => true
|
filter: (c: CommentView) => boolean = (c) => true,
|
||||||
): CommentNodeI[] {
|
): CommentNodeI[] {
|
||||||
const start = performance.now()
|
const start = performance.now()
|
||||||
const map = new Map<number, CommentNodeI>()
|
const map = new Map<number, CommentNodeI>()
|
||||||
@@ -81,7 +81,7 @@ export function buildCommentsTree(
|
|||||||
|
|
||||||
export function searchCommentTree(
|
export function searchCommentTree(
|
||||||
tree: CommentNodeI[],
|
tree: CommentNodeI[],
|
||||||
id: number
|
id: number,
|
||||||
): CommentNodeI | undefined {
|
): CommentNodeI | undefined {
|
||||||
for (const node of tree) {
|
for (const node of tree) {
|
||||||
if (node.comment_view.comment.id === id) {
|
if (node.comment_view.comment.id === id) {
|
||||||
@@ -102,7 +102,7 @@ export function searchCommentTree(
|
|||||||
export function insertCommentIntoTree(
|
export function insertCommentIntoTree(
|
||||||
tree: CommentNodeI[],
|
tree: CommentNodeI[],
|
||||||
cv: CommentView,
|
cv: CommentView,
|
||||||
parentComment: boolean
|
parentComment: boolean,
|
||||||
) {
|
) {
|
||||||
// Building a fake node to be used for later
|
// Building a fake node to be used for later
|
||||||
const node: CommentNodeI = {
|
const node: CommentNodeI = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
export async function block(id: number, block: boolean) {
|
export async function block(id: number, block: boolean) {
|
||||||
try {
|
try {
|
||||||
const loading = toast({
|
const loading = toast({
|
||||||
@@ -111,13 +111,10 @@
|
|||||||
import Entity from '$lib/components/ui/Entity.svelte'
|
import Entity from '$lib/components/ui/Entity.svelte'
|
||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
|
|
||||||
export let community_view: CommunityView
|
let loading = $state({
|
||||||
export let moderators: CommunityModeratorView[] = []
|
|
||||||
|
|
||||||
let loading = {
|
|
||||||
blocking: false,
|
blocking: false,
|
||||||
subscribing: false,
|
subscribing: false,
|
||||||
}
|
})
|
||||||
|
|
||||||
async function subscribe() {
|
async function subscribe() {
|
||||||
if (!$profile?.jwt) return
|
if (!$profile?.jwt) return
|
||||||
@@ -140,8 +137,17 @@
|
|||||||
|
|
||||||
loading.subscribing = false
|
loading.subscribing = false
|
||||||
}
|
}
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
community_view: CommunityView
|
||||||
|
moderators?: CommunityModeratorView[]
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
community_view = $bindable(),
|
||||||
|
moderators = [],
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<StickyCard class="min-w-full pt-0 text-slate-600 dark:text-zinc-400 {clazz}">
|
<StickyCard class="min-w-full pt-0 text-slate-600 dark:text-zinc-400 {clazz}">
|
||||||
@@ -149,34 +155,39 @@
|
|||||||
name={community_view.community.title}
|
name={community_view.community.title}
|
||||||
label="!{fullCommunityName(
|
label="!{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
community_view.community.actor_id
|
community_view.community.actor_id,
|
||||||
)}"
|
)}"
|
||||||
>
|
>
|
||||||
<Avatar
|
{#snippet customIcon()}
|
||||||
width={32}
|
<Avatar
|
||||||
url={community_view.community.icon}
|
width={32}
|
||||||
alt={community_view.community.name}
|
url={community_view.community.icon}
|
||||||
circle={false}
|
alt={community_view.community.name}
|
||||||
slot="icon"
|
circle={false}
|
||||||
/>
|
/>
|
||||||
|
{/snippet}
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.about} class="!pt-0">
|
<Expandable bind:open={$userSettings.expand.about} class="!pt-0">
|
||||||
<span slot="title" class="py-1 px-1 flex gap-1 items-center">
|
{#snippet title()}
|
||||||
<Icon src={InformationCircle} size="15" mini />
|
<span class="py-1 px-1 flex gap-1 items-center">
|
||||||
{$t('cards.site.about')}
|
<Icon src={InformationCircle} size="15" mini />
|
||||||
</span>
|
{$t('cards.site.about')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<Markdown source={community_view.community.description} />
|
<Markdown source={community_view.community.description} />
|
||||||
</Expandable>
|
</Expandable>
|
||||||
|
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.stats}>
|
<Expandable bind:open={$userSettings.expand.stats}>
|
||||||
<span slot="title" class="py-1 px-1 flex gap-1 items-center">
|
{#snippet title()}
|
||||||
<Icon src={ChartBar} size="15" mini />
|
<span class="py-1 px-1 flex gap-1 items-center">
|
||||||
{$t('cards.site.stats')}
|
<Icon src={ChartBar} size="15" mini />
|
||||||
</span>
|
{$t('cards.site.stats')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<div class="flex flex-row gap-4 flex-wrap">
|
<div class="flex flex-row gap-4 flex-wrap">
|
||||||
<LabelStat
|
<LabelStat
|
||||||
label={$t('cards.community.members')}
|
label={$t('cards.community.members')}
|
||||||
@@ -194,10 +205,12 @@
|
|||||||
{#if moderators && moderators.length > 0}
|
{#if moderators && moderators.length > 0}
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
<Expandable bind:open={$userSettings.expand.team}>
|
<Expandable bind:open={$userSettings.expand.team}>
|
||||||
<span slot="title" class="py-1 px-1 flex gap-1 items-center">
|
{#snippet title()}
|
||||||
<ShieldIcon width={15} filled />
|
<span class="py-1 px-1 flex gap-1 items-center">
|
||||||
{$t('cards.community.moderators')}
|
<ShieldIcon width={15} filled />
|
||||||
</span>
|
{$t('cards.community.moderators')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={moderators.map((m) => ({
|
items={moderators.map((m) => ({
|
||||||
id: m.moderator.id,
|
id: m.moderator.id,
|
||||||
@@ -224,12 +237,13 @@
|
|||||||
on:click={subscribe}
|
on:click={subscribe}
|
||||||
class="flex-1 relative z-[inherit]"
|
class="flex-1 relative z-[inherit]"
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
<Icon
|
||||||
mini
|
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
||||||
size="16"
|
mini
|
||||||
slot="prefix"
|
size="16"
|
||||||
/>
|
/>
|
||||||
|
{/snippet}
|
||||||
{community_view.subscribed == 'Subscribed' ||
|
{community_view.subscribed == 'Subscribed' ||
|
||||||
community_view.subscribed == 'Pending'
|
community_view.subscribed == 'Pending'
|
||||||
? $t('cards.community.subscribed')
|
? $t('cards.community.subscribed')
|
||||||
@@ -240,17 +254,23 @@
|
|||||||
<Button
|
<Button
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
community_view.community.actor_id
|
community_view.community.actor_id,
|
||||||
)}/settings"
|
)}/settings"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
>
|
>
|
||||||
<Icon src={Cog6Tooth} mini size="16" slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Cog6Tooth} mini size="16" />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="top-end">
|
<Menu placement="top-end">
|
||||||
<Button size="square-md" slot="target" class="ml-auto">
|
{#snippet target()}
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini slot="prefix" />
|
<Button size="square-md" class="ml-auto">
|
||||||
</Button>
|
{#snippet prefix()}
|
||||||
|
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
<MenuButton href="/modlog?community={community_view.community.id}">
|
<MenuButton href="/modlog?community={community_view.community.id}">
|
||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
@@ -262,7 +282,9 @@
|
|||||||
on:click={() =>
|
on:click={() =>
|
||||||
block(community_view.community.id, !community_view.blocked)}
|
block(community_view.community.id, !community_view.blocked)}
|
||||||
>
|
>
|
||||||
<Icon src={NoSymbol} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={NoSymbol} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{community_view.blocked
|
{community_view.blocked
|
||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
@@ -273,7 +295,9 @@
|
|||||||
size="lg"
|
size="lg"
|
||||||
on:click={() => blockInstance(community_view.community.instance_id)}
|
on:click={() => blockInstance(community_view.community.instance_id)}
|
||||||
>
|
>
|
||||||
<Icon src={BuildingOffice2} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={BuildingOffice2} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -301,7 +325,9 @@
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Icon src={Fire} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Fire} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
@@ -15,31 +17,39 @@
|
|||||||
import ImageUploadModal from '../modal/ImageUploadModal.svelte'
|
import ImageUploadModal from '../modal/ImageUploadModal.svelte'
|
||||||
import Select from 'mono-svelte/forms/Select.svelte'
|
import Select from 'mono-svelte/forms/Select.svelte'
|
||||||
|
|
||||||
/**
|
interface Props {
|
||||||
* The community ID to edit.
|
/**
|
||||||
*/
|
* The community ID to edit.
|
||||||
export let edit: number | undefined = undefined
|
*/
|
||||||
|
edit?: number | undefined
|
||||||
export let formData: {
|
formData?: {
|
||||||
name: string
|
name: string
|
||||||
displayName: string
|
displayName: string
|
||||||
icon?: string
|
icon?: string
|
||||||
banner?: string
|
banner?: string
|
||||||
sidebar?: string
|
sidebar?: string
|
||||||
nsfw: boolean
|
nsfw: boolean
|
||||||
postsLockedToModerators: boolean
|
postsLockedToModerators: boolean
|
||||||
submitting: boolean
|
submitting: boolean
|
||||||
visibility: 'Public' | 'LocalOnly'
|
visibility: 'Public' | 'LocalOnly'
|
||||||
} = {
|
}
|
||||||
name: '',
|
formtitle?: import('svelte').Snippet
|
||||||
displayName: '',
|
|
||||||
sidebar: '',
|
|
||||||
nsfw: false,
|
|
||||||
postsLockedToModerators: false,
|
|
||||||
submitting: false,
|
|
||||||
visibility: 'Public',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
edit = undefined,
|
||||||
|
formData = $bindable({
|
||||||
|
name: '',
|
||||||
|
displayName: '',
|
||||||
|
sidebar: '',
|
||||||
|
nsfw: false,
|
||||||
|
postsLockedToModerators: false,
|
||||||
|
submitting: false,
|
||||||
|
visibility: 'Public',
|
||||||
|
}),
|
||||||
|
formtitle,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!$profile?.jwt) return
|
if (!$profile?.jwt) return
|
||||||
if ((!edit && formData.name == '') || formData.displayName == '') return
|
if ((!edit && formData.name == '') || formData.displayName == '') return
|
||||||
@@ -103,7 +113,7 @@
|
|||||||
goto(
|
goto(
|
||||||
`/c/${res.community_view.community.name}@${
|
`/c/${res.community_view.community.name}@${
|
||||||
new URL(res.community_view.community.actor_id).hostname
|
new URL(res.community_view.community.actor_id).hostname
|
||||||
}`
|
}`,
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
@@ -115,19 +125,19 @@
|
|||||||
formData.submitting = false
|
formData.submitting = false
|
||||||
}
|
}
|
||||||
|
|
||||||
let uploading = {
|
let uploading = $state({
|
||||||
banner: false,
|
banner: false,
|
||||||
icon: false,
|
icon: false,
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
on:submit|preventDefault={submit}
|
onsubmit={preventDefault(submit)}
|
||||||
class="flex flex-col gap-4 h-full w-full"
|
class="flex flex-col gap-4 h-full w-full"
|
||||||
>
|
>
|
||||||
<slot name="formtitle">
|
{#if formtitle}{@render formtitle()}{:else}
|
||||||
<Header>{$t('routes.createCommunity')}</Header>
|
<Header>{$t('routes.createCommunity')}</Header>
|
||||||
</slot>
|
{/if}
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label={$t('form.name')}
|
label={$t('form.name')}
|
||||||
@@ -147,7 +157,7 @@
|
|||||||
<Label>{$t('routes.admin.config.icon')}</Label>
|
<Label>{$t('routes.admin.config.icon')}</Label>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => (uploading.icon = !uploading.icon)}
|
onclick={() => (uploading.icon = !uploading.icon)}
|
||||||
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
||||||
>
|
>
|
||||||
{#if formData.icon}
|
{#if formData.icon}
|
||||||
@@ -175,7 +185,7 @@
|
|||||||
<Label>{$t('routes.admin.config.banner')}</Label>
|
<Label>{$t('routes.admin.config.banner')}</Label>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => (uploading.banner = !uploading.banner)}
|
onclick={() => (uploading.banner = !uploading.banner)}
|
||||||
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
||||||
>
|
>
|
||||||
{#if formData.banner}
|
{#if formData.banner}
|
||||||
|
|||||||
@@ -31,13 +31,23 @@
|
|||||||
import { isAdmin } from '../moderation/moderation'
|
import { isAdmin } from '../moderation/moderation'
|
||||||
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
||||||
|
|
||||||
export let community: Community
|
interface Props {
|
||||||
export let subscribed: SubscribedType
|
community: Community
|
||||||
export let counts: CommunityAggregates | undefined = undefined
|
subscribed: SubscribedType
|
||||||
export let moderators: CommunityModeratorView[] = []
|
counts?: CommunityAggregates | undefined
|
||||||
export let blocked: boolean = false
|
moderators?: CommunityModeratorView[]
|
||||||
let clazz: string = ''
|
blocked?: boolean
|
||||||
export { clazz as class }
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
community = $bindable(),
|
||||||
|
subscribed = $bindable(),
|
||||||
|
counts = undefined,
|
||||||
|
moderators = [],
|
||||||
|
blocked = false,
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<EntityHeader
|
<EntityHeader
|
||||||
@@ -71,27 +81,28 @@
|
|||||||
bio={community.description}
|
bio={community.description}
|
||||||
class={clazz}
|
class={clazz}
|
||||||
>
|
>
|
||||||
<button
|
{#snippet nameDetail()}
|
||||||
on:click={() => {
|
<button
|
||||||
navigator?.clipboard?.writeText?.(
|
onclick={() => {
|
||||||
`!${fullCommunityName(community.name, community.actor_id)}`
|
navigator?.clipboard?.writeText?.(
|
||||||
)
|
`!${fullCommunityName(community.name, community.actor_id)}`,
|
||||||
toast({ content: $t('toast.copied') })
|
)
|
||||||
}}
|
toast({ content: $t('toast.copied') })
|
||||||
class="text-sm flex gap-0 items-center"
|
}}
|
||||||
slot="nameDetail"
|
class="text-sm flex gap-0 items-center"
|
||||||
>
|
>
|
||||||
!{fullCommunityName(community.name, community.actor_id)}
|
!{fullCommunityName(community.name, community.actor_id)}
|
||||||
</button>
|
</button>
|
||||||
|
{/snippet}
|
||||||
{#if moderators.length > 0}
|
{#if moderators.length > 0}
|
||||||
<Expandable
|
<Expandable
|
||||||
class="border rounded-xl bg-white/50 dark:bg-zinc-900/50 w-full p-3 px-4
|
class="border rounded-xl bg-white/50 dark:bg-zinc-900/50 w-full p-3 px-4
|
||||||
dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text-zinc-300 transition-colors"
|
dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text-zinc-300 transition-colors"
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="title">
|
{#snippet title()}
|
||||||
<ShieldIcon width={15} filled />
|
<ShieldIcon width={15} filled />
|
||||||
{$t('cards.community.moderators')}
|
{$t('cards.community.moderators')}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={moderators.map((m) => ({
|
items={moderators.map((m) => ({
|
||||||
id: m.moderator.id,
|
id: m.moderator.id,
|
||||||
@@ -114,30 +125,32 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
counts: counts ?? {},
|
counts: counts ?? {},
|
||||||
subscribed: subscribed,
|
subscribed: subscribed,
|
||||||
}}
|
}}
|
||||||
let:subscribe
|
|
||||||
let:subscribing
|
|
||||||
>
|
>
|
||||||
<Button
|
{#snippet children({ subscribe, subscribing })}
|
||||||
disabled={subscribing}
|
<Button
|
||||||
loading={subscribing}
|
disabled={subscribing}
|
||||||
size="lg"
|
loading={subscribing}
|
||||||
color={subscribed == 'NotSubscribed' ? 'primary' : 'secondary'}
|
size="lg"
|
||||||
on:click={async () => {
|
color={subscribed == 'NotSubscribed' ? 'primary' : 'secondary'}
|
||||||
subscribed =
|
on:click={async () => {
|
||||||
(await subscribe())?.community_view.subscribed ?? 'NotSubscribed'
|
subscribed =
|
||||||
}}
|
(await subscribe())?.community_view.subscribed ??
|
||||||
class="flex-1 relative z-[inherit]"
|
'NotSubscribed'
|
||||||
>
|
}}
|
||||||
<Icon
|
class="flex-1 relative z-[inherit]"
|
||||||
src={subscribed != 'NotSubscribed' ? Check : Plus}
|
>
|
||||||
micro
|
{#snippet prefix()}
|
||||||
size="16"
|
<Icon
|
||||||
slot="prefix"
|
src={subscribed != 'NotSubscribed' ? Check : Plus}
|
||||||
/>
|
micro
|
||||||
{subscribed == 'Subscribed' || subscribed == 'Pending'
|
size="16"
|
||||||
? $t('cards.community.subscribed')
|
/>
|
||||||
: $t('cards.community.subscribe')}
|
{/snippet}
|
||||||
</Button>
|
{subscribed == 'Subscribed' || subscribed == 'Pending'
|
||||||
|
? $t('cards.community.subscribed')
|
||||||
|
: $t('cards.community.subscribe')}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</Subscribe>
|
</Subscribe>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -150,7 +163,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
rounding="xl"
|
rounding="xl"
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community.name,
|
community.name,
|
||||||
community.actor_id
|
community.actor_id,
|
||||||
)}/settings"
|
)}/settings"
|
||||||
style="height: 38px; width: 38px;"
|
style="height: 38px; width: 38px;"
|
||||||
>
|
>
|
||||||
@@ -158,14 +171,13 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="top-end">
|
<Menu placement="top-end">
|
||||||
<Button
|
{#snippet target()}
|
||||||
rounding="xl"
|
<Button rounding="xl" size="custom" style="height: 38px; width: 38px;">
|
||||||
size="custom"
|
{#snippet prefix()}
|
||||||
slot="target"
|
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||||
style="height: 38px; width: 38px;"
|
{/snippet}
|
||||||
>
|
</Button>
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini slot="prefix" />
|
{/snippet}
|
||||||
</Button>
|
|
||||||
<MenuButton href="/modlog?community={community.id}">
|
<MenuButton href="/modlog?community={community.id}">
|
||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
@@ -176,7 +188,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
size="lg"
|
size="lg"
|
||||||
on:click={() => block(community.id, !blocked)}
|
on:click={() => block(community.id, !blocked)}
|
||||||
>
|
>
|
||||||
<Icon src={NoSymbol} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={NoSymbol} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{blocked
|
{blocked
|
||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
@@ -187,7 +201,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
size="lg"
|
size="lg"
|
||||||
on:click={() => blockInstance(community.instance_id)}
|
on:click={() => blockInstance(community.instance_id)}
|
||||||
>
|
>
|
||||||
<Icon src={BuildingOffice2} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={BuildingOffice2} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -215,7 +231,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Icon src={Fire} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Fire} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -23,13 +23,22 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import Entity from '$lib/components/ui/Entity.svelte'
|
import Entity from '$lib/components/ui/Entity.svelte'
|
||||||
|
|
||||||
export let community: CommunityView
|
let showInfo = $state(false)
|
||||||
export let view: 'cozy' | 'compact' = 'compact'
|
interface Props {
|
||||||
export let showCounts: boolean = true
|
community: CommunityView
|
||||||
|
view?: 'cozy' | 'compact'
|
||||||
|
showCounts?: boolean
|
||||||
|
class?: string
|
||||||
|
icon?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
let showInfo = false
|
let {
|
||||||
let clazz: string = 'py-4 flex flex-col gap-4 text-sm max-w-full relative'
|
community = $bindable(),
|
||||||
export { clazz as class }
|
view = 'compact',
|
||||||
|
showCounts = true,
|
||||||
|
class: clazz = 'py-4 flex flex-col gap-4 text-sm max-w-full relative',
|
||||||
|
icon,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if showInfo}
|
{#if showInfo}
|
||||||
@@ -48,7 +57,7 @@
|
|||||||
<a
|
<a
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community.community.name,
|
community.community.name,
|
||||||
community.community.actor_id
|
community.community.actor_id,
|
||||||
)}"
|
)}"
|
||||||
class="flex-1 w-full overflow-hidden"
|
class="flex-1 w-full overflow-hidden"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
@@ -58,13 +67,13 @@
|
|||||||
? 'flex-col gap-2'
|
? 'flex-col gap-2'
|
||||||
: 'flex-row'} gap-2 items-center"
|
: 'flex-row'} gap-2 items-center"
|
||||||
>
|
>
|
||||||
<slot name="icon">
|
{#if icon}{@render icon()}{:else}
|
||||||
<Avatar
|
<Avatar
|
||||||
url={community.community.icon}
|
url={community.community.icon}
|
||||||
width={32}
|
width={32}
|
||||||
alt={community.community.name}
|
alt={community.community.name}
|
||||||
/>
|
/>
|
||||||
</slot>
|
{/if}
|
||||||
<div
|
<div
|
||||||
class="flex flex-col overflow-hidden whitespace-nowrap flex-1 min-w-0 flex-shrink"
|
class="flex flex-col overflow-hidden whitespace-nowrap flex-1 min-w-0 flex-shrink"
|
||||||
>
|
>
|
||||||
@@ -92,50 +101,55 @@
|
|||||||
<Button size="square-md" on:click={() => (showInfo = !showInfo)}>
|
<Button size="square-md" on:click={() => (showInfo = !showInfo)}>
|
||||||
<Icon src={InformationCircle} size="16" micro />
|
<Icon src={InformationCircle} size="16" micro />
|
||||||
</Button>
|
</Button>
|
||||||
<Subscribe {community} let:subscribe let:subscribing>
|
<Subscribe {community}>
|
||||||
<Button
|
{#snippet children({ subscribe, subscribing })}
|
||||||
disabled={subscribing || !$profile?.jwt}
|
<Button
|
||||||
loading={subscribing}
|
disabled={subscribing || !$profile?.jwt}
|
||||||
on:click={async () => {
|
loading={subscribing}
|
||||||
const res = await subscribe()
|
on:click={async () => {
|
||||||
|
const res = await subscribe()
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
const newSubscribed =
|
const newSubscribed =
|
||||||
res.community_view.subscribed != 'NotSubscribed'
|
res.community_view.subscribed != 'NotSubscribed'
|
||||||
? 'Subscribed'
|
? 'Subscribed'
|
||||||
: 'NotSubscribed'
|
: 'NotSubscribed'
|
||||||
|
|
||||||
community.subscribed = newSubscribed
|
community.subscribed = newSubscribed
|
||||||
addSubscription(
|
addSubscription(
|
||||||
community.community,
|
community.community,
|
||||||
newSubscribed == 'Subscribed'
|
newSubscribed == 'Subscribed',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
size="custom"
|
size="custom"
|
||||||
title={isSubscribed(community.subscribed)
|
title={isSubscribed(community.subscribed)
|
||||||
? $t('cards.community.subscribed')
|
? $t('cards.community.subscribed')
|
||||||
: $t('cards.community.subscribe')}
|
: $t('cards.community.subscribe')}
|
||||||
color={isSubscribed(community.subscribed) ? 'elevatedLow' : 'primary'}
|
color={isSubscribed(community.subscribed)
|
||||||
class="{isSubscribed(community.subscribed)
|
? 'elevatedLow'
|
||||||
? 'text-slate-600 dark:text-zinc-400'
|
: 'primary'}
|
||||||
: ''}
|
class="{isSubscribed(community.subscribed)
|
||||||
aspect-square h-8 @md:px-2 @md:min-w-32 @md:aspect-auto"
|
? 'text-slate-600 dark:text-zinc-400'
|
||||||
>
|
: ''}
|
||||||
<Icon
|
aspect-square h-8 @md:px-2 @md:min-w-32 @md:aspect-auto"
|
||||||
src={isSubscribed(community.subscribed) ? Check : Plus}
|
>
|
||||||
size="16"
|
{#snippet prefix()}
|
||||||
micro
|
<Icon
|
||||||
slot="prefix"
|
src={isSubscribed(community.subscribed) ? Check : Plus}
|
||||||
/>
|
size="16"
|
||||||
<span class="hidden @md:block">
|
micro
|
||||||
{#if isSubscribed(community.subscribed)}
|
/>
|
||||||
{$t('cards.community.subscribed')}
|
{/snippet}
|
||||||
{:else}
|
<span class="hidden @md:block">
|
||||||
{$t('cards.community.subscribe')}
|
{#if isSubscribed(community.subscribed)}
|
||||||
{/if}
|
{$t('cards.community.subscribed')}
|
||||||
</span>
|
{:else}
|
||||||
</Button>
|
{$t('cards.community.subscribe')}
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</Subscribe>
|
</Subscribe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,25 +5,37 @@
|
|||||||
import type { Community } from 'lemmy-js-client'
|
import type { Community } from 'lemmy-js-client'
|
||||||
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let community: Community
|
interface Props {
|
||||||
|
community: Community
|
||||||
export let avatar: boolean = false
|
avatar?: boolean
|
||||||
export let name: boolean = true
|
name?: boolean
|
||||||
export let avatarSize: number = 24
|
avatarSize?: number
|
||||||
export let showInstance: boolean = $userSettings.showInstances.community
|
showInstance?: boolean
|
||||||
export let displayName: boolean = true
|
displayName?: boolean
|
||||||
|
badges?: any
|
||||||
export let badges = {
|
class?: string
|
||||||
nsfw: false,
|
instanceClass?: string
|
||||||
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
let clazz: string = ''
|
let {
|
||||||
export let instanceClass: string = ''
|
community,
|
||||||
export { clazz as class }
|
avatar = false,
|
||||||
|
name = true,
|
||||||
|
avatarSize = 24,
|
||||||
|
showInstance = $userSettings.showInstances.community,
|
||||||
|
displayName = true,
|
||||||
|
badges = {
|
||||||
|
nsfw: false,
|
||||||
|
},
|
||||||
|
class: clazz = '',
|
||||||
|
instanceClass = '',
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {clazz}"
|
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {clazz}"
|
||||||
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
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
|
interface Props {
|
||||||
|
community: Community
|
||||||
|
}
|
||||||
|
|
||||||
|
let { community }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row gap-3 items-center">
|
<div class="flex flex-row gap-3 items-center">
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import { profile } from '$lib/auth'
|
import { profile } from '$lib/auth'
|
||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
@@ -14,36 +16,51 @@
|
|||||||
import { amModOfAny } from '../moderation/moderation'
|
import { amModOfAny } from '../moderation/moderation'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
export let selected: string
|
interface Props {
|
||||||
export let navigate: boolean = true
|
selected: string
|
||||||
export let changeDefault: boolean = false
|
navigate?: boolean
|
||||||
export let showLabel: boolean = true
|
changeDefault?: boolean
|
||||||
|
showLabel?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
let feed: string = selected
|
let {
|
||||||
$: feed = selected
|
selected,
|
||||||
$: changeDefault
|
navigate = true,
|
||||||
? ($userSettings.defaultSort.feed = selected as
|
changeDefault = false,
|
||||||
| 'All'
|
showLabel = true,
|
||||||
| 'Subscribed'
|
...rest
|
||||||
| 'Local')
|
}: Props = $props()
|
||||||
: undefined
|
|
||||||
|
let feed: string = $state(selected)
|
||||||
|
run(() => {
|
||||||
|
feed = selected
|
||||||
|
})
|
||||||
|
run(() => {
|
||||||
|
changeDefault
|
||||||
|
? ($userSettings.defaultSort.feed = selected as
|
||||||
|
| 'All'
|
||||||
|
| 'Subscribed'
|
||||||
|
| 'Local')
|
||||||
|
: undefined
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
bind:value={feed}
|
bind:value={feed}
|
||||||
on:change={() => {
|
on:change={() => {
|
||||||
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor')
|
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="label">
|
{#snippet customLabel()}
|
||||||
{#if showLabel}
|
{#if showLabel}
|
||||||
<span class="flex items-center gap-1">
|
<span class="flex items-center gap-1">
|
||||||
<Icon src={GlobeAmericas} size="16" micro />
|
<Icon src={GlobeAmericas} size="16" micro />
|
||||||
{$t('filter.location.label')}
|
{$t('filter.location.label')}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
<option value="All">
|
<option value="All">
|
||||||
<Icon
|
<Icon
|
||||||
src={GlobeAmericas}
|
src={GlobeAmericas}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
@@ -25,26 +27,40 @@
|
|||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
|
||||||
export let selected: string
|
interface Props {
|
||||||
export let navigate: boolean = true
|
selected: string
|
||||||
export let changeDefault: boolean = false
|
navigate?: boolean
|
||||||
|
changeDefault?: boolean
|
||||||
let sort: string = selected?.startsWith('Top') ? 'TopAll' : selected
|
class?: string
|
||||||
$: if (selected) {
|
[key: string]: any
|
||||||
sort = selected?.startsWith('Top') ? 'TopAll' : selected
|
|
||||||
}
|
}
|
||||||
const setSelected = () => (selected = sort)
|
|
||||||
$: changeDefault
|
|
||||||
? ($userSettings.defaultSort.sort = selected as SortType)
|
|
||||||
: undefined
|
|
||||||
|
|
||||||
let clazz: string = ''
|
let {
|
||||||
export { clazz as class }
|
selected = $bindable(),
|
||||||
|
navigate = true,
|
||||||
|
changeDefault = false,
|
||||||
|
class: clazz = '',
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let sort: string = $state(selected?.startsWith('Top') ? 'TopAll' : selected)
|
||||||
|
const setSelected = () => (selected = sort)
|
||||||
|
|
||||||
|
run(() => {
|
||||||
|
if (selected) {
|
||||||
|
sort = selected?.startsWith('Top') ? 'TopAll' : selected
|
||||||
|
}
|
||||||
|
})
|
||||||
|
run(() => {
|
||||||
|
changeDefault
|
||||||
|
? ($userSettings.defaultSort.sort = selected as SortType)
|
||||||
|
: undefined
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row {clazz}">
|
<div class="flex flex-row {clazz}">
|
||||||
<Select
|
<Select
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
class={selected?.startsWith('Top') ? 'rounded-r-none' : ''}
|
class={selected?.startsWith('Top') ? 'rounded-r-none' : ''}
|
||||||
bind:value={sort}
|
bind:value={sort}
|
||||||
on:change={(e) => {
|
on:change={(e) => {
|
||||||
@@ -52,10 +68,12 @@
|
|||||||
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span slot="label" class="flex items-center gap-1">
|
{#snippet label()}
|
||||||
<Icon src={ChartBar} size="13" micro />
|
<span class="flex items-center gap-1">
|
||||||
{$t('filter.sort.label')}
|
<Icon src={ChartBar} size="13" micro />
|
||||||
</span>
|
{$t('filter.sort.label')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<option value="Active">
|
<option value="Active">
|
||||||
<Icon
|
<Icon
|
||||||
src={ArrowTrendingUp}
|
src={ArrowTrendingUp}
|
||||||
@@ -149,10 +167,12 @@
|
|||||||
searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span slot="label" class="flex items-center gap-1">
|
{#snippet label()}
|
||||||
<Icon src={Clock} size="15" micro />
|
<span class="flex items-center gap-1">
|
||||||
{$t('filter.sort.top.time.label')}
|
<Icon src={Clock} size="15" micro />
|
||||||
</span>
|
{$t('filter.sort.top.time.label')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
<option value="TopAll">
|
<option value="TopAll">
|
||||||
<Icon
|
<Icon
|
||||||
src={PlusCircle}
|
src={PlusCircle}
|
||||||
|
|||||||
@@ -13,18 +13,23 @@
|
|||||||
ViewColumns,
|
ViewColumns,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let showLabel = true
|
interface Props {
|
||||||
|
showLabel?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let { showLabel = true, ...rest }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select {...$$restProps} bind:value={$userSettings.view}>
|
<Select {...rest} bind:value={$userSettings.view}>
|
||||||
<svelte:fragment slot="label">
|
{#snippet customLabel()}
|
||||||
{#if showLabel}
|
{#if showLabel}
|
||||||
<span class="flex items-center gap-1">
|
<span class="flex items-center gap-1">
|
||||||
<Icon src={ViewColumns} size="14" micro />
|
<Icon src={ViewColumns} size="14" micro />
|
||||||
{$t('filter.view.label')}
|
{$t('filter.view.label')}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
<option value="cozy">
|
<option value="cozy">
|
||||||
<Icon
|
<Icon
|
||||||
src={RectangleGroup}
|
src={RectangleGroup}
|
||||||
|
|||||||
@@ -5,13 +5,17 @@
|
|||||||
import { flip } from 'svelte/animate'
|
import { flip } from 'svelte/animate'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
|
|
||||||
export let items: {
|
interface Props {
|
||||||
avatar?: string
|
items: {
|
||||||
name: string
|
avatar?: string
|
||||||
instance?: string
|
name: string
|
||||||
id: number
|
instance?: string
|
||||||
url: string
|
id: number
|
||||||
}[]
|
url: string
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|
||||||
|
let { items }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each items.sort((a, b) => a.name.localeCompare(b.name)) as item (item.id)}
|
{#each items.sort((a, b) => a.name.localeCompare(b.name)) as item (item.id)}
|
||||||
|
|||||||
@@ -4,10 +4,13 @@
|
|||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import type { PrivateMessageView } from 'lemmy-js-client'
|
import type { PrivateMessageView } from 'lemmy-js-client'
|
||||||
|
|
||||||
export let message: PrivateMessageView
|
interface Props {
|
||||||
export let meta: boolean = true
|
message: PrivateMessageView
|
||||||
|
meta?: boolean
|
||||||
|
style?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let style: string = ''
|
let { message, meta = true, style = '' }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2 text-sm" {style}>
|
<div class="flex flex-col gap-2 text-sm" {style}>
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import type { Person } from 'lemmy-js-client'
|
import type { Person } from 'lemmy-js-client'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
import { Button, Modal } from 'mono-svelte'
|
||||||
|
|
||||||
export let open: boolean = false
|
interface Props {
|
||||||
export let user: Person
|
open?: boolean
|
||||||
|
user: Person
|
||||||
|
denying: boolean
|
||||||
|
denyReason?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let denying: boolean
|
let {
|
||||||
|
open = $bindable(false),
|
||||||
export let denyReason: string = ''
|
user,
|
||||||
|
denying = $bindable(),
|
||||||
|
denyReason = $bindable(''),
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
let loading = false
|
let loading = false
|
||||||
|
|
||||||
@@ -21,10 +30,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
<h1 class="text-2xl font-bold" slot="title">
|
{#snippet title()}
|
||||||
{$t('routes.admin.applications.modalTitle')}
|
<h1 class="text-2xl font-bold">
|
||||||
</h1>
|
{$t('routes.admin.applications.modalTitle')}
|
||||||
<form on:submit|preventDefault={() => deny()} class="flex flex-col gap-4">
|
</h1>
|
||||||
|
{/snippet}
|
||||||
|
<form onsubmit={preventDefault(() => deny())} class="flex flex-col gap-4">
|
||||||
<UserLink avatar {user} />
|
<UserLink avatar {user} />
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
bind:value={denyReason}
|
bind:value={denyReason}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import ProgressBar from '$lib/components/ui/ProgressBar.svelte'
|
import ProgressBar from '$lib/components/ui/ProgressBar.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
@@ -11,14 +13,24 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
|
|
||||||
export let open: boolean
|
interface Props {
|
||||||
export let image: FileList | null = null
|
open: boolean
|
||||||
export let preview: boolean = true
|
image?: FileList | null
|
||||||
export let multiple: boolean = true
|
preview?: boolean
|
||||||
let progress = 1
|
multiple?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
$: previewURLs =
|
let {
|
||||||
preview && image ? Array.from(image).map(URL.createObjectURL) : undefined
|
open = $bindable(),
|
||||||
|
image = $bindable(null),
|
||||||
|
preview = true,
|
||||||
|
multiple = true,
|
||||||
|
}: Props = $props()
|
||||||
|
let progress = $state(1)
|
||||||
|
|
||||||
|
let previewURLs = $derived(
|
||||||
|
preview && image ? Array.from(image).map(URL.createObjectURL) : undefined,
|
||||||
|
)
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ upload: string[] }>()
|
const dispatcher = createEventDispatcher<{ upload: string[] }>()
|
||||||
|
|
||||||
@@ -39,8 +51,8 @@
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toast({ content: errorMessage(err), type: 'error' })
|
toast({ content: errorMessage(err), type: 'error' })
|
||||||
return 'Failed to upload'
|
return 'Failed to upload'
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
).filter((i) => i != undefined)
|
).filter((i) => i != undefined)
|
||||||
|
|
||||||
@@ -61,13 +73,15 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
<div slot="title" class="flex items-center gap-2">Upload image</div>
|
{#snippet title()}
|
||||||
|
<div class="flex items-center gap-2">Upload image</div>
|
||||||
|
{/snippet}
|
||||||
{#if progress != 1}
|
{#if progress != 1}
|
||||||
<div transition:slide={{ duration: 500, easing: expoOut }} class="w-full">
|
<div transition:slide={{ duration: 500, easing: expoOut }} class="w-full">
|
||||||
<ProgressBar {progress} />
|
<ProgressBar {progress} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<form class="flex flex-col gap-4" on:submit|preventDefault={upload}>
|
<form class="flex flex-col gap-4" onsubmit={preventDefault(upload)}>
|
||||||
<label
|
<label
|
||||||
for="image-input"
|
for="image-input"
|
||||||
class="p-4 border-2 border-dashed rounded-xl cursor-pointer transition-colors
|
class="p-4 border-2 border-dashed rounded-xl cursor-pointer transition-colors
|
||||||
@@ -79,10 +93,10 @@
|
|||||||
{multiple ? 'grid-cols-3 grid-rows-2' : 'grid-cols-1 grid-rows-1'}"
|
{multiple ? 'grid-cols-3 grid-rows-2' : 'grid-cols-1 grid-rows-1'}"
|
||||||
>
|
>
|
||||||
{#each previewURLs as file}
|
{#each previewURLs as file}
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y_missing_attribute -->
|
||||||
<img
|
<img
|
||||||
src={file}
|
src={file}
|
||||||
on:load={() => URL.revokeObjectURL(file)}
|
onload={() => URL.revokeObjectURL(file)}
|
||||||
alt={file}
|
alt={file}
|
||||||
class="w-full rounded-md h-full object-cover transition-all
|
class="w-full rounded-md h-full object-cover transition-all
|
||||||
border border-slate-200 dark:border-zinc-800 ring-1
|
border border-slate-200 dark:border-zinc-800 ring-1
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
@@ -8,12 +10,16 @@
|
|||||||
import { Button, Modal, toast } from 'mono-svelte'
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let open: boolean = false
|
interface Props {
|
||||||
export let user: Person
|
open?: boolean
|
||||||
|
user: Person
|
||||||
|
}
|
||||||
|
|
||||||
let message = ''
|
let { open = $bindable(false), user }: Props = $props()
|
||||||
|
|
||||||
let loading = false
|
let message = $state('')
|
||||||
|
|
||||||
|
let loading = $state(false)
|
||||||
|
|
||||||
async function sendMessage() {
|
async function sendMessage() {
|
||||||
if (!$profile?.jwt || message == '') return
|
if (!$profile?.jwt || message == '') return
|
||||||
@@ -44,8 +50,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
<h1 class="text-2xl font-bold" slot="title">Message</h1>
|
{#snippet title()}
|
||||||
<form on:submit|preventDefault={sendMessage} class="flex flex-col gap-4">
|
<h1 class="text-2xl font-bold">Message</h1>
|
||||||
|
{/snippet}
|
||||||
|
<form onsubmit={preventDefault(sendMessage)} class="flex flex-col gap-4">
|
||||||
<p class="inline-flex flex-row gap-2 items-center">
|
<p class="inline-flex flex-row gap-2 items-center">
|
||||||
<Icon src={PaperAirplane} size="16" mini />
|
<Icon src={PaperAirplane} size="16" mini />
|
||||||
<UserLink avatar {user} />
|
<UserLink avatar {user} />
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import type { Community, Person, PersonView } from 'lemmy-js-client'
|
import type { Community, Person, PersonView } from 'lemmy-js-client'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
@@ -9,17 +11,25 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import CommunityLink from '../community/CommunityLink.svelte'
|
import CommunityLink from '../community/CommunityLink.svelte'
|
||||||
|
|
||||||
export let open = false
|
interface Props {
|
||||||
let item: Person | undefined
|
open?: boolean
|
||||||
export { item as user }
|
user: Person | undefined
|
||||||
export let community: Community | undefined
|
community: Community | undefined
|
||||||
export let banned: boolean
|
banned: boolean
|
||||||
|
}
|
||||||
|
|
||||||
let reason = ''
|
let {
|
||||||
let deleteData = false
|
open = $bindable(false),
|
||||||
let expires = ''
|
user: item = $bindable(),
|
||||||
|
community,
|
||||||
|
banned,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
let loading = false
|
let reason = $state('')
|
||||||
|
let deleteData = $state(false)
|
||||||
|
let expires = $state('')
|
||||||
|
|
||||||
|
let loading = $state(false)
|
||||||
|
|
||||||
// hack due to svelte's reactive declarations
|
// hack due to svelte's reactive declarations
|
||||||
const resetReason = () => {
|
const resetReason = () => {
|
||||||
@@ -28,7 +38,9 @@
|
|||||||
expires = ''
|
expires = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (item) resetReason()
|
run(() => {
|
||||||
|
if (item) resetReason()
|
||||||
|
})
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!item || !$profile?.user || !$profile?.jwt) return
|
if (!item || !$profile?.user || !$profile?.jwt) return
|
||||||
@@ -105,7 +117,7 @@
|
|||||||
title={banned ? $t('moderation.ban.unbanning') : $t('moderation.ban.banning')}
|
title={banned ? $t('moderation.ban.unbanning') : $t('moderation.ban.banning')}
|
||||||
>
|
>
|
||||||
{#if item}
|
{#if item}
|
||||||
<form class="flex flex-col gap-4" on:submit|preventDefault={submit}>
|
<form class="flex flex-col gap-4" onsubmit={preventDefault(submit)}>
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<Avatar url={item.avatar} alt={item.name} width={24} />
|
<Avatar url={item.avatar} alt={item.name} width={24} />
|
||||||
<span class="font-bold">{item.name}</span>
|
<span class="font-bold">{item.name}</span>
|
||||||
@@ -121,9 +133,9 @@
|
|||||||
{#if !banned}
|
{#if !banned}
|
||||||
<Checkbox bind:checked={deleteData}>
|
<Checkbox bind:checked={deleteData}>
|
||||||
{$t('moderation.ban.deleteData')}
|
{$t('moderation.ban.deleteData')}
|
||||||
<svelte:fragment slot="description">
|
{#snippet description()}
|
||||||
{$t('moderation.ban.warning')}
|
{$t('moderation.ban.warning')}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={expires}
|
bind:value={expires}
|
||||||
|
|||||||
@@ -14,19 +14,25 @@
|
|||||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
export let item: PostView | CommentView
|
interface Props {
|
||||||
|
item: PostView | CommentView
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let { item = $bindable(), ...rest }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom" class="top-0 h-[26px] w-[26px] ">
|
<Menu placement="bottom" class="top-0 h-[26px] w-[26px] ">
|
||||||
<Button
|
{#snippet target()}
|
||||||
class="w-[26px] h-[26px] hover:!text-green-500 dark:text-zinc-400 text-slate-600"
|
<Button
|
||||||
size="square-md"
|
class="w-[26px] h-[26px] hover:!text-green-500 dark:text-zinc-400 text-slate-600"
|
||||||
slot="target"
|
size="square-md"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
>
|
>
|
||||||
<ShieldIcon filled width={14} />
|
<ShieldIcon filled width={14} />
|
||||||
</Button>
|
</Button>
|
||||||
|
{/snippet}
|
||||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
||||||
<MenuDivider>
|
<MenuDivider>
|
||||||
{#if !item.community.local && !amMod($profile.user, item.community)}
|
{#if !item.community.local && !amMod($profile.user, item.community)}
|
||||||
@@ -36,7 +42,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</MenuDivider>
|
</MenuDivider>
|
||||||
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
|
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
|
||||||
<Icon src={Trash} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Trash} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{#if isCommentView(item)}
|
{#if isCommentView(item)}
|
||||||
{item.comment.removed
|
{item.comment.removed
|
||||||
? $t('moderation.restore')
|
? $t('moderation.restore')
|
||||||
@@ -52,7 +60,9 @@
|
|||||||
on:click={() =>
|
on:click={() =>
|
||||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||||
>
|
>
|
||||||
<Icon src={ShieldExclamation} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={ShieldExclamation} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{item.creator_banned_from_community
|
{item.creator_banned_from_community
|
||||||
? $t('moderation.ban.unbanFromCommunity')
|
? $t('moderation.ban.unbanFromCommunity')
|
||||||
: $t('moderation.ban.banFromCommunity')}
|
: $t('moderation.ban.banFromCommunity')}
|
||||||
@@ -67,12 +77,14 @@
|
|||||||
await feature(
|
await feature(
|
||||||
!item.comment.distinguished,
|
!item.comment.distinguished,
|
||||||
item.comment,
|
item.comment,
|
||||||
$profile.jwt
|
$profile.jwt,
|
||||||
)
|
)
|
||||||
).comment_view.comment
|
).comment_view.comment
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Megaphone} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Megaphone} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{item.comment.distinguished
|
{item.comment.distinguished
|
||||||
? $t('moderation.unfeature')
|
? $t('moderation.unfeature')
|
||||||
: $t('moderation.feature')}
|
: $t('moderation.feature')}
|
||||||
@@ -83,7 +95,9 @@
|
|||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if $profile?.user && isAdmin($profile.user)}
|
||||||
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
||||||
<Icon src={Fire} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Fire} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -18,12 +18,17 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import ShieldIcon from './ShieldIcon.svelte'
|
import ShieldIcon from './ShieldIcon.svelte'
|
||||||
|
|
||||||
export let item: PostView | CommentView
|
interface Props {
|
||||||
|
item: PostView | CommentView
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
let locking = false
|
let { item = $bindable(), ...rest }: Props = $props()
|
||||||
let pinning = false
|
|
||||||
|
|
||||||
$: acting = locking || pinning
|
let locking = $state(false)
|
||||||
|
let pinning = $state(false)
|
||||||
|
|
||||||
|
let acting = $derived(locking || pinning)
|
||||||
|
|
||||||
async function lock(lock: boolean) {
|
async function lock(lock: boolean) {
|
||||||
if (!$profile?.jwt || !isPostView(item)) return
|
if (!$profile?.jwt || !isPostView(item)) return
|
||||||
@@ -71,16 +76,17 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
<Button
|
{#snippet target()}
|
||||||
class="hover:!text-green-500"
|
<Button
|
||||||
slot="target"
|
class="hover:!text-green-500"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
loading={acting}
|
loading={acting}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
>
|
>
|
||||||
<ShieldIcon filled width={16} />
|
<ShieldIcon filled width={16} />
|
||||||
</Button>
|
</Button>
|
||||||
|
{/snippet}
|
||||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
||||||
<MenuDivider>
|
<MenuDivider>
|
||||||
{#if !item.community.local && !amMod($profile.user, item.community)}
|
{#if !item.community.local && !amMod($profile.user, item.community)}
|
||||||
@@ -95,12 +101,9 @@
|
|||||||
loading={locking}
|
loading={locking}
|
||||||
disabled={locking}
|
disabled={locking}
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={item.post.locked ? LockOpen : LockClosed}
|
<Icon src={item.post.locked ? LockOpen : LockClosed} size="16" mini />
|
||||||
size="16"
|
{/snippet}
|
||||||
mini
|
|
||||||
slot="prefix"
|
|
||||||
/>
|
|
||||||
{item.post.locked ? $t('moderation.unlock') : $t('moderation.lock')}
|
{item.post.locked ? $t('moderation.unlock') : $t('moderation.lock')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import { Select, Switch, toast } from 'mono-svelte'
|
import { Select, Switch, toast } from 'mono-svelte'
|
||||||
@@ -16,21 +18,31 @@
|
|||||||
import { Button, Checkbox, Modal } from 'mono-svelte'
|
import { Button, Checkbox, Modal } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
export let open: boolean
|
interface Props {
|
||||||
export let item: PostView | CommentView | undefined = undefined
|
open: boolean
|
||||||
export let purge: boolean = false
|
item?: PostView | CommentView | undefined
|
||||||
|
purge?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
let reason = ''
|
let {
|
||||||
let commentReason: boolean = false
|
open = $bindable(),
|
||||||
let privateMessage: boolean = false
|
item = $bindable(undefined),
|
||||||
let loading = false
|
purge = false,
|
||||||
let preset = $userSettings.moderation.presets[0]?.content ?? ''
|
}: Props = $props()
|
||||||
|
|
||||||
$: removed = item
|
let reason = $state('')
|
||||||
? isCommentView(item)
|
let commentReason: boolean = $state(false)
|
||||||
? item.comment.removed
|
let privateMessage: boolean = $state(false)
|
||||||
: item.post.removed
|
let loading = $state(false)
|
||||||
: false
|
let preset = $state($userSettings.moderation.presets[0]?.content ?? '')
|
||||||
|
|
||||||
|
let removed = $derived(
|
||||||
|
item
|
||||||
|
? isCommentView(item)
|
||||||
|
? item.comment.removed
|
||||||
|
: item.post.removed
|
||||||
|
: false,
|
||||||
|
)
|
||||||
|
|
||||||
const getReplyReason = (reason: string, preset: string) => {
|
const getReplyReason = (reason: string, preset: string) => {
|
||||||
if (!item) return `no template`
|
if (!item) return `no template`
|
||||||
@@ -38,7 +50,7 @@
|
|||||||
return removalTemplate(preset, {
|
return removalTemplate(preset, {
|
||||||
communityLink: `!${fullCommunityName(
|
communityLink: `!${fullCommunityName(
|
||||||
item!.community.name,
|
item!.community.name,
|
||||||
item!.community.actor_id
|
item!.community.actor_id,
|
||||||
)}`,
|
)}`,
|
||||||
postTitle: item.post.name,
|
postTitle: item.post.name,
|
||||||
reason: reason,
|
reason: reason,
|
||||||
@@ -46,7 +58,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$: replyReason = commentReason ? getReplyReason(reason, preset) : ''
|
let replyReason
|
||||||
|
run(() => {
|
||||||
|
replyReason = commentReason ? getReplyReason(reason, preset) : ''
|
||||||
|
})
|
||||||
|
|
||||||
async function remove() {
|
async function remove() {
|
||||||
if (!item) return
|
if (!item) return
|
||||||
@@ -151,11 +166,11 @@
|
|||||||
commentReason = false
|
commentReason = false
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
run(() => {
|
||||||
if (item) {
|
if (item) {
|
||||||
resetText()
|
resetText()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
@@ -168,7 +183,7 @@
|
|||||||
>
|
>
|
||||||
{#if item}
|
{#if item}
|
||||||
<form
|
<form
|
||||||
on:submit|preventDefault={remove}
|
onsubmit={preventDefault(remove)}
|
||||||
class="flex flex-col gap-4 list-none"
|
class="flex flex-col gap-4 list-none"
|
||||||
>
|
>
|
||||||
{#if isCommentView(item)}
|
{#if isCommentView(item)}
|
||||||
@@ -212,16 +227,18 @@
|
|||||||
placeholder={replyReason}
|
placeholder={replyReason}
|
||||||
rows={3}
|
rows={3}
|
||||||
>
|
>
|
||||||
<div class="flex justify-between items-end mb-1" slot="label">
|
{#snippet label()}
|
||||||
{$t('comment.reply')}
|
<div class="flex justify-between items-end mb-1">
|
||||||
<Select bind:value={preset} placeholder="No preset">
|
{$t('comment.reply')}
|
||||||
{#each $userSettings.moderation.presets as preset}
|
<Select bind:value={preset} placeholder="No preset">
|
||||||
<option value={preset.content}>
|
{#each $userSettings.moderation.presets as preset}
|
||||||
{preset.title}
|
<option value={preset.content}>
|
||||||
</option>
|
{preset.title}
|
||||||
{/each}
|
</option>
|
||||||
</Select>
|
{/each}
|
||||||
</div>
|
</Select>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
</MarkdownEditor>
|
</MarkdownEditor>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -233,7 +250,9 @@
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
submit
|
submit
|
||||||
>
|
>
|
||||||
<Icon src={purge ? Fire : Trash} mini size="16" slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={purge ? Fire : Trash} mini size="16" />
|
||||||
|
{/snippet}
|
||||||
{#if purge}
|
{#if purge}
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
@@ -16,24 +18,27 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
||||||
|
|
||||||
export let open: boolean
|
interface Props {
|
||||||
export let item: PostView | CommentView | PrivateMessageView | undefined =
|
open: boolean
|
||||||
undefined
|
item?: PostView | CommentView | PrivateMessageView | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
let { open = $bindable(), item = undefined }: Props = $props()
|
||||||
|
|
||||||
const isComment = (
|
const isComment = (
|
||||||
item: PostView | CommentView | PrivateMessageView
|
item: PostView | CommentView | PrivateMessageView,
|
||||||
): item is CommentView => 'comment' in item
|
): item is CommentView => 'comment' in item
|
||||||
|
|
||||||
const isPost = (
|
const isPost = (
|
||||||
item: PostView | CommentView | PrivateMessageView
|
item: PostView | CommentView | PrivateMessageView,
|
||||||
): item is PostView => !isComment(item) && 'post' in item
|
): item is PostView => !isComment(item) && 'post' in item
|
||||||
|
|
||||||
const isPrivateMessage = (
|
const isPrivateMessage = (
|
||||||
item: PostView | CommentView | PrivateMessageView
|
item: PostView | CommentView | PrivateMessageView,
|
||||||
): item is PrivateMessageView => !isComment(item) && 'private_message' in item
|
): item is PrivateMessageView => !isComment(item) && 'private_message' in item
|
||||||
|
|
||||||
let loading = false
|
let loading = $state(false)
|
||||||
let reason = ''
|
let reason = $state('')
|
||||||
|
|
||||||
async function report() {
|
async function report() {
|
||||||
if (!item || !$profile?.jwt || reason == '') return
|
if (!item || !$profile?.jwt || reason == '') return
|
||||||
@@ -70,15 +75,15 @@
|
|||||||
|
|
||||||
const resetText = () => (reason = '')
|
const resetText = () => (reason = '')
|
||||||
|
|
||||||
$: {
|
run(() => {
|
||||||
if (item) {
|
if (item) {
|
||||||
resetText()
|
resetText()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open title={$t('moderation.reportModal.title')}>
|
<Modal bind:open title={$t('moderation.reportModal.title')}>
|
||||||
<form class="flex flex-col gap-4" on:submit|preventDefault={report}>
|
<form class="flex flex-col gap-4" onsubmit={preventDefault(report)}>
|
||||||
{#if item}
|
{#if item}
|
||||||
<div class="pointer-events-none list-none">
|
<div class="pointer-events-none list-none">
|
||||||
{#if isComment(item)}
|
{#if isComment(item)}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let width: number = 16
|
interface Props {
|
||||||
export let filled: boolean = false
|
width?: number
|
||||||
|
filled?: boolean
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
let clazz: string = ''
|
let { width = 16, filled = false, class: clazz = '' }: Props = $props()
|
||||||
export { clazz as class }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if filled}
|
{#if filled}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export const removalTemplate = (
|
|||||||
communityLink?: string
|
communityLink?: string
|
||||||
username?: string
|
username?: string
|
||||||
reason?: string
|
reason?: string
|
||||||
}
|
},
|
||||||
) => {
|
) => {
|
||||||
if (content.postTitle) input = input.replaceAll('{{post}}', content.postTitle)
|
if (content.postTitle) input = input.replaceAll('{{post}}', content.postTitle)
|
||||||
if (content.communityLink)
|
if (content.communityLink)
|
||||||
|
|||||||
@@ -31,26 +31,6 @@
|
|||||||
import { profile } from '$lib/auth'
|
import { profile } from '$lib/auth'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
export let post: PostView
|
|
||||||
export let actions: boolean = true
|
|
||||||
export let hideCommunity = false
|
|
||||||
export let view = $userSettings.view
|
|
||||||
|
|
||||||
$: tags = parseTags(post.post.name)
|
|
||||||
$: type = mediaType(post.post.url, view)
|
|
||||||
$: rule = getTagRule(tags.tags)
|
|
||||||
|
|
||||||
$: hideTitle =
|
|
||||||
$userSettings.posts.deduplicateEmbed &&
|
|
||||||
post.post.embed_title == post.post.name &&
|
|
||||||
view != 'compact' &&
|
|
||||||
type != 'iframe'
|
|
||||||
|
|
||||||
$: hideBody =
|
|
||||||
$userSettings.posts.deduplicateEmbed &&
|
|
||||||
post.post.embed_description == post.post.body &&
|
|
||||||
view != 'compact'
|
|
||||||
|
|
||||||
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
|
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
|
||||||
const tagContent = tags.map((t) => t.content.toLowerCase())
|
const tagContent = tags.map((t) => t.content.toLowerCase())
|
||||||
|
|
||||||
@@ -75,9 +55,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let style: string = ''
|
interface Props {
|
||||||
let clazz: string = ''
|
post: PostView
|
||||||
export { clazz as class }
|
actions?: boolean
|
||||||
|
hideCommunity?: boolean
|
||||||
|
view?: any
|
||||||
|
style?: string
|
||||||
|
class?: string
|
||||||
|
badges?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
post,
|
||||||
|
actions = true,
|
||||||
|
hideCommunity = false,
|
||||||
|
view = $userSettings.view,
|
||||||
|
style = '',
|
||||||
|
class: clazz = '',
|
||||||
|
badges,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let tags = $derived(parseTags(post.post.name))
|
||||||
|
let type = $derived(mediaType(post.post.url, view))
|
||||||
|
let rule = $derived(getTagRule(tags.tags))
|
||||||
|
let hideTitle = $derived(
|
||||||
|
$userSettings.posts.deduplicateEmbed &&
|
||||||
|
post.post.embed_title == post.post.name &&
|
||||||
|
view != 'compact' &&
|
||||||
|
type != 'iframe',
|
||||||
|
)
|
||||||
|
let hideBody = $derived(
|
||||||
|
$userSettings.posts.deduplicateEmbed &&
|
||||||
|
post.post.embed_description == post.post.body &&
|
||||||
|
view != 'compact',
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -85,9 +96,9 @@
|
|||||||
This is the sole component for displaying posts.
|
This is the sole component for displaying posts.
|
||||||
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
|
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
|
||||||
-->
|
-->
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||||
<div
|
<div
|
||||||
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none
|
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none
|
||||||
group
|
group
|
||||||
@@ -97,10 +108,10 @@
|
|||||||
{view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''}
|
{view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''}
|
||||||
{clazz ?? ''}"
|
{clazz ?? ''}"
|
||||||
id={post.post.id.toString()}
|
id={post.post.id.toString()}
|
||||||
on:click={(e) => {
|
onclick={(e) => {
|
||||||
onClick(e)
|
onClick(e)
|
||||||
}}
|
}}
|
||||||
on:keydown={(e) => {
|
onkeydown={(e) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (e.key == 'Enter') onClick(e)
|
if (e.key == 'Enter') onClick(e)
|
||||||
}}
|
}}
|
||||||
@@ -135,7 +146,9 @@
|
|||||||
tags={tags?.tags}
|
tags={tags?.tags}
|
||||||
{view}
|
{view}
|
||||||
>
|
>
|
||||||
<slot name="badges" slot="badges" />
|
{#snippet extraBadges()}
|
||||||
|
{@render badges?.()}
|
||||||
|
{/snippet}
|
||||||
</PostMeta>
|
</PostMeta>
|
||||||
{#key post.post.url}
|
{#key post.post.url}
|
||||||
<div
|
<div
|
||||||
@@ -178,11 +191,15 @@
|
|||||||
{:else if view == 'compact'}
|
{:else if view == 'compact'}
|
||||||
<div class="flex flex-row items-center gap-2 text-sm">
|
<div class="flex flex-row items-center gap-2 text-sm">
|
||||||
<Badge>
|
<Badge>
|
||||||
<Icon src={ArrowUp} slot="icon" size="14" micro />
|
{#snippet icon()}
|
||||||
|
<Icon src={ArrowUp} size="14" micro />
|
||||||
|
{/snippet}
|
||||||
{post.counts.score}
|
{post.counts.score}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge>
|
<Badge>
|
||||||
<Icon src={ChatBubbleOvalLeft} slot="icon" size="14" micro />
|
{#snippet icon()}
|
||||||
|
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
||||||
|
{/snippet}
|
||||||
{post.counts.comments}
|
{post.counts.comments}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
@@ -194,7 +211,7 @@
|
|||||||
group-hover:inset-y-0.5 group-hover:-inset-x-4 group-hover:sm:-inset-x-5 group-hover:opacity-100
|
group-hover:inset-y-0.5 group-hover:-inset-x-4 group-hover:sm:-inset-x-5 group-hover:opacity-100
|
||||||
group-focus:inset-y-0.5 group-focus:-inset-x-4 group-focus:sm:-inset-x-5 group-focus:opacity-100
|
group-focus:inset-y-0.5 group-focus:-inset-x-4 group-focus:sm:-inset-x-5 group-focus:opacity-100
|
||||||
duration-150"
|
duration-150"
|
||||||
/>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
|
|||||||
@@ -67,28 +67,37 @@
|
|||||||
formatRelativeDate,
|
formatRelativeDate,
|
||||||
} from '$lib/components/util/RelativeDate.svelte'
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
|
||||||
export let post: PostView
|
|
||||||
export let view: View = 'cozy'
|
|
||||||
export let debug: boolean = false
|
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ edit: PostView; hide: boolean }>()
|
const dispatcher = createEventDispatcher<{ edit: PostView; hide: boolean }>()
|
||||||
|
|
||||||
let editing = false
|
let editing = $state(false)
|
||||||
let saving = false
|
let saving = $state(false)
|
||||||
|
|
||||||
let translating = false
|
let translating = $state(false)
|
||||||
|
|
||||||
let localShare = false
|
let localShare = $state(false)
|
||||||
|
|
||||||
$: buttonHeight = view == 'compact' ? 'h-7' : 'h-8'
|
interface Props {
|
||||||
$: buttonSquare = view == 'compact' ? 'w-7 h-7' : 'w-8 h-8'
|
post: PostView
|
||||||
|
view?: View
|
||||||
|
debug?: boolean
|
||||||
|
style?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let style: string = ''
|
let {
|
||||||
|
post = $bindable(),
|
||||||
|
view = 'cozy',
|
||||||
|
debug = $bindable(false),
|
||||||
|
style = '',
|
||||||
|
}: Props = $props()
|
||||||
|
let buttonHeight = $derived(view == 'compact' ? 'h-7' : 'h-8')
|
||||||
|
let buttonSquare = $derived(view == 'compact' ? 'w-7 h-7' : 'w-8 h-8')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if editing}
|
{#if editing}
|
||||||
<Modal bind:open={editing}>
|
<Modal bind:open={editing}>
|
||||||
<h1 slot="title" class="text-2xl font-bold">Editing post</h1>
|
{#snippet customTitle()}
|
||||||
|
<h1 class="text-2xl font-bold">Editing post</h1>
|
||||||
|
{/snippet}
|
||||||
{#await import('./form/PostForm.svelte')}
|
{#await import('./form/PostForm.svelte')}
|
||||||
<div class="mx-auto h-96 flex justify-center items-center">
|
<div class="mx-auto h-96 flex justify-center items-center">
|
||||||
<Spinner width={32} />
|
<Spinner width={32} />
|
||||||
@@ -103,10 +112,10 @@
|
|||||||
dispatcher('edit', e.detail)
|
dispatcher('edit', e.detail)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="formtitle">
|
{#snippet formtitle()}
|
||||||
<!-- Have the title not exist at all -->
|
<!-- Have the title not exist at all -->
|
||||||
{''}
|
{''}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
</PostForm>
|
</PostForm>
|
||||||
{/await}
|
{/await}
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -152,7 +161,7 @@
|
|||||||
/>
|
/>
|
||||||
<FormattedNumber number={post.counts.comments} />
|
<FormattedNumber number={post.counts.comments} />
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex-1" />
|
<div class="flex-1"></div>
|
||||||
|
|
||||||
{#if $userSettings.debugInfo}
|
{#if $userSettings.debugInfo}
|
||||||
{#if debug}
|
{#if debug}
|
||||||
@@ -169,7 +178,9 @@
|
|||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
animations={{ scale: true, large: true }}
|
animations={{ scale: true, large: true }}
|
||||||
>
|
>
|
||||||
<Icon src={BugAnt} micro size="16" slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={BugAnt} micro size="16" />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
||||||
@@ -200,12 +211,9 @@
|
|||||||
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||||
animations={{ scale: true, large: true }}
|
animations={{ scale: true, large: true }}
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={post.saved ? BookmarkSlash : Bookmark}
|
<Icon src={post.saved ? BookmarkSlash : Bookmark} size="16" mini />
|
||||||
size="16"
|
{/snippet}
|
||||||
mini
|
|
||||||
slot="prefix"
|
|
||||||
/>
|
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -216,21 +224,26 @@
|
|||||||
targetClass="h-full"
|
targetClass="h-full"
|
||||||
title={$t('post.actions.more.label')}
|
title={$t('post.actions.more.label')}
|
||||||
>
|
>
|
||||||
<Button
|
{#snippet target()}
|
||||||
slot="target"
|
<Button
|
||||||
title={$t('post.actions.more.label')}
|
title={$t('post.actions.more.label')}
|
||||||
color="ghost"
|
color="ghost"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="custom"
|
size="custom"
|
||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
animations={{ scale: true, large: true }}
|
animations={{ scale: true, large: true }}
|
||||||
>
|
>
|
||||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} micro />
|
{#snippet prefix()}
|
||||||
</Button>
|
<Icon src={EllipsisHorizontal} width={16} micro />
|
||||||
|
{/snippet}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
<MenuDivider>{$t('cards.site.stats')}</MenuDivider>
|
<MenuDivider>{$t('cards.site.stats')}</MenuDivider>
|
||||||
<div class="flex flex-row gap-1 items-center">
|
<div class="flex flex-row gap-1 items-center">
|
||||||
<MenuButton class="flex-1">
|
<MenuButton class="flex-1">
|
||||||
<Icon src={Clock} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Clock} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
<span>
|
<span>
|
||||||
{publishedToDate(post.post.published).toLocaleDateString(undefined, {
|
{publishedToDate(post.post.published).toLocaleDateString(undefined, {
|
||||||
dateStyle: 'short',
|
dateStyle: 'short',
|
||||||
@@ -242,10 +255,12 @@
|
|||||||
publishedToDate(post.post.updated),
|
publishedToDate(post.post.updated),
|
||||||
{
|
{
|
||||||
style: 'long',
|
style: 'long',
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
<MenuButton class="flex-1" aria-label={editedTime}>
|
<MenuButton class="flex-1" aria-label={editedTime}>
|
||||||
<Icon src={Pencil} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Pencil} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
<RelativeDate date={publishedToDate(post.post.updated)} />
|
<RelativeDate date={publishedToDate(post.post.updated)} />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -256,7 +271,9 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
aria-label={$t('aria.vote.score', { default: post.counts.score })}
|
aria-label={$t('aria.vote.score', { default: post.counts.score })}
|
||||||
>
|
>
|
||||||
<Icon src={ArrowsUpDown} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={ArrowsUpDown} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.vote.score')}
|
{$t('post.actions.vote.score')}
|
||||||
•
|
•
|
||||||
<FormattedNumber
|
<FormattedNumber
|
||||||
@@ -276,25 +293,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
||||||
<MenuButton link href={userLink(post.creator)}>
|
<MenuButton link href={userLink(post.creator)}>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={UserCircle}
|
<Icon src={UserCircle} size="16" micro class="flex-shrink-0" />
|
||||||
size="16"
|
{/snippet}
|
||||||
micro
|
|
||||||
slot="prefix"
|
|
||||||
class="flex-shrink-0"
|
|
||||||
/>
|
|
||||||
<TextProps wrap="no-wrap">
|
<TextProps wrap="no-wrap">
|
||||||
{post.creator.name}
|
{post.creator.name}
|
||||||
</TextProps>
|
</TextProps>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton link href={communityLink(post.community)}>
|
<MenuButton link href={communityLink(post.community)}>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={Newspaper}
|
<Icon src={Newspaper} size="16" micro class="flex-shrink-0" />
|
||||||
size="16"
|
{/snippet}
|
||||||
micro
|
|
||||||
slot="prefix"
|
|
||||||
class="flex-shrink-0"
|
|
||||||
/>
|
|
||||||
<TextProps wrap="no-wrap">
|
<TextProps wrap="no-wrap">
|
||||||
{post.community.title}
|
{post.community.title}
|
||||||
</TextProps>
|
</TextProps>
|
||||||
@@ -304,7 +313,9 @@
|
|||||||
</MenuDivider>
|
</MenuDivider>
|
||||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton on:click={() => (editing = true)}>
|
<MenuButton on:click={() => (editing = true)}>
|
||||||
<Icon src={PencilSquare} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={PencilSquare} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.edit')}
|
{$t('post.actions.more.edit')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -315,7 +326,9 @@
|
|||||||
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon slot="prefix" src={post.read ? EyeSlash : Eye} size="16" micro />
|
{#snippet prefix()}
|
||||||
|
<Icon src={post.read ? EyeSlash : Eye} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{post.read
|
{post.read
|
||||||
? $t('post.actions.more.markUnread')
|
? $t('post.actions.more.markUnread')
|
||||||
: $t('post.actions.more.markRead')}
|
: $t('post.actions.more.markRead')}
|
||||||
@@ -331,15 +344,17 @@
|
|||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
localShare
|
localShare
|
||||||
? `${instanceToURL(getInstance())}/post/${post.post.id}`
|
? `${instanceToURL(getInstance())}/post/${post.post.id}`
|
||||||
: post.post.ap_id
|
: post.post.ap_id,
|
||||||
)
|
)
|
||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
}}
|
}}
|
||||||
class="flex-1 !py-0"
|
class="flex-1 !py-0"
|
||||||
>
|
>
|
||||||
<Icon src={Share} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Share} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
<div class="flex-1" />
|
<div class="flex-1"></div>
|
||||||
{#if !post.post.local}
|
{#if !post.post.local}
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Button
|
<Button
|
||||||
@@ -371,7 +386,9 @@
|
|||||||
translating = !translating
|
translating = !translating
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Language} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Language} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.translate')}
|
{$t('post.actions.more.translate')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -399,7 +416,9 @@
|
|||||||
goto('/create/post?crosspost=true')
|
goto('/create/post?crosspost=true')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={ArrowTopRightOnSquare} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={ArrowTopRightOnSquare} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.crosspost')}
|
{$t('post.actions.more.crosspost')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
||||||
@@ -409,12 +428,14 @@
|
|||||||
post.post.deleted = await deleteItem(
|
post.post.deleted = await deleteItem(
|
||||||
post,
|
post,
|
||||||
!post.post.deleted,
|
!post.post.deleted,
|
||||||
$profile.jwt
|
$profile.jwt,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
>
|
>
|
||||||
<Icon src={Trash} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Trash} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{post.post.deleted
|
{post.post.deleted
|
||||||
? $t('post.actions.more.restore')
|
? $t('post.actions.more.restore')
|
||||||
: $t('post.actions.more.delete')}
|
: $t('post.actions.more.delete')}
|
||||||
@@ -428,7 +449,7 @@
|
|||||||
const hidden = await hidePost(
|
const hidden = await hidePost(
|
||||||
post.post.id,
|
post.post.id,
|
||||||
!post.hidden,
|
!post.hidden,
|
||||||
$profile?.jwt
|
$profile?.jwt,
|
||||||
)
|
)
|
||||||
post.hidden = hidden
|
post.hidden = hidden
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
@@ -437,14 +458,18 @@
|
|||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
>
|
>
|
||||||
<Icon slot="prefix" src={XMark} size="16" micro />
|
{#snippet prefix()}
|
||||||
|
<Icon src={XMark} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{post.hidden
|
{post.hidden
|
||||||
? $t('post.actions.more.unhide')
|
? $t('post.actions.more.unhide')
|
||||||
: $t('post.actions.more.hide')}
|
: $t('post.actions.more.hide')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuButton on:click={() => report(post)} color="danger-subtle">
|
<MenuButton on:click={() => report(post)} color="danger-subtle">
|
||||||
<Icon src={Flag} width={16} micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Flag} width={16} micro />
|
||||||
|
{/snippet}
|
||||||
{$t('moderation.report')}
|
{$t('moderation.report')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -4,15 +4,8 @@
|
|||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let body: string
|
let expanded = $state(false)
|
||||||
export let view: View = 'cozy'
|
let element: Element = $state()
|
||||||
export let clickThrough = false
|
|
||||||
let htmlElement = 'div'
|
|
||||||
|
|
||||||
export { htmlElement as element }
|
|
||||||
|
|
||||||
let expanded = false
|
|
||||||
let element: Element
|
|
||||||
|
|
||||||
function isOverflown(element: Element, body: string = '') {
|
function isOverflown(element: Element, body: string = '') {
|
||||||
if (!element) return
|
if (!element) return
|
||||||
@@ -26,11 +19,25 @@
|
|||||||
return overflows
|
return overflows
|
||||||
}
|
}
|
||||||
|
|
||||||
$: overflows = isOverflown(element, body)
|
interface Props {
|
||||||
|
body: string
|
||||||
|
view?: View
|
||||||
|
clickThrough?: boolean
|
||||||
|
element?: string
|
||||||
|
style?: string
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let style: string = ''
|
let {
|
||||||
let clazz: string = ''
|
body,
|
||||||
export { clazz as class }
|
view = 'cozy',
|
||||||
|
clickThrough = false,
|
||||||
|
element: htmlElement = 'div',
|
||||||
|
style = '',
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let overflows = $derived(isOverflown(element, body))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:element
|
<svelte:element
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
export interface Tag {
|
export interface Tag {
|
||||||
content: string
|
content: string
|
||||||
color?: string
|
color?: string
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
])
|
])
|
||||||
|
|
||||||
export const parseTags = (
|
export const parseTags = (
|
||||||
title?: string
|
title?: string,
|
||||||
): { tags: Tag[]; title?: string } => {
|
): { tags: Tag[]; title?: string } => {
|
||||||
if (!title) return { tags: [] }
|
if (!title) return { tags: [] }
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
extracted.push(
|
extracted.push(
|
||||||
textToTag.get(content) ?? {
|
textToTag.get(content) ?? {
|
||||||
content: content,
|
content: content,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return ''
|
return ''
|
||||||
@@ -43,6 +43,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { stopPropagation } from 'svelte/legacy'
|
||||||
|
|
||||||
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, Popover } from 'mono-svelte'
|
import { Badge, Popover } from 'mono-svelte'
|
||||||
@@ -70,37 +72,53 @@
|
|||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
|
|
||||||
export let community: Community | undefined = undefined
|
let popoverOpen = $state(false)
|
||||||
export let showCommunity: boolean = true
|
|
||||||
export let subscribed: SubscribedType | undefined = undefined
|
|
||||||
|
|
||||||
export let user: Person | undefined = undefined
|
interface Props {
|
||||||
export let published: Date | undefined = undefined
|
community?: Community | undefined
|
||||||
export let title: string | undefined = undefined
|
showCommunity?: boolean
|
||||||
export let id: number | undefined = undefined
|
subscribed?: SubscribedType | undefined
|
||||||
export let read: boolean = false
|
user?: Person | undefined
|
||||||
export let edited: string | undefined = undefined
|
published?: Date | undefined
|
||||||
|
title?: string | undefined
|
||||||
export let view: View = 'cozy'
|
id?: number | undefined
|
||||||
|
read?: boolean
|
||||||
// Badges
|
edited?: string | undefined
|
||||||
export let badges = {
|
view?: View
|
||||||
nsfw: false,
|
// Badges
|
||||||
saved: false,
|
badges?: any
|
||||||
featured: false,
|
tags?: Tag[]
|
||||||
deleted: false,
|
style?: string
|
||||||
removed: false,
|
titleClass?: string
|
||||||
locked: false,
|
extraBadges?: import('svelte').Snippet
|
||||||
moderator: false,
|
|
||||||
admin: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let tags: Tag[] = []
|
let {
|
||||||
|
community = $bindable(undefined),
|
||||||
let popoverOpen = false
|
showCommunity = true,
|
||||||
|
subscribed = $bindable(undefined),
|
||||||
export let style: string = ''
|
user = undefined,
|
||||||
export let titleClass: string = ''
|
published = undefined,
|
||||||
|
title = undefined,
|
||||||
|
id = undefined,
|
||||||
|
read = false,
|
||||||
|
edited = undefined,
|
||||||
|
view = 'cozy',
|
||||||
|
badges = {
|
||||||
|
nsfw: false,
|
||||||
|
saved: false,
|
||||||
|
featured: false,
|
||||||
|
deleted: false,
|
||||||
|
removed: false,
|
||||||
|
locked: false,
|
||||||
|
moderator: false,
|
||||||
|
admin: false,
|
||||||
|
},
|
||||||
|
tags = [],
|
||||||
|
style = '',
|
||||||
|
titleClass = '',
|
||||||
|
extraBadges,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -114,32 +132,36 @@
|
|||||||
class:compact={view == 'compact'}
|
class:compact={view == 'compact'}
|
||||||
{style}
|
{style}
|
||||||
>
|
>
|
||||||
{#if showCommunity && community && subscribed && showCommunity}
|
{#if showCommunity && community != undefined && subscribed}
|
||||||
<Popover bind:open={popoverOpen} manual>
|
<Popover bind:open={popoverOpen} manual>
|
||||||
<button
|
{#snippet target()}
|
||||||
on:click={() => (popoverOpen = !popoverOpen)}
|
<button
|
||||||
class="relative cursor-pointer row-span-2 flex-shrink-0 pr-2 group/community"
|
onclick={() => (popoverOpen = !popoverOpen)}
|
||||||
slot="target"
|
class="relative cursor-pointer row-span-2 flex-shrink-0 pr-2 group/community"
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={community.icon}
|
url={community?.icon}
|
||||||
width={view == 'compact' ? 24 : 32}
|
width={view == 'compact' ? 24 : 32}
|
||||||
alt={community.name}
|
alt={community?.name}
|
||||||
class="group-hover/community:ring-2 transition-all ring-offset-0 ring-primary-900 dark:ring-primary-100"
|
class="group-hover/community:ring-2 transition-all ring-offset-0 ring-primary-900 dark:ring-primary-100"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
{/snippet}
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<div
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
slot="popover"
|
{#snippet popover()}
|
||||||
class="max-w-md rounded-2xl bg-white dark:bg-zinc-950"
|
{#if community && subscribed}
|
||||||
on:click|stopPropagation={() => {}}
|
<div
|
||||||
>
|
class="max-w-md rounded-2xl bg-white dark:bg-zinc-950"
|
||||||
<CommunityHeader bind:community bind:subscribed />
|
onclick={stopPropagation(() => {})}
|
||||||
</div>
|
>
|
||||||
|
<CommunityHeader bind:community bind:subscribed />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
</Popover>
|
</Popover>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
{/if}
|
{/if}
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
<CommunityLink
|
<CommunityLink
|
||||||
@@ -174,14 +196,14 @@
|
|||||||
avatar={!showCommunity}
|
avatar={!showCommunity}
|
||||||
class="flex-shrink "
|
class="flex-shrink "
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="badges">
|
{#snippet extraBadges()}
|
||||||
{#if badges.moderator}
|
{#if badges.moderator}
|
||||||
<ShieldIcon filled width={14} class="text-green-500" />
|
<ShieldIcon filled width={14} class="text-green-500" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if badges.admin}
|
{#if badges.admin}
|
||||||
<ShieldIcon filled width={14} class="text-red-500" />
|
<ShieldIcon filled width={14} class="text-red-500" />
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
</UserLink>
|
</UserLink>
|
||||||
</address>
|
</address>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -213,13 +235,13 @@
|
|||||||
style={tag.color ? `--tag-color: ${tag.color};` : ''}
|
style={tag.color ? `--tag-color: ${tag.color};` : ''}
|
||||||
>
|
>
|
||||||
<Badge class={tag.color ? 'badge-tag-color' : ''}>
|
<Badge class={tag.color ? 'badge-tag-color' : ''}>
|
||||||
<svelte:fragment slot="icon">
|
{#snippet icon()}
|
||||||
{#if tag.icon}
|
{#if tag.icon}
|
||||||
<Icon src={tag.icon} micro size="14" />
|
<Icon src={tag.icon} micro size="14" />
|
||||||
{:else}
|
{:else}
|
||||||
<Icon src={Tag} micro size="14" />
|
<Icon src={Tag} micro size="14" />
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
{tag.content}
|
{tag.content}
|
||||||
</Badge>
|
</Badge>
|
||||||
</a>
|
</a>
|
||||||
@@ -227,7 +249,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#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" />
|
{#snippet icon()}
|
||||||
|
<Icon src={ExclamationTriangle} size="14" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.badges.nsfw')}
|
{$t('post.badges.nsfw')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -237,7 +261,9 @@
|
|||||||
color="yellow-subtle"
|
color="yellow-subtle"
|
||||||
allowIconOnly
|
allowIconOnly
|
||||||
>
|
>
|
||||||
<Icon src={Bookmark} micro size="14" slot="icon" />
|
{#snippet icon()}
|
||||||
|
<Icon src={Bookmark} micro size="14" />
|
||||||
|
{/snippet}
|
||||||
{$t('post.badges.saved')}
|
{$t('post.badges.saved')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -247,19 +273,25 @@
|
|||||||
color="yellow-subtle"
|
color="yellow-subtle"
|
||||||
allowIconOnly
|
allowIconOnly
|
||||||
>
|
>
|
||||||
<Icon src={LockClosed} micro size="14" slot="icon" />
|
{#snippet icon()}
|
||||||
|
<Icon src={LockClosed} micro size="14" />
|
||||||
|
{/snippet}
|
||||||
<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" />
|
{#snippet icon()}
|
||||||
|
<Icon src={Trash} micro size="14" />
|
||||||
|
{/snippet}
|
||||||
<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" />
|
{#snippet icon()}
|
||||||
|
<Icon src={Trash} micro size="14" />
|
||||||
|
{/snippet}
|
||||||
<span class="max-md:hidden">{$t('post.badges.deleted')}</span>
|
<span class="max-md:hidden">{$t('post.badges.deleted')}</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -269,11 +301,13 @@
|
|||||||
color="green-subtle"
|
color="green-subtle"
|
||||||
allowIconOnly
|
allowIconOnly
|
||||||
>
|
>
|
||||||
<Icon src={Megaphone} micro size="14" slot="icon" />
|
{#snippet icon()}
|
||||||
|
<Icon src={Megaphone} micro size="14" />
|
||||||
|
{/snippet}
|
||||||
<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" />
|
{@render extraBadges?.()}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
export const voteColor = (vote: number, border: boolean = false) =>
|
export const voteColor = (vote: number, border: boolean = false) =>
|
||||||
vote == 1
|
vote == 1
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
export const shouldShowVoteColor = (
|
export const shouldShowVoteColor = (
|
||||||
vote: number,
|
vote: number,
|
||||||
type: 'upvotes' | 'downvotes'
|
type: 'upvotes' | 'downvotes',
|
||||||
): string =>
|
): string =>
|
||||||
(vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes')
|
(vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes')
|
||||||
? voteColor(vote)
|
? voteColor(vote)
|
||||||
@@ -29,15 +29,27 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
export let post: Post
|
interface Props {
|
||||||
export let vote: number = 0
|
post: Post
|
||||||
export let score: number
|
vote?: number
|
||||||
export let upvotes: number = 0
|
score: number
|
||||||
export let downvotes: number = 0
|
upvotes?: number
|
||||||
|
downvotes?: number
|
||||||
|
showCounts?: boolean
|
||||||
|
children?: import('svelte').Snippet<[any]>
|
||||||
|
}
|
||||||
|
|
||||||
export let showCounts: boolean = true
|
let {
|
||||||
|
post,
|
||||||
|
vote = $bindable(0),
|
||||||
|
score = $bindable(),
|
||||||
|
upvotes = $bindable(0),
|
||||||
|
downvotes = $bindable(0),
|
||||||
|
showCounts = true,
|
||||||
|
children,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
let loading = false
|
let loading = $state(false)
|
||||||
|
|
||||||
let oldScore = score
|
let oldScore = score
|
||||||
|
|
||||||
@@ -58,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot {vote} {score}>
|
{#if children}{@render children({ vote, score })}{:else}
|
||||||
<div
|
<div
|
||||||
class="{buttonColor.ghost} rounded-full h-full font-medium flex items-center *:p-2
|
class="{buttonColor.ghost} rounded-full h-full font-medium flex items-center *:p-2
|
||||||
hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0
|
hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0
|
||||||
@@ -70,7 +82,7 @@
|
|||||||
aria-label={$t('aria.vote.group')}
|
aria-label={$t('aria.vote.group')}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
onclick={() => castVote(vote == 1 ? 0 : 1)}
|
||||||
class="flex items-center gap-0.5 transition-colors relative z-0
|
class="flex items-center gap-0.5 transition-colors relative z-0
|
||||||
{vote == 1
|
{vote == 1
|
||||||
? shouldShowVoteColor(vote, 'upvotes')
|
? shouldShowVoteColor(vote, 'upvotes')
|
||||||
@@ -96,7 +108,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{#if $site?.site_view.local_site.enable_downvotes ?? true}
|
{#if $site?.site_view.local_site.enable_downvotes ?? true}
|
||||||
<button
|
<button
|
||||||
on:click={() => castVote(vote == -1 ? 0 : -1)}
|
onclick={() => castVote(vote == -1 ? 0 : -1)}
|
||||||
class="flex items-center flex-row-reverse gap-0.5 transition-colors
|
class="flex items-center flex-row-reverse gap-0.5 transition-colors
|
||||||
{vote == -1
|
{vote == -1
|
||||||
? shouldShowVoteColor(vote, 'downvotes')
|
? shouldShowVoteColor(vote, 'downvotes')
|
||||||
@@ -122,4 +134,4 @@
|
|||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
{/if}
|
||||||
@@ -9,14 +9,26 @@
|
|||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
import { combineCrossposts } from './crosspost'
|
import { combineCrossposts } from './crosspost'
|
||||||
|
|
||||||
export let posts: PostView[]
|
interface Props {
|
||||||
export let community: boolean = false
|
posts: PostView[]
|
||||||
export let feedData: any
|
community?: boolean
|
||||||
let etc = $$restProps
|
feedData: any
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
$: combinedPosts = combineCrossposts(posts)
|
let {
|
||||||
|
posts = $bindable(),
|
||||||
|
community = false,
|
||||||
|
feedData,
|
||||||
|
children,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
let etc = rest
|
||||||
|
|
||||||
let viewPost: number = -1
|
let combinedPosts = $derived(combineCrossposts(posts))
|
||||||
|
|
||||||
|
let viewPost: number = $state(-1)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
@@ -32,7 +44,9 @@
|
|||||||
description="There are no posts that match this filter."
|
description="There are no posts that match this filter."
|
||||||
>
|
>
|
||||||
<Button href="/communities">
|
<Button href="/communities">
|
||||||
<Icon src={Plus} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Plus} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
<span>Follow some communities</span>
|
<span>Follow some communities</span>
|
||||||
</Button>
|
</Button>
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
@@ -53,10 +67,10 @@
|
|||||||
posts = posts.toSpliced(index, 1)
|
posts = posts.toSpliced(index, 1)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="badges">
|
{#snippet badges()}
|
||||||
{#if post.withCrossposts}
|
{#if post.withCrossposts}
|
||||||
<button
|
<button
|
||||||
on:click={() => {
|
onclick={() => {
|
||||||
if (viewPost == post.post.id) viewPost = -1
|
if (viewPost == post.post.id) viewPost = -1
|
||||||
else viewPost = post.post.id
|
else viewPost = post.post.id
|
||||||
}}
|
}}
|
||||||
@@ -76,7 +90,7 @@
|
|||||||
: 's'}
|
: 's'}
|
||||||
</Badge>
|
</Badge>
|
||||||
</button>{/if}
|
</button>{/if}
|
||||||
</svelte:fragment>
|
{/snippet}
|
||||||
</Post>
|
</Post>
|
||||||
{#if post.withCrossposts && viewPost == post.post.id}
|
{#if post.withCrossposts && viewPost == post.post.id}
|
||||||
<div
|
<div
|
||||||
@@ -104,5 +118,5 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
@@ -20,7 +22,7 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
|
import { onMount, tick, type SvelteComponent } from 'svelte'
|
||||||
import {
|
import {
|
||||||
createVirtualizer,
|
createVirtualizer,
|
||||||
createWindowVirtualizer,
|
createWindowVirtualizer,
|
||||||
@@ -39,12 +41,28 @@
|
|||||||
import type { Readable } from 'svelte/motion'
|
import type { Readable } from 'svelte/motion'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
|
|
||||||
export let posts: PostView[]
|
let virtualItemEls: HTMLElement[] = $state([])
|
||||||
export let community: boolean = false
|
let virtualListEl: HTMLElement | undefined = $state(undefined)
|
||||||
export let feedId: PostFeedID
|
|
||||||
|
|
||||||
let virtualItemEls: HTMLElement[] = []
|
afterNavigate(() => {
|
||||||
let virtualListEl: HTMLElement | undefined = undefined
|
$virtualizer.scrollToIndex($postFeeds[feedId]?.lastSeen ?? 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
posts: PostView[]
|
||||||
|
community?: boolean
|
||||||
|
feedId: PostFeedID
|
||||||
|
feedData: PostFeed['data']
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
posts = $bindable(),
|
||||||
|
community = false,
|
||||||
|
feedId,
|
||||||
|
feedData = $bindable(),
|
||||||
|
children,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const virtualizer = createWindowVirtualizer({
|
const virtualizer = createWindowVirtualizer({
|
||||||
count: posts.length,
|
count: posts.length,
|
||||||
@@ -55,27 +73,9 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
$: items = $virtualizer.getVirtualItems()
|
let error: any = $state(undefined)
|
||||||
|
let loading = $state(false)
|
||||||
$: if (virtualItemEls.length) {
|
let hasMore = $state(true)
|
||||||
virtualItemEls.forEach($virtualizer.measureElement)
|
|
||||||
}
|
|
||||||
|
|
||||||
$: if (posts.length && virtualListEl)
|
|
||||||
$virtualizer.setOptions({
|
|
||||||
scrollMargin: virtualListEl?.offsetTop,
|
|
||||||
count: posts.length,
|
|
||||||
})
|
|
||||||
|
|
||||||
afterNavigate(() => {
|
|
||||||
$virtualizer.scrollToIndex($postFeeds[feedId]?.lastSeen ?? 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
export let feedData: PostFeed['data']
|
|
||||||
|
|
||||||
let error: any = undefined
|
|
||||||
let loading = false
|
|
||||||
let hasMore = true
|
|
||||||
|
|
||||||
async function loadMore() {
|
async function loadMore() {
|
||||||
if (!hasMore || loading) return
|
if (!hasMore || loading) return
|
||||||
@@ -181,6 +181,19 @@
|
|||||||
await tick()
|
await tick()
|
||||||
$virtualizer.measure()
|
$virtualizer.measure()
|
||||||
})
|
})
|
||||||
|
let items = $derived($virtualizer.getVirtualItems())
|
||||||
|
run(() => {
|
||||||
|
if (virtualItemEls.length) {
|
||||||
|
virtualItemEls.forEach($virtualizer.measureElement)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
run(() => {
|
||||||
|
if (posts.length && virtualListEl)
|
||||||
|
$virtualizer.setOptions({
|
||||||
|
scrollMargin: virtualListEl?.offsetTop,
|
||||||
|
count: posts.length,
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- <svelte:window on:keydown={handleKeydown} /> -->
|
<!-- <svelte:window on:keydown={handleKeydown} /> -->
|
||||||
@@ -198,7 +211,9 @@
|
|||||||
description="There are no posts that match this filter."
|
description="There are no posts that match this filter."
|
||||||
>
|
>
|
||||||
<Button href="/communities">
|
<Button href="/communities">
|
||||||
<Icon src={Plus} size="16" mini slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Plus} size="16" mini />
|
||||||
|
{/snippet}
|
||||||
<span>Follow some communities</span>
|
<span>Follow some communities</span>
|
||||||
</Button>
|
</Button>
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
@@ -284,16 +299,20 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
community_name: feedData.community_name ?? 'undefined',
|
community_name: feedData.community_name ?? 'undefined',
|
||||||
})}
|
})}
|
||||||
<Button slot="action" color="tertiary">
|
{#snippet action()}
|
||||||
<Icon src={ChevronDoubleUp} size="16" micro slot="prefix" />
|
<Button color="tertiary">
|
||||||
{$t('routes.post.scrollToTop')}
|
{#snippet prefix()}
|
||||||
</Button>
|
<Icon src={ChevronDoubleUp} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
|
{$t('routes.post.scrollToTop')}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
|
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { userSettings } from "$lib/settings"
|
import { userSettings } from '$lib/settings.svelte'
|
||||||
import type { PostView } from "lemmy-js-client"
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import { get } from "svelte/store"
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export type PostViewWithCrossposts = PostView & {
|
export type PostViewWithCrossposts = PostView & {
|
||||||
withCrossposts: true
|
withCrossposts: true
|
||||||
@@ -54,4 +54,4 @@ export const combineCrossposts = (
|
|||||||
})
|
})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
||||||
import { client, site } from '$lib/lemmy.js'
|
import { client, site } from '$lib/lemmy.js'
|
||||||
import type { Community, Post, PostView } from 'lemmy-js-client'
|
import type { Community, Post, PostView } from 'lemmy-js-client'
|
||||||
@@ -33,46 +35,56 @@
|
|||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import FreeTextInput from '$lib/components/input/FreeTextInput.svelte'
|
import FreeTextInput from '$lib/components/input/FreeTextInput.svelte'
|
||||||
|
|
||||||
export let edit = false
|
interface Props {
|
||||||
|
edit?: boolean
|
||||||
/**
|
/**
|
||||||
* The post to edit
|
* The post to edit
|
||||||
*/
|
*/
|
||||||
export let editingPost: Post | undefined = undefined
|
editingPost?: Post | undefined
|
||||||
|
passedCommunity?: Community | undefined
|
||||||
export let passedCommunity: Community | undefined = undefined
|
data?: {
|
||||||
|
community: Community | null
|
||||||
export let data: {
|
title: string
|
||||||
community: Community | null
|
body: string
|
||||||
title: string
|
image: FileList | null
|
||||||
body: string
|
thumbnail?: string
|
||||||
image: FileList | null
|
url?: string
|
||||||
thumbnail?: string
|
nsfw: boolean
|
||||||
url?: string
|
loading: boolean
|
||||||
nsfw: boolean
|
alt_text?: string
|
||||||
loading: boolean
|
language_id?: number
|
||||||
alt_text?: string
|
}
|
||||||
language_id?: number
|
formtitle?: import('svelte').Snippet
|
||||||
} = {
|
|
||||||
community: null,
|
|
||||||
title: '',
|
|
||||||
body: '',
|
|
||||||
image: null,
|
|
||||||
thumbnail: undefined,
|
|
||||||
url: undefined,
|
|
||||||
nsfw: false,
|
|
||||||
loading: false,
|
|
||||||
alt_text: undefined,
|
|
||||||
language_id: undefined,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
edit = false,
|
||||||
|
editingPost = undefined,
|
||||||
|
passedCommunity = undefined,
|
||||||
|
data = $bindable({
|
||||||
|
community: null,
|
||||||
|
title: '',
|
||||||
|
body: '',
|
||||||
|
image: null,
|
||||||
|
thumbnail: undefined,
|
||||||
|
url: undefined,
|
||||||
|
nsfw: false,
|
||||||
|
loading: false,
|
||||||
|
alt_text: undefined,
|
||||||
|
language_id: undefined,
|
||||||
|
}),
|
||||||
|
formtitle,
|
||||||
|
}: Props = $props()
|
||||||
// weird select menu language handling
|
// weird select menu language handling
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
$: if (data.language_id === '') data.language_id = undefined
|
run(() => {
|
||||||
|
if (data.language_id === '') data.language_id = undefined
|
||||||
|
})
|
||||||
|
|
||||||
let saveDraft = edit ? false : true
|
let saveDraft = edit ? false : true
|
||||||
let communitySearch = passedCommunity?.name ?? ''
|
let communitySearch = $state(passedCommunity?.name ?? '')
|
||||||
|
|
||||||
let communities: Community[] = []
|
let communities: Community[] = $state([])
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ submit: PostView }>()
|
const dispatcher = createEventDispatcher<{ submit: PostView }>()
|
||||||
|
|
||||||
@@ -179,7 +191,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let uploadingImage = false
|
let uploadingImage = $state(false)
|
||||||
|
|
||||||
const generateTitle = async (url: string | undefined) => {
|
const generateTitle = async (url: string | undefined) => {
|
||||||
if (!url) return
|
if (!url) return
|
||||||
@@ -224,15 +236,17 @@
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
let generation = {
|
let generation = $state({
|
||||||
loading: false,
|
loading: false,
|
||||||
generatable: false,
|
generatable: false,
|
||||||
title: '',
|
title: '',
|
||||||
}
|
})
|
||||||
|
|
||||||
let addAltText = false
|
let addAltText = $state(false)
|
||||||
|
|
||||||
$: generation.generatable = canGenerateTitle(data.url)
|
run(() => {
|
||||||
|
generation.generatable = canGenerateTitle(data.url)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if uploadingImage}
|
{#if uploadingImage}
|
||||||
@@ -248,12 +262,12 @@
|
|||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
|
<form onsubmit={preventDefault(submit)} class="flex flex-col gap-4 h-full">
|
||||||
<slot name="formtitle">
|
{#if formtitle}{@render formtitle()}{:else}
|
||||||
<Header class="font-bold text-xl">
|
<Header class="font-bold text-xl">
|
||||||
{edit ? $t('form.post.edit') : $t('form.post.create')}
|
{edit ? $t('form.post.edit') : $t('form.post.create')}
|
||||||
</Header>
|
</Header>
|
||||||
</slot>
|
{/if}
|
||||||
<ErrorContainer scope="post-form" />
|
<ErrorContainer scope="post-form" />
|
||||||
{#if !edit && data}
|
{#if !edit && data}
|
||||||
{#if !data.community}
|
{#if !data.community}
|
||||||
@@ -285,12 +299,13 @@
|
|||||||
alignment="left"
|
alignment="left"
|
||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
<Avatar
|
{#snippet prefix()}
|
||||||
url={data.community.icon}
|
<Avatar
|
||||||
alt={data.community.name}
|
url={data.community.icon}
|
||||||
width={24}
|
alt={data.community.name}
|
||||||
slot="prefix"
|
width={24}
|
||||||
/>
|
/>
|
||||||
|
{/snippet}
|
||||||
<div class="flex flex-col gap-0">
|
<div class="flex flex-col gap-0">
|
||||||
<span class="text-xs">{data.community.name}</span>
|
<span class="text-xs">{data.community.name}</span>
|
||||||
<span class="text-[10px] leading-3">
|
<span class="text-[10px] leading-3">
|
||||||
@@ -326,7 +341,9 @@
|
|||||||
<div
|
<div
|
||||||
class="border border-slate-100 rounded-xl h-6 w-6 grid place-items-center"
|
class="border border-slate-100 rounded-xl h-6 w-6 grid place-items-center"
|
||||||
>
|
>
|
||||||
<Icon src={Plus} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Plus} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
</div>
|
</div>
|
||||||
{#if data.url}
|
{#if data.url}
|
||||||
<Button
|
<Button
|
||||||
@@ -336,12 +353,9 @@
|
|||||||
color="ghost"
|
color="ghost"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
>
|
>
|
||||||
<Icon
|
{#snippet prefix()}
|
||||||
src={ChatBubbleBottomCenterText}
|
<Icon src={ChatBubbleBottomCenterText} size="15" micro />
|
||||||
size="15"
|
{/snippet}{$t('form.post.altText')}
|
||||||
micro
|
|
||||||
slot="prefix"
|
|
||||||
/>{$t('form.post.altText')}
|
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
@@ -351,7 +365,9 @@
|
|||||||
color="ghost"
|
color="ghost"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
>
|
>
|
||||||
<Icon src={Photo} size="15" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Photo} size="15" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('form.post.uploadImage')}
|
{$t('form.post.uploadImage')}
|
||||||
</Button>
|
</Button>
|
||||||
{#if generation.generatable}
|
{#if generation.generatable}
|
||||||
@@ -363,7 +379,9 @@
|
|||||||
color="ghost"
|
color="ghost"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
>
|
>
|
||||||
<Icon src={Sparkles} size="15" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Sparkles} size="15" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('form.post.generateTitle')}
|
{$t('form.post.generateTitle')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -433,7 +451,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<div class="mt-auto" />
|
<div class="mt-auto"></div>
|
||||||
<div class="flex flex-row items-center gap-2 w-full">
|
<div class="flex flex-row items-center gap-2 w-full">
|
||||||
<Button
|
<Button
|
||||||
submit
|
submit
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { client, getInstance } from '$lib/lemmy.js'
|
import { client, getInstance } from '$lib/lemmy.js'
|
||||||
import type { View } from '$lib/settings'
|
import type { View } from '$lib/settings.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image'
|
import { isImage, isVideo } from '$lib/ui/image'
|
||||||
import { canParseUrl, findClosestNumber } from '$lib/util'
|
import { canParseUrl, findClosestNumber } from '$lib/util'
|
||||||
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
||||||
@@ -10,7 +10,7 @@ export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
|||||||
export const bestImageURL = (
|
export const bestImageURL = (
|
||||||
post: Post,
|
post: Post,
|
||||||
compact: boolean = true,
|
compact: boolean = true,
|
||||||
width: number = 1024
|
width: number = 1024,
|
||||||
) => {
|
) => {
|
||||||
if (post.thumbnail_url) return optimizeImageURL(post.thumbnail_url, width)
|
if (post.thumbnail_url) return optimizeImageURL(post.thumbnail_url, width)
|
||||||
else if (post.url) return optimizeImageURL(post.url, width)
|
else if (post.url) return optimizeImageURL(post.url, width)
|
||||||
@@ -20,7 +20,7 @@ export const bestImageURL = (
|
|||||||
|
|
||||||
export const optimizeImageURL = (
|
export const optimizeImageURL = (
|
||||||
urlStr: string,
|
urlStr: string,
|
||||||
width: number = 1024
|
width: number = 1024,
|
||||||
): string => {
|
): string => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(urlStr)
|
const url = new URL(urlStr)
|
||||||
@@ -32,8 +32,8 @@ export const optimizeImageURL = (
|
|||||||
'thumbnail',
|
'thumbnail',
|
||||||
findClosestNumber(
|
findClosestNumber(
|
||||||
[128, 196, 256, 512, 728, 1024, 1536],
|
[128, 196, 256, 512, 728, 1024, 1536],
|
||||||
width
|
width,
|
||||||
).toString()
|
).toString(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ export const iframeType = (url: string): IframeType => {
|
|||||||
export async function hidePost(
|
export async function hidePost(
|
||||||
id: number,
|
id: number,
|
||||||
hide: boolean,
|
hide: boolean,
|
||||||
jwt: string
|
jwt: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const res = await client({ auth: jwt }).hidePost({
|
const res = await client({ auth: jwt }).hidePost({
|
||||||
hide: hide,
|
hide: hide,
|
||||||
|
|||||||
@@ -12,14 +12,25 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import type { View } from '$lib/settings'
|
import type { View } from '$lib/settings'
|
||||||
|
|
||||||
export let url: string
|
interface Props {
|
||||||
export let thumbnail_url: string | undefined = undefined
|
url: string
|
||||||
export let nsfw: boolean = false
|
thumbnail_url?: string | undefined
|
||||||
export let embed_title: string | undefined = undefined
|
nsfw?: boolean
|
||||||
export let embed_description: string | undefined = undefined
|
embed_title?: string | undefined
|
||||||
export let view: View = 'cozy'
|
embed_description?: string | undefined
|
||||||
|
view?: View
|
||||||
|
}
|
||||||
|
|
||||||
$: richURL = parseURL(url)
|
let {
|
||||||
|
url,
|
||||||
|
thumbnail_url = undefined,
|
||||||
|
nsfw = false,
|
||||||
|
embed_title = undefined,
|
||||||
|
embed_description = undefined,
|
||||||
|
view = 'cozy',
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let richURL = $derived(parseURL(url))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -105,37 +116,39 @@
|
|||||||
rounded-full flex p-1 relative -top-7 min-[384px]:mx-3 mt-8 min-[384px]:mt-0 mx-auto -mb-7 w-max max-w-full overflow-auto"
|
rounded-full flex p-1 relative -top-7 min-[384px]:mx-3 mt-8 min-[384px]:mt-0 mx-auto -mb-7 w-max max-w-full overflow-auto"
|
||||||
>
|
>
|
||||||
<PostLinkSources {url}>
|
<PostLinkSources {url}>
|
||||||
<Button
|
{#snippet target()}
|
||||||
color="tertiary"
|
<Button
|
||||||
slot="target"
|
color="tertiary"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="w-max text-slate-600 dark:text-zinc-400 block
|
class="w-max text-slate-600 dark:text-zinc-400 block
|
||||||
text-xs flex-shrink-0"
|
text-xs flex-shrink-0"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
>
|
>
|
||||||
<Icon src={LinkIcon} size="16" micro class="flex-shrink-0" />
|
<Icon src={LinkIcon} size="16" micro class="flex-shrink-0" />
|
||||||
{$t('post.actions.link.actions')}
|
{$t('post.actions.link.actions')}
|
||||||
</Button>
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</PostLinkSources>
|
</PostLinkSources>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex space-x-1">
|
<div class="flex space-x-1">
|
||||||
<PostLinkSources {url}>
|
<PostLinkSources {url}>
|
||||||
<Button
|
{#snippet target()}
|
||||||
color="ghost"
|
<Button
|
||||||
slot="target"
|
color="ghost"
|
||||||
size="xs"
|
size="xs"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
class="p-0.5 px-1 w-max mt-auto text-slate-600 dark:text-zinc-400 block
|
class="p-0.5 px-1 w-max mt-auto text-slate-600 dark:text-zinc-400 block
|
||||||
text-xs"
|
text-xs"
|
||||||
>
|
>
|
||||||
<div class="mr-0.5" style="width: 8px;">
|
<div class="mr-0.5" style="width: 8px;">
|
||||||
<Icon src={LinkIcon} size="16" micro />
|
<Icon src={LinkIcon} size="16" micro />
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-1" style="width: 8px;">
|
<div class="mr-1" style="width: 8px;">
|
||||||
<Icon src={ChevronDown} size="16" micro />
|
<Icon src={ChevronDown} size="16" micro />
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</PostLinkSources>
|
</PostLinkSources>
|
||||||
<Button
|
<Button
|
||||||
href={url}
|
href={url}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
const sources: {
|
const sources: {
|
||||||
getLink: (url: string) => string
|
getLink: (url: string) => string
|
||||||
name: string
|
name: string
|
||||||
@@ -43,12 +43,20 @@
|
|||||||
import type { MediaType } from '../helpers'
|
import type { MediaType } from '../helpers'
|
||||||
import { Icon, Share } from 'svelte-hero-icons'
|
import { Icon, Share } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let url: string
|
interface Props {
|
||||||
export let type: MediaType = 'embed'
|
url: string
|
||||||
|
type?: MediaType
|
||||||
|
target?: import('svelte').Snippet
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let { url, type = 'embed', target, ...rest }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu {...$$restProps}>
|
<Menu {...rest}>
|
||||||
<slot name="target" slot="target" />
|
{#snippet target()}
|
||||||
|
{@render target?.()}
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
<MenuDivider>{$t('post.actions.link.title')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.link.title')}</MenuDivider>
|
||||||
{#each sources as source}
|
{#each sources as source}
|
||||||
@@ -66,7 +74,9 @@
|
|||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Share} size="16" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Share} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
const youtubeDomain = (place: 'youtube' | 'invidious' | 'piped') => {
|
const youtubeDomain = (place: 'youtube' | 'invidious' | 'piped') => {
|
||||||
switch (place) {
|
switch (place) {
|
||||||
case 'youtube': {
|
case 'youtube': {
|
||||||
@@ -37,12 +37,6 @@
|
|||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export let type: IframeType = 'none'
|
|
||||||
export let thumbnail: string | undefined = undefined
|
|
||||||
export let url: string
|
|
||||||
export let opened = !$userSettings.embeds.clickToView
|
|
||||||
export let autoplay: boolean = $userSettings.embeds.clickToView
|
|
||||||
|
|
||||||
const urlToEmbed = (inputUrl: string) => {
|
const urlToEmbed = (inputUrl: string) => {
|
||||||
if (type == 'video') {
|
if (type == 'video') {
|
||||||
return inputUrl
|
return inputUrl
|
||||||
@@ -56,7 +50,7 @@
|
|||||||
if (autoplay) url.searchParams.set('autoplay', '1')
|
if (autoplay) url.searchParams.set('autoplay', '1')
|
||||||
|
|
||||||
return `https://${youtubeDomain(
|
return `https://${youtubeDomain(
|
||||||
$userSettings.embeds.youtube
|
$userSettings.embeds.youtube,
|
||||||
)}/embed/${videoID}?${url.searchParams.toString()}`
|
)}/embed/${videoID}?${url.searchParams.toString()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const typeData = (
|
const typeData = (
|
||||||
type: IframeType
|
type: IframeType,
|
||||||
): {
|
): {
|
||||||
icon: IconSource
|
icon: IconSource
|
||||||
text: string
|
text: string
|
||||||
@@ -91,11 +85,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: data = typeData(type)
|
interface Props {
|
||||||
$: embedUrl = urlToEmbed(url)
|
type?: IframeType
|
||||||
|
thumbnail?: string | undefined
|
||||||
|
url: string
|
||||||
|
opened?: any
|
||||||
|
autoplay?: boolean
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
let clazz: string = ''
|
let {
|
||||||
export { clazz as class }
|
type = 'none',
|
||||||
|
thumbnail = undefined,
|
||||||
|
url,
|
||||||
|
opened = $bindable(!$userSettings.embeds.clickToView),
|
||||||
|
autoplay = $userSettings.embeds.clickToView,
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let data = $derived(typeData(type))
|
||||||
|
let embedUrl = $derived(urlToEmbed(url))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -104,7 +113,7 @@
|
|||||||
-->
|
-->
|
||||||
{#if opened}
|
{#if opened}
|
||||||
{#if type == 'video'}
|
{#if type == 'video'}
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
<!-- svelte-ignore a11y_media_has_caption -->
|
||||||
<video {autoplay} controls class="rounded-xl aspect-video {clazz}">
|
<video {autoplay} controls class="rounded-xl aspect-video {clazz}">
|
||||||
<source src={url} />
|
<source src={url} />
|
||||||
</video>
|
</video>
|
||||||
@@ -116,11 +125,11 @@
|
|||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||||
allowfullscreen
|
allowfullscreen
|
||||||
class="aspect-video rounded-xl dark:bg-zinc-900 {clazz ?? ''}"
|
class="aspect-video rounded-xl dark:bg-zinc-900 {clazz ?? ''}"
|
||||||
/>
|
></iframe>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
on:click={() => (opened = true)}
|
onclick={() => (opened = true)}
|
||||||
class="aspect-video w-full h-full z-0 overflow-hidden relative rounded-xl flex flex-col gap-2 items-center justify-center text-white"
|
class="aspect-video w-full h-full z-0 overflow-hidden relative rounded-xl flex flex-col gap-2 items-center justify-center text-white"
|
||||||
>
|
>
|
||||||
{#if thumbnail}
|
{#if thumbnail}
|
||||||
@@ -132,7 +141,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
class="absolute blur-3xl -z-10 top-0 left-0 w-full h-full bg-gradient-to-br from-green-800 via-blue-900 via-20% to-red-700"
|
class="absolute blur-3xl -z-10 top-0 left-0 w-full h-full bg-gradient-to-br from-green-800 via-blue-900 via-20% to-red-700"
|
||||||
/>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
<Icon src={data.icon} solid size="48" />
|
<Icon src={data.icon} solid size="48" />
|
||||||
<h1 class="font-bold text-xl">{data.text}</h1>
|
<h1 class="font-bold text-xl">{data.text}</h1>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { stopPropagation } from 'svelte/legacy'
|
||||||
|
|
||||||
import { userSettings, type View } from '$lib/settings'
|
import { userSettings, type View } from '$lib/settings'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { bestImageURL, postLink } from '../helpers'
|
import { bestImageURL, postLink } from '../helpers'
|
||||||
@@ -6,10 +8,14 @@
|
|||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
export let post: Post
|
interface Props {
|
||||||
export let blur: boolean = false
|
post: Post
|
||||||
|
blur?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
let imageLoaded: boolean | null = null
|
let { post, blur = false }: Props = $props()
|
||||||
|
|
||||||
|
let imageLoaded: boolean | null = $state(null)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
imageLoaded = false
|
imageLoaded = false
|
||||||
@@ -23,11 +29,11 @@
|
|||||||
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
|
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
|
||||||
data-sveltekit-preload-data="off"
|
data-sveltekit-preload-data="off"
|
||||||
aria-label={post.name}
|
aria-label={post.name}
|
||||||
on:click={() => showImage(bestImageURL(post, false, -1))}
|
onclick={() => showImage(bestImageURL(post, false, -1))}
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y_missing_attribute -->
|
||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
fetchpriority="auto"
|
fetchpriority="auto"
|
||||||
@@ -52,7 +58,7 @@
|
|||||||
srcset={bestImageURL(post, false, 1512)}
|
srcset={bestImageURL(post, false, 1512)}
|
||||||
media="(max-width: 1512px)"
|
media="(max-width: 1512px)"
|
||||||
/>
|
/>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y_missing_attribute -->
|
||||||
<img
|
<img
|
||||||
src={bestImageURL(post, false, -1)}
|
src={bestImageURL(post, false, -1)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
@@ -63,16 +69,16 @@
|
|||||||
height={300}
|
height={300}
|
||||||
class:blur-[64px]={blur}
|
class:blur-[64px]={blur}
|
||||||
alt={post.alt_text ?? ''}
|
alt={post.alt_text ?? ''}
|
||||||
on:load={() => (imageLoaded = true)}
|
onload={() => (imageLoaded = true)}
|
||||||
/>
|
/>
|
||||||
</picture>
|
</picture>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<div
|
<div
|
||||||
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
||||||
rounded-full ml-auto w-max m-2 p-0 gap-1
|
rounded-full ml-auto w-max m-2 p-0 gap-1
|
||||||
*:bg-white *:border *:border-slate-200 *:dark:border-zinc-800 *:dark:bg-zinc-900"
|
*:bg-white *:border *:border-slate-200 *:dark:border-zinc-800 *:dark:bg-zinc-900"
|
||||||
on:click|stopPropagation={() => {}}
|
onclick={stopPropagation(() => {})}
|
||||||
>
|
>
|
||||||
{#if post.alt_text}
|
{#if post.alt_text}
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -18,11 +18,21 @@
|
|||||||
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
||||||
import PostImage from './PostImage.svelte'
|
import PostImage from './PostImage.svelte'
|
||||||
|
|
||||||
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
interface Props {
|
||||||
export let post: Post
|
view?: 'card' | 'cozy' | 'list' | 'compact'
|
||||||
export let type: MediaType = 'none'
|
post: Post
|
||||||
export let opened: boolean | undefined = undefined
|
type?: MediaType
|
||||||
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
|
opened?: boolean | undefined
|
||||||
|
blur?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
view = 'cozy',
|
||||||
|
post,
|
||||||
|
type = 'none',
|
||||||
|
opened = undefined,
|
||||||
|
blur = post.nsfw && $userSettings.nsfwBlur,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -18,19 +18,28 @@
|
|||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let post: Post
|
|
||||||
export let type: MediaType = 'none'
|
|
||||||
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'
|
||||||
|
|
||||||
$: size = thumbnailSize(view)
|
interface Props {
|
||||||
|
post: Post
|
||||||
|
type?: MediaType
|
||||||
|
view?: View
|
||||||
|
blur?: boolean
|
||||||
|
style?: string
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let style: string = ''
|
let {
|
||||||
let clazz: string = ''
|
post,
|
||||||
export { clazz as class }
|
type = 'none',
|
||||||
|
view = 'cozy',
|
||||||
|
blur = post.nsfw && $userSettings.nsfwBlur,
|
||||||
|
style = '',
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let size = $derived(thumbnailSize(view))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -43,15 +52,16 @@
|
|||||||
openOnHover
|
openOnHover
|
||||||
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
||||||
>
|
>
|
||||||
<Material
|
{#snippet target()}
|
||||||
slot="target"
|
<Material
|
||||||
padding="none"
|
padding="none"
|
||||||
rounding="full"
|
rounding="full"
|
||||||
elevation="high"
|
elevation="high"
|
||||||
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
||||||
>
|
>
|
||||||
ALT
|
ALT
|
||||||
</Material>
|
</Material>
|
||||||
|
{/snippet}
|
||||||
<div class="max-w-sm">
|
<div class="max-w-sm">
|
||||||
{post.alt_text}
|
{post.alt_text}
|
||||||
</div>
|
</div>
|
||||||
@@ -60,7 +70,7 @@
|
|||||||
<svelte:element
|
<svelte:element
|
||||||
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||||
href={postLink(post)}
|
href={postLink(post)}
|
||||||
on:click={() => {
|
onclick={() => {
|
||||||
if (type == 'image') {
|
if (type == 'image') {
|
||||||
showImage(bestImageURL(post, false, -1))
|
showImage(bestImageURL(post, false, -1))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,21 @@
|
|||||||
import { Icon, XCircle } from 'svelte-hero-icons'
|
import { Icon, XCircle } from 'svelte-hero-icons'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
export let q: string = ''
|
interface Props {
|
||||||
|
q?: string
|
||||||
|
instance?: string | undefined
|
||||||
|
listing_type?: ListingType
|
||||||
|
showWhenEmpty?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
export let instance: string | undefined = undefined
|
let {
|
||||||
export let listing_type: ListingType = 'Subscribed'
|
q = $bindable(''),
|
||||||
export let showWhenEmpty: boolean = false
|
instance = undefined,
|
||||||
|
listing_type = 'Subscribed',
|
||||||
|
showWhenEmpty = false,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ select: Person | undefined }>()
|
const dispatcher = createEventDispatcher<{ select: Person | undefined }>()
|
||||||
</script>
|
</script>
|
||||||
@@ -32,31 +42,33 @@
|
|||||||
on:select
|
on:select
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{showWhenEmpty}
|
{showWhenEmpty}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
let:item
|
|
||||||
let:select
|
|
||||||
>
|
>
|
||||||
<div class="w-full h-full" slot="noresults">
|
{#snippet noresults()}
|
||||||
{#if showWhenEmpty}
|
<div class="w-full h-full">
|
||||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
{#if showWhenEmpty}
|
||||||
<Icon src={XCircle} size="16" mini />
|
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||||
|
<Icon src={XCircle} size="16" mini />
|
||||||
|
<div class="flex flex-col text-left">
|
||||||
|
<span>None</span>
|
||||||
|
</div>
|
||||||
|
</MenuButton>
|
||||||
|
{:else}
|
||||||
|
<span class="mx-auto my-auto">No results.</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet children({ item, select })}
|
||||||
|
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||||
|
<MenuButton on:click={() => select(item)}>
|
||||||
|
<Avatar url={item.avatar} alt={item.name} width={24} />
|
||||||
<div class="flex flex-col text-left">
|
<div class="flex flex-col text-left">
|
||||||
<span>None</span>
|
<span>{item.name}</span>
|
||||||
|
<span class="text-xs opacity-80">
|
||||||
|
{new URL(item.actor_id).hostname}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{:else}
|
</div>
|
||||||
<span class="mx-auto my-auto">No results.</span>
|
{/snippet}
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
|
||||||
<MenuButton on:click={() => select(item)}>
|
|
||||||
<Avatar url={item.avatar} alt={item.name} width={24} />
|
|
||||||
<div class="flex flex-col text-left">
|
|
||||||
<span>{item.name}</span>
|
|
||||||
<span class="text-xs opacity-80">
|
|
||||||
{new URL(item.actor_id).hostname}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</MenuButton>
|
|
||||||
</div>
|
|
||||||
</Search>
|
</Search>
|
||||||
@@ -11,12 +11,21 @@
|
|||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
|
||||||
export let user: PersonView
|
interface Props {
|
||||||
export let view: 'cozy' | 'compact' = 'compact'
|
user: PersonView
|
||||||
export let showCounts: boolean = true
|
view?: 'cozy' | 'compact'
|
||||||
|
showCounts?: boolean
|
||||||
|
class?: string
|
||||||
|
icon?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
let clazz: string = 'py-4 flex flex-col gap-4 text-sm max-w-full relative'
|
let {
|
||||||
export { clazz as class }
|
user,
|
||||||
|
view = 'compact',
|
||||||
|
showCounts = true,
|
||||||
|
class: clazz = 'py-4 flex flex-col gap-4 text-sm max-w-full relative',
|
||||||
|
icon,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={clazz}>
|
<div class={clazz}>
|
||||||
@@ -32,9 +41,9 @@
|
|||||||
? 'flex-col gap-2'
|
? 'flex-col gap-2'
|
||||||
: 'flex-row'} gap-2 items-center"
|
: 'flex-row'} gap-2 items-center"
|
||||||
>
|
>
|
||||||
<slot name="icon">
|
{#if icon}{@render icon()}{:else}
|
||||||
<Avatar url={user.person.avatar} width={32} alt={user.person.name} />
|
<Avatar url={user.person.avatar} width={32} alt={user.person.name} />
|
||||||
</slot>
|
{/if}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="font-medium text-base">
|
<div class="font-medium text-base">
|
||||||
{user.person.display_name ?? user.person.name}
|
{user.person.display_name ?? user.person.name}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public'
|
||||||
|
|
||||||
import type { IconSource } from 'svelte-hero-icons'
|
import type { IconSource } from 'svelte-hero-icons'
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
const badges = parseBadge()
|
const badges = parseBadge()
|
||||||
|
|
||||||
const getEnvBadge = (
|
const getEnvBadge = (
|
||||||
actor_id: string
|
actor_id: string,
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
classes: string
|
classes: string
|
||||||
@@ -54,21 +54,36 @@
|
|||||||
import type { Person } from 'lemmy-js-client'
|
import type { Person } from 'lemmy-js-client'
|
||||||
import { Icon, Language, NoSymbol } from 'svelte-hero-icons'
|
import { Icon, Language, NoSymbol } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let user: Person
|
interface Props {
|
||||||
export let avatar: boolean = false
|
user: Person
|
||||||
export let avatarSize: number = 24
|
avatar?: boolean
|
||||||
export let badges: boolean = true
|
avatarSize?: number
|
||||||
export let inComment: boolean = false
|
badges?: boolean
|
||||||
export let showInstance: boolean =
|
inComment?: boolean
|
||||||
$userSettings.showInstances.user ||
|
showInstance?: boolean
|
||||||
($userSettings.showInstances.comments && inComment)
|
displayName?: any
|
||||||
export let displayName = $userSettings.displayNames
|
instanceClass?: string
|
||||||
|
class?: string
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
extraBadges?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
$: envBadge = getEnvBadge(user.actor_id)
|
let {
|
||||||
|
user,
|
||||||
|
avatar = false,
|
||||||
|
avatarSize = 24,
|
||||||
|
badges = true,
|
||||||
|
inComment = false,
|
||||||
|
showInstance = $userSettings.showInstances.user ||
|
||||||
|
($userSettings.showInstances.comments && inComment),
|
||||||
|
displayName = $userSettings.displayNames,
|
||||||
|
instanceClass = '',
|
||||||
|
class: clazz = '',
|
||||||
|
children,
|
||||||
|
extraBadges,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
export let instanceClass: string = ''
|
let envBadge = $derived(getEnvBadge(user.actor_id))
|
||||||
let clazz: string = ''
|
|
||||||
export { clazz as class }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
@@ -76,7 +91,7 @@
|
|||||||
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<Avatar
|
<Avatar
|
||||||
url={user.avatar}
|
url={user.avatar}
|
||||||
@@ -125,7 +140,7 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<slot name="badges" />
|
{@render extraBadges?.()}
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { TextInput } from 'mono-svelte'
|
import { TextInput } from 'mono-svelte'
|
||||||
|
|
||||||
let query: string = ''
|
let query: string = $state('')
|
||||||
let loading = false
|
let loading = $state(false)
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
loading = true
|
loading = true
|
||||||
goto(`/search?q=${query}`).then(() => (loading = false))
|
goto(`/search?q=${query}`).then(() => (loading = false))
|
||||||
}
|
}
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
class?: string
|
||||||
|
children?: import('svelte').Snippet<[any]>
|
||||||
|
}
|
||||||
|
|
||||||
|
let { class: clazz = '', children }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form on:submit|preventDefault={search} class="w-full h-full {clazz}">
|
<form onsubmit={preventDefault(search)} class="w-full h-full {clazz}">
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
class="w-full h-full {clazz}"
|
class="w-full h-full {clazz}"
|
||||||
@@ -22,4 +28,4 @@
|
|||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<slot {search} {loading} />
|
{@render children?.({ search, loading })}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
import { marked } from 'marked'
|
import { marked } from 'marked'
|
||||||
import {
|
import {
|
||||||
MdCode,
|
MdCode,
|
||||||
@@ -88,20 +88,32 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
export let source: string = ''
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
export let inline: boolean = false
|
|
||||||
|
|
||||||
options.inline = inline
|
options.inline = inline
|
||||||
|
|
||||||
export let noStyle: boolean = false
|
interface Props {
|
||||||
|
source?: string
|
||||||
|
inline?: boolean
|
||||||
|
noStyle?: boolean
|
||||||
|
style?: string
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
$: tokens = marked.lexer(source)
|
let {
|
||||||
|
source = '',
|
||||||
|
inline = false,
|
||||||
|
noStyle = false,
|
||||||
|
style = '',
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
export let style: string = ''
|
let tokens
|
||||||
let clazz: string = ''
|
run(() => {
|
||||||
export { clazz as class }
|
tokens = marked.lexer(source)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
@@ -22,30 +24,21 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import ImageUploadModal from '../lemmy/modal/ImageUploadModal.svelte'
|
import ImageUploadModal from '../lemmy/modal/ImageUploadModal.svelte'
|
||||||
|
|
||||||
export let images: boolean = true
|
|
||||||
export let value: string = ''
|
|
||||||
export let label: string | undefined = undefined
|
|
||||||
export let previewButton: boolean = true
|
|
||||||
export let tools: boolean = true
|
|
||||||
export let disabled: boolean = false
|
|
||||||
export let rows: number = 2
|
|
||||||
|
|
||||||
export let beforePreview: (input: string) => string = (input) => input
|
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ confirm: string }>()
|
const dispatcher = createEventDispatcher<{ confirm: string }>()
|
||||||
|
|
||||||
let textArea: HTMLTextAreaElement
|
let textArea: HTMLTextAreaElement | undefined = $state()
|
||||||
|
|
||||||
function replaceTextAtIndices(
|
function replaceTextAtIndices(
|
||||||
str: string,
|
str: string,
|
||||||
startIndex: number,
|
startIndex: number,
|
||||||
endIndex: number,
|
endIndex: number,
|
||||||
replacement: string
|
replacement: string,
|
||||||
) {
|
) {
|
||||||
return str.substring(0, startIndex) + replacement + str.substring(endIndex)
|
return str.substring(0, startIndex) + replacement + str.substring(endIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapSelection(start: string, end: string) {
|
function wrapSelection(start: string, end: string) {
|
||||||
|
if (!textArea) return
|
||||||
const startPos = textArea.selectionStart
|
const startPos = textArea.selectionStart
|
||||||
const endPos = textArea.selectionEnd
|
const endPos = textArea.selectionEnd
|
||||||
|
|
||||||
@@ -56,7 +49,7 @@
|
|||||||
textArea.value,
|
textArea.value,
|
||||||
startPos,
|
startPos,
|
||||||
endPos,
|
endPos,
|
||||||
newText
|
newText,
|
||||||
)
|
)
|
||||||
|
|
||||||
textArea.focus()
|
textArea.focus()
|
||||||
@@ -66,10 +59,8 @@
|
|||||||
value = textArea.value
|
value = textArea.value
|
||||||
}
|
}
|
||||||
|
|
||||||
let uploadingImage = false
|
let uploadingImage = $state(false)
|
||||||
let image: any
|
let image: any = $state()
|
||||||
|
|
||||||
export let previewing = false
|
|
||||||
|
|
||||||
const shortcuts = {
|
const shortcuts = {
|
||||||
KeyB: () => wrapSelection('**', '**'),
|
KeyB: () => wrapSelection('**', '**'),
|
||||||
@@ -92,10 +83,41 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (!previewing && value) adjustHeight()
|
interface Props {
|
||||||
|
images?: boolean
|
||||||
|
value?: string
|
||||||
|
label?: string | undefined
|
||||||
|
previewButton?: boolean
|
||||||
|
tools?: boolean
|
||||||
|
disabled?: boolean
|
||||||
|
rows?: number
|
||||||
|
beforePreview?: (input: string) => string
|
||||||
|
previewing?: boolean
|
||||||
|
class?: string
|
||||||
|
customLabel?: import('svelte').Snippet
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
let clazz: string = ''
|
let {
|
||||||
export { clazz as class }
|
images = true,
|
||||||
|
value = $bindable(''),
|
||||||
|
label = undefined,
|
||||||
|
previewButton = true,
|
||||||
|
tools = true,
|
||||||
|
disabled = false,
|
||||||
|
rows = 2,
|
||||||
|
beforePreview = (input) => input,
|
||||||
|
previewing = $bindable(false),
|
||||||
|
class: clazz = '',
|
||||||
|
customLabel,
|
||||||
|
children,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
run(() => {
|
||||||
|
if (!previewing && value) adjustHeight()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if uploadingImage && images}
|
{#if uploadingImage && images}
|
||||||
@@ -111,12 +133,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{#if label || $$slots.label}
|
{#if label || customLabel}
|
||||||
<Label>
|
<Label>
|
||||||
{#if label}
|
{#if label}
|
||||||
{label}
|
{label}
|
||||||
{:else if $$slots.label}
|
{:else if customLabel}
|
||||||
<slot name="label" />
|
{@render customLabel?.()}
|
||||||
{/if}
|
{/if}
|
||||||
</Label>
|
</Label>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -264,7 +286,7 @@ overflow-hidden transition-colors {clazz}"
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{rows}
|
{rows}
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -279,7 +301,7 @@ overflow-hidden transition-colors {clazz}"
|
|||||||
optionNames={[$t('form.edit'), $t('form.preview')]}
|
optionNames={[$t('form.edit'), $t('form.preview')]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
import { Button, Material, toast } from 'mono-svelte'
|
import { Button, Material, toast } from 'mono-svelte'
|
||||||
import { Icon, ClipboardDocument } from 'svelte-hero-icons'
|
import { Icon, ClipboardDocument } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let raw: string
|
interface Props {
|
||||||
|
raw: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { raw }: Props = $props()
|
||||||
|
|
||||||
function parseCodeblock(src: string): {
|
function parseCodeblock(src: string): {
|
||||||
code: string
|
code: string
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: codeblock = parseCodeblock(raw)
|
let codeblock = $derived(parseCodeblock(raw))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Material
|
<Material
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let depth: number = 0
|
interface Props {
|
||||||
export let raw: string | undefined = undefined
|
depth?: number
|
||||||
|
raw?: string | undefined
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let { depth = 0, raw = undefined, children }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if depth === 1}
|
{#if depth === 1}
|
||||||
<h1 class="font-bold text-4xl"><slot></slot></h1>
|
<h1 class="font-bold text-4xl">{@render children?.()}</h1>
|
||||||
{:else if depth === 2}
|
{:else if depth === 2}
|
||||||
<h2 class="font-bold text-3xl"><slot></slot></h2>
|
<h2 class="font-bold text-3xl">{@render children?.()}</h2>
|
||||||
{:else if depth === 3}
|
{:else if depth === 3}
|
||||||
<h3 class="font-bold text-2xl"><slot></slot></h3>
|
<h3 class="font-bold text-2xl">{@render children?.()}</h3>
|
||||||
{:else if depth === 4}
|
{:else if depth === 4}
|
||||||
<h4 class="font-semibold text-xl"><slot></slot></h4>
|
<h4 class="font-semibold text-xl">{@render children?.()}</h4>
|
||||||
{:else if depth === 5}
|
{:else if depth === 5}
|
||||||
<h5 class="font-semibold text-lg"><slot></slot></h5>
|
<h5 class="font-semibold text-lg">{@render children?.()}</h5>
|
||||||
{:else if depth === 6}
|
{:else if depth === 6}
|
||||||
<h6 class="font-semibold text-base"><slot></slot></h6>
|
<h6 class="font-semibold text-base">{@render children?.()}</h6>
|
||||||
{:else}
|
{:else}
|
||||||
{raw}
|
{raw}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string
|
interface Props {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { text }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -7,11 +7,15 @@
|
|||||||
} from '$lib/components/lemmy/post/helpers'
|
} from '$lib/components/lemmy/post/helpers'
|
||||||
import PostIframe from '$lib/components/lemmy/post/media/PostIframe.svelte'
|
import PostIframe from '$lib/components/lemmy/post/media/PostIframe.svelte'
|
||||||
|
|
||||||
export let href: string
|
interface Props {
|
||||||
export let title: string | undefined = undefined
|
href: string
|
||||||
export let text: string = ''
|
title?: string | undefined
|
||||||
|
text?: string
|
||||||
|
}
|
||||||
|
|
||||||
$: type = mediaType(href, 'cozy')
|
let { href, title = undefined, text = '' }: Props = $props()
|
||||||
|
|
||||||
|
let type = $derived(mediaType(href, 'cozy'))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -29,7 +33,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
class="inline"
|
class="inline"
|
||||||
on:click={() => showImage(optimizeImageURL(href, -1), text)}
|
onclick={() => showImage(optimizeImageURL(href, -1), text)}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={optimizeImageURL(href, 1024)}
|
src={optimizeImageURL(href, 1024)}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { photonify } from './plugins'
|
import { photonify } from './plugins'
|
||||||
|
|
||||||
export let href = ''
|
interface Props {
|
||||||
export let title = undefined
|
href?: string
|
||||||
|
title?: any
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let { href = '', title = undefined, children }: Props = $props()
|
||||||
|
|
||||||
export const parseURL = (href: string) => {
|
export const parseURL = (href: string) => {
|
||||||
try {
|
try {
|
||||||
@@ -12,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: photonified = photonify(href)
|
let photonified = $derived(photonify(href))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
@@ -20,5 +25,5 @@
|
|||||||
{title}
|
{title}
|
||||||
class="hover:underline text-sky-600 dark:text-sky-500"
|
class="hover:underline text-sky-600 dark:text-sky-500"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</a>
|
</a>
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let ordered: boolean
|
interface Props {
|
||||||
export let start: number
|
ordered: boolean
|
||||||
|
start: number
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let { ordered, start, children }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if ordered}
|
{#if ordered}
|
||||||
@@ -8,12 +13,12 @@
|
|||||||
{start}
|
{start}
|
||||||
class="pl-5 list-decimal *:marker:font-medium *:marker:text-primary-900 *:marker:dark:text-primary-100"
|
class="pl-5 list-decimal *:marker:font-medium *:marker:text-primary-900 *:marker:dark:text-primary-100"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</ol>
|
</ol>
|
||||||
{:else}
|
{:else}
|
||||||
<ul
|
<ul
|
||||||
class="list-disc pl-4 *:marker:text-primary-900 *:marker:dark:text-primary-100"
|
class="list-disc pl-4 *:marker:text-primary-900 *:marker:dark:text-primary-100"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export let tokens
|
let { tokens, children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</li>
|
</li>
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
<script>
|
<script>
|
||||||
import { options } from '../Markdown.svelte'
|
import { options } from '../Markdown.svelte'
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p class="leading-[1.5] {options.inline ? '' : 'max-w'}">
|
<p class="leading-[1.5] {options.inline ? '' : 'max-w'}">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
<blockquote class="border-l-2 dark:border-zinc-700 border-slate-300 p-1 px-3">
|
<blockquote class="border-l-2 dark:border-zinc-700 border-slate-300 p-1 px-3">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
@@ -6,7 +6,11 @@
|
|||||||
import { Icon } from 'svelte-hero-icons'
|
import { Icon } from 'svelte-hero-icons'
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
|
||||||
export let raw: string
|
interface Props {
|
||||||
|
raw: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { raw }: Props = $props()
|
||||||
|
|
||||||
function extractTitle(text: string) {
|
function extractTitle(text: string) {
|
||||||
const spoilerRegex = /^::: ?spoiler (.+)\n([\s\S]+?)\n:::/gm
|
const spoilerRegex = /^::: ?spoiler (.+)\n([\s\S]+?)\n:::/gm
|
||||||
@@ -25,12 +29,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: data = extractTitle(raw)
|
let data = $derived(extractTitle(raw))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Expandable class="border-y border-slate-200 dark:border-zinc-800 py-2">
|
<Expandable class="border-y border-slate-200 dark:border-zinc-800 py-2">
|
||||||
<div slot="title" class="text-left">
|
{#snippet title()}
|
||||||
<SvelteMarkdown source={data.title} {renderers} {options} isInline />
|
<div class="text-left">
|
||||||
</div>
|
<SvelteMarkdown source={data.title} {renderers} {options} isInline />
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
<SvelteMarkdown source={data.content} {renderers} {options} />
|
<SvelteMarkdown source={data.content} {renderers} {options} />
|
||||||
</Expandable>
|
</Expandable>
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string
|
interface Props {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { text }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<sub>{text}</sub>
|
<sub>{text}</sub>
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string
|
interface Props {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let { text }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<sup>{text}</sup>
|
<sup>{text}</sup>
|
||||||
@@ -1 +1,11 @@
|
|||||||
<slot />
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{@render children?.()}
|
||||||
@@ -37,7 +37,7 @@ export const linkify = markedLinkifyIt(
|
|||||||
|
|
||||||
if (!self.re.community) {
|
if (!self.re.community) {
|
||||||
self.re.community = new RegExp(
|
self.re.community = new RegExp(
|
||||||
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i
|
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (self.re.community.test(tail)) {
|
if (self.re.community.test(tail)) {
|
||||||
@@ -63,7 +63,7 @@ export const linkify = markedLinkifyIt(
|
|||||||
|
|
||||||
if (!self.re.user) {
|
if (!self.re.user) {
|
||||||
self.re.user = new RegExp(
|
self.re.user = new RegExp(
|
||||||
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i
|
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (self.re.user.test(tail)) {
|
if (self.re.user.test(tail)) {
|
||||||
@@ -86,7 +86,7 @@ export const linkify = markedLinkifyIt(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
fuzzyEmail: false,
|
fuzzyEmail: false,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const regexes = {
|
const regexes = {
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
<table class="overflow-auto w-full table-fixed rounded-xl">
|
<table class="overflow-auto w-full table-fixed rounded-xl">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</table>
|
</table>
|
||||||
@@ -1 +1,11 @@
|
|||||||
<tbody><slot /></tbody>
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<tbody>{@render children?.()}</tbody>
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let header: boolean
|
interface Props {
|
||||||
export let align:
|
header: boolean
|
||||||
| 'left'
|
align?: 'left' | 'center' | 'right' | 'justify' | 'char' | null | undefined
|
||||||
| 'center'
|
children?: import('svelte').Snippet
|
||||||
| 'right'
|
}
|
||||||
| 'justify'
|
|
||||||
| 'char'
|
let { header, align = undefined, children }: Props = $props()
|
||||||
| null
|
|
||||||
| undefined = undefined
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if header}
|
{#if header}
|
||||||
@@ -15,13 +13,13 @@
|
|||||||
class="bg-slate-50 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 py-2 px-3"
|
class="bg-slate-50 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 py-2 px-3"
|
||||||
{align}
|
{align}
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</th>
|
</th>
|
||||||
{:else}
|
{:else}
|
||||||
<td
|
<td
|
||||||
class="bg-slate-25 dark:bg-zinc-950 border border-slate-200 dark:border-zinc-800 py-2 px-3"
|
class="bg-slate-25 dark:bg-zinc-950 border border-slate-200 dark:border-zinc-800 py-2 px-3"
|
||||||
{align}
|
{align}
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1 +1,11 @@
|
|||||||
<thead><slot /></thead>
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<thead>{@render children?.()}</thead>
|
||||||
@@ -1 +1,11 @@
|
|||||||
<tr><slot /></tr>
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<tr>{@render children?.()}</tr>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
|
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
|
||||||
import { text } from './translation'
|
import { text } from './translation'
|
||||||
import { locale, t } from '$lib/translations'
|
import { locale, t } from '$lib/translations'
|
||||||
@@ -10,16 +12,22 @@
|
|||||||
translatedText: string
|
translatedText: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export let open: boolean = false
|
interface Props {
|
||||||
|
open?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
let { open = $bindable(false) }: Props = $props()
|
||||||
let error = false
|
let error = false
|
||||||
|
|
||||||
const opened = () => translate($text)
|
const opened = () => translate($text)
|
||||||
|
|
||||||
$: if (open) opened()
|
run(() => {
|
||||||
|
if (open) opened()
|
||||||
|
})
|
||||||
|
|
||||||
let result: Promise<TranslateResponse> | undefined = undefined
|
let result: Promise<TranslateResponse> | undefined = $state(undefined)
|
||||||
let from = 'auto'
|
let from = $state('auto')
|
||||||
let to = $locale
|
let to = $state($locale)
|
||||||
|
|
||||||
async function translate(text: string) {
|
async function translate(text: string) {
|
||||||
const url = $userSettings.translator
|
const url = $userSettings.translator
|
||||||
@@ -53,9 +61,11 @@
|
|||||||
|
|
||||||
<Modal title={$t('post.actions.more.translate')} bind:open>
|
<Modal title={$t('post.actions.more.translate')} bind:open>
|
||||||
<TextArea bind:value={$text} rows={2}>
|
<TextArea bind:value={$text} rows={2}>
|
||||||
<Button on:click={() => translate($text)} slot="suffix" color="primary">
|
{#snippet suffix()}
|
||||||
{$t('post.actions.more.translate')}
|
<Button on:click={() => translate($text)} color="primary">
|
||||||
</Button>
|
{$t('post.actions.more.translate')}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
</TextArea>
|
</TextArea>
|
||||||
<div class="flex items-center gap-2 w-full">
|
<div class="flex items-center gap-2 w-full">
|
||||||
<Select bind:value={from} class="flex-1">
|
<Select bind:value={from} class="flex-1">
|
||||||
|
|||||||
@@ -5,17 +5,9 @@
|
|||||||
|
|
||||||
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
|
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
|
||||||
|
|
||||||
export let url: string | undefined
|
|
||||||
export let alt: string = ''
|
|
||||||
export let title: string = ''
|
|
||||||
export let circle: boolean = true
|
|
||||||
|
|
||||||
export let width: number
|
|
||||||
export let res: number | undefined = undefined
|
|
||||||
|
|
||||||
const optimizeUrl = (
|
const optimizeUrl = (
|
||||||
url: string | undefined,
|
url: string | undefined,
|
||||||
res: number
|
res: number,
|
||||||
): string | undefined => {
|
): string | undefined => {
|
||||||
if (url === undefined) return
|
if (url === undefined) return
|
||||||
|
|
||||||
@@ -25,7 +17,7 @@
|
|||||||
if (res > -1) {
|
if (res > -1) {
|
||||||
urlObj.searchParams.append(
|
urlObj.searchParams.append(
|
||||||
'thumbnail',
|
'thumbnail',
|
||||||
findClosestNumber(sizes, res).toString()
|
findClosestNumber(sizes, res).toString(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,17 +27,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: optimizedURLs = [2, 3, 6, -1].map((n) =>
|
interface Props {
|
||||||
optimizeUrl(url, (res || width) * n)
|
url: string | undefined
|
||||||
|
alt?: string
|
||||||
|
title?: string
|
||||||
|
circle?: boolean
|
||||||
|
width: number
|
||||||
|
res?: number | undefined
|
||||||
|
style?: string
|
||||||
|
class?: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
url,
|
||||||
|
alt = '',
|
||||||
|
title = '',
|
||||||
|
circle = true,
|
||||||
|
width,
|
||||||
|
res = undefined,
|
||||||
|
style = '',
|
||||||
|
class: clazz = '',
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
let optimizedURLs = $derived(
|
||||||
|
[2, 3, 6, -1].map((n) => optimizeUrl(url, (res || width) * n)),
|
||||||
)
|
)
|
||||||
export let style: string = ''
|
|
||||||
let clazz: string = ''
|
|
||||||
export { clazz as class }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if optimizedURLs[0] != undefined}
|
{#if optimizedURLs[0] != undefined}
|
||||||
<img
|
<img
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
srcset="{optimizedURLs[0]} 1x, {optimizedURLs[1]} 2x, {optimizedURLs[2]} 4x, {optimizedURLs[3]} 6x"
|
srcset="{optimizedURLs[0]} 1x, {optimizedURLs[1]} 2x, {optimizedURLs[2]} 4x, {optimizedURLs[3]} 6x"
|
||||||
src={optimizedURLs[0]}
|
src={optimizedURLs[0]}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
class?: string
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
action?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let { class: clazz = '', children, action }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -8,8 +13,8 @@
|
|||||||
text-sm text-slate-600 dark:text-zinc-400 gap-2 flex-wrap {clazz}"
|
text-sm text-slate-600 dark:text-zinc-400 gap-2 flex-wrap {clazz}"
|
||||||
>
|
>
|
||||||
<span class="font-medium text-left">
|
<span class="font-medium text-left">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</span>
|
</span>
|
||||||
<hr class="border-slate-200 flex-1 w-full dark:border-zinc-800" />
|
<hr class="border-slate-200 flex-1 w-full dark:border-zinc-800" />
|
||||||
<slot name="action" />
|
{@render action?.()}
|
||||||
</div>
|
</div>
|
||||||
@@ -1,15 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from './Avatar.svelte'
|
import Avatar from './Avatar.svelte'
|
||||||
|
|
||||||
export let name: string
|
interface Props {
|
||||||
export let label: string | undefined = undefined
|
name: string
|
||||||
export let icon: string | undefined = undefined
|
label?: string | undefined
|
||||||
|
icon?: string | undefined
|
||||||
|
customIcon?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
name,
|
||||||
|
label = undefined,
|
||||||
|
icon = undefined,
|
||||||
|
customIcon,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row gap-2 items-center">
|
<div class="flex flex-row gap-2 items-center">
|
||||||
<slot name="icon">
|
{#if customIcon}{@render customIcon()}{:else}
|
||||||
<Avatar url={icon} width={32} />
|
<Avatar url={icon} width={32} />
|
||||||
</slot>
|
{/if}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span class="font-semibold text-base">{name}</span>
|
<span class="font-semibold text-base">{name}</span>
|
||||||
<span class="text-sm">{label}</span>
|
<span class="text-sm">{label}</span>
|
||||||
|
|||||||
@@ -6,28 +6,46 @@
|
|||||||
import { optimizeImageURL } from '../lemmy/post/helpers'
|
import { optimizeImageURL } from '../lemmy/post/helpers'
|
||||||
import FormattedNumber from '../util/FormattedNumber.svelte'
|
import FormattedNumber from '../util/FormattedNumber.svelte'
|
||||||
|
|
||||||
export let avatar: string | undefined = undefined
|
interface Props {
|
||||||
export let name: string
|
avatar?: string | undefined
|
||||||
export let bio: string | undefined = undefined
|
|
||||||
export let banner: string | undefined = undefined
|
|
||||||
export let url: string | undefined = undefined
|
|
||||||
export let stats: {
|
|
||||||
name: string
|
name: string
|
||||||
value: string
|
bio?: string | undefined
|
||||||
format?: boolean
|
banner?: string | undefined
|
||||||
}[] = []
|
url?: string | undefined
|
||||||
|
stats?: {
|
||||||
|
name: string
|
||||||
|
value: string
|
||||||
|
format?: boolean
|
||||||
|
}[]
|
||||||
|
center?: boolean
|
||||||
|
class?: string
|
||||||
|
nameDetail?: import('svelte').Snippet
|
||||||
|
actions?: import('svelte').Snippet
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
export let center: boolean = false
|
let {
|
||||||
|
avatar = undefined,
|
||||||
let clazz: string = ''
|
name,
|
||||||
export { clazz as class }
|
bio = undefined,
|
||||||
|
banner = undefined,
|
||||||
|
url = undefined,
|
||||||
|
stats = [],
|
||||||
|
center = false,
|
||||||
|
class: clazz = '',
|
||||||
|
nameDetail,
|
||||||
|
actions,
|
||||||
|
children,
|
||||||
|
...rest
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Material
|
<Material
|
||||||
color="transparent"
|
color="transparent"
|
||||||
padding="none"
|
padding="none"
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
class="z-10 relative border-slate-200 dark:border-zinc-700 {clazz}"
|
class="z-10 relative border-slate-200 dark:border-zinc-700 {clazz}"
|
||||||
>
|
>
|
||||||
{#if banner || avatar}
|
{#if banner || avatar}
|
||||||
@@ -72,12 +90,12 @@
|
|||||||
<span
|
<span
|
||||||
class="flex items-center gap-0 text-sm text-slate-600 dark:text-zinc-400 max-w-full w-max"
|
class="flex items-center gap-0 text-sm text-slate-600 dark:text-zinc-400 max-w-full w-max"
|
||||||
>
|
>
|
||||||
<slot name="nameDetail" />
|
{@render nameDetail?.()}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{#if $$slots.actions}
|
{#if actions}
|
||||||
<div class="flex flex-col mt-2">
|
<div class="flex flex-col mt-2">
|
||||||
<slot name="actions" />
|
{@render actions?.()}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -118,7 +136,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
</Material>
|
</Material>
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,58 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Disclosure } from 'mono-svelte'
|
import { Disclosure } from 'mono-svelte'
|
||||||
import { Minus, Plus, Icon } from 'svelte-hero-icons'
|
import { Minus, Plus, Icon } from 'svelte-hero-icons'
|
||||||
export let open: boolean = false
|
interface Props {
|
||||||
export let icon: boolean = true
|
open?: boolean
|
||||||
let clazz: string = ''
|
icon?: boolean
|
||||||
export { clazz as class }
|
class?: string
|
||||||
|
title?: import('svelte').Snippet
|
||||||
|
extended?: import('svelte').Snippet
|
||||||
|
content?: import('svelte').Snippet
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
open = $bindable(false),
|
||||||
|
icon = true,
|
||||||
|
class: clazz = '',
|
||||||
|
title,
|
||||||
|
extended,
|
||||||
|
content,
|
||||||
|
children,
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Disclosure bind:open class="items-start justify-items-start gap-2 {clazz}">
|
<Disclosure bind:open class="items-start justify-items-start gap-2 {clazz}">
|
||||||
<div
|
{#snippet summary()}
|
||||||
slot="summary"
|
|
||||||
class="font-medium w-full text-left flex flex-row items-center justify-between hover:text-primary-900
|
|
||||||
hover:dark:text-primary-100 transition-colors h-full z-0 group relative"
|
|
||||||
>
|
|
||||||
<div class="flex flex-row gap-1 items-center w-full">
|
|
||||||
<slot name="title" />
|
|
||||||
</div>
|
|
||||||
{#if icon}
|
|
||||||
<Icon
|
|
||||||
src={open ? Minus : Plus}
|
|
||||||
size="16"
|
|
||||||
micro
|
|
||||||
class="{open
|
|
||||||
? ''
|
|
||||||
: 'rotate-90'} transition-transform duration-300 ease-out"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<div
|
<div
|
||||||
class="inset-0 -z-10 opacity-0 absolute bg-slate-100 dark:bg-zinc-900 rounded-full
|
class="font-medium w-full text-left flex flex-row items-center justify-between hover:text-primary-900
|
||||||
group-hover:opacity-100 group-hover:-inset-1 group-hover:-inset-x-2 transition-all"
|
hover:dark:text-primary-100 transition-colors h-full z-0 group relative"
|
||||||
/>
|
>
|
||||||
</div>
|
<div class="flex flex-row gap-1 items-center w-full">
|
||||||
<slot name="extended" slot="extended" />
|
{@render title?.()}
|
||||||
<slot name="content">
|
</div>
|
||||||
<div class="pt-2 text-slate-900 dark:text-zinc-100">
|
{#if icon}
|
||||||
<slot />
|
<Icon
|
||||||
|
src={open ? Minus : Plus}
|
||||||
|
size="16"
|
||||||
|
micro
|
||||||
|
class="{open
|
||||||
|
? ''
|
||||||
|
: 'rotate-90'} transition-transform duration-300 ease-out"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
<div
|
||||||
|
class="inset-0 -z-10 opacity-0 absolute bg-slate-100 dark:bg-zinc-900 rounded-full
|
||||||
|
group-hover:opacity-100 group-hover:-inset-1 group-hover:-inset-x-2 transition-all"
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
{/snippet}
|
||||||
|
{#snippet extended()}
|
||||||
|
{@render extended?.()}
|
||||||
|
{/snippet}
|
||||||
|
{#if content}{@render content()}{:else}
|
||||||
|
<div class="pt-2 text-slate-900 dark:text-zinc-100">
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" module>
|
||||||
import { pushState } from '$app/navigation'
|
import { pushState } from '$app/navigation'
|
||||||
|
|
||||||
export function showImage(url: string, alt: string = '') {
|
export function showImage(url: string, alt: string = '') {
|
||||||
@@ -24,13 +24,8 @@
|
|||||||
import { focusTrap } from 'svelte-focus-trap'
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
/**
|
let zoomed = $state(false)
|
||||||
* The full-resolution image URL
|
let sharing = $state(false)
|
||||||
*/
|
|
||||||
export let alt: string = ''
|
|
||||||
|
|
||||||
let zoomed = false
|
|
||||||
let sharing = false
|
|
||||||
|
|
||||||
async function downloadImage(url: string) {
|
async function downloadImage(url: string) {
|
||||||
sharing = true
|
sharing = true
|
||||||
@@ -43,21 +38,29 @@
|
|||||||
sharing = false
|
sharing = false
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
/**
|
||||||
|
* The full-resolution image URL
|
||||||
|
*/
|
||||||
|
alt?: string
|
||||||
|
class?: string
|
||||||
|
children?: import('svelte').Snippet
|
||||||
|
}
|
||||||
|
|
||||||
|
let { alt = '', class: clazz = '', children }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $page.state.openImage || '' != ''}
|
{#if $page.state.openImage || '' != ''}
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y-positive-tabindex -->
|
<!-- svelte-ignore a11y_positive_tabindex -->
|
||||||
<div
|
<div
|
||||||
class="fixed top-0 left-0 w-screen h-[100svh] overflow-auto bg-white/50 dark:bg-black/50
|
class="fixed top-0 left-0 w-screen h-[100svh] overflow-auto bg-white/50 dark:bg-black/50
|
||||||
flex flex-col z-[100] backdrop-blur-sm"
|
flex flex-col z-[100] backdrop-blur-sm"
|
||||||
transition:fade={{ duration: 150 }}
|
transition:fade={{ duration: 150 }}
|
||||||
on:click={() => history.back()}
|
onclick={() => history.back()}
|
||||||
on:keydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key == 'Escape') history.back()
|
if (e.key == 'Escape') history.back()
|
||||||
}}
|
}}
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
@@ -117,7 +120,9 @@
|
|||||||
title={$t('post.actions.more.share')}
|
title={$t('post.actions.more.share')}
|
||||||
loading={sharing}
|
loading={sharing}
|
||||||
>
|
>
|
||||||
<Icon src={Share} size="20" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={Share} size="20" micro />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
@@ -141,13 +146,15 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
title={$t('post.image.close')}
|
title={$t('post.image.close')}
|
||||||
>
|
>
|
||||||
<Icon src={XMark} size="20" micro slot="prefix" />
|
{#snippet prefix()}
|
||||||
|
<Icon src={XMark} size="20" micro />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
</Material>
|
</Material>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<button on:click={() => history.back()} class="contents {clazz}">
|
<button onclick={() => history.back()} class="contents {clazz}">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</button>
|
</button>
|
||||||
@@ -1,14 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormattedNumber from '../util/FormattedNumber.svelte'
|
import FormattedNumber from '../util/FormattedNumber.svelte'
|
||||||
|
|
||||||
export let label: string
|
interface Props {
|
||||||
export let content: string
|
label: string
|
||||||
export let formatted: boolean = false
|
content: string
|
||||||
|
formatted?: boolean
|
||||||
|
labelClass?: string
|
||||||
|
contentClass?: string
|
||||||
|
class?: string
|
||||||
|
}
|
||||||
|
|
||||||
export let labelClass: string = ''
|
let {
|
||||||
export let contentClass: string = ''
|
label,
|
||||||
let clazz: string = ''
|
content,
|
||||||
export { clazz as class }
|
formatted = false,
|
||||||
|
labelClass = '',
|
||||||
|
contentClass = '',
|
||||||
|
class: clazz = '',
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col {clazz}">
|
<div class="flex flex-col {clazz}">
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { userSettings } from '$lib/settings'
|
import { userSettings } from '$lib/settings'
|
||||||
|
|
||||||
export let width = 48
|
interface Props {
|
||||||
|
width?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
let { width = 48 }: Props = $props()
|
||||||
|
|
||||||
const monthColors: {
|
const monthColors: {
|
||||||
[x: number]: string
|
[x: number]: string
|
||||||
@@ -20,7 +24,7 @@
|
|||||||
12: '--hover-color-1: #228B22; --hover-color-2: #FFFFFF;',
|
12: '--hover-color-1: #228B22; --hover-color-2: #FFFFFF;',
|
||||||
}
|
}
|
||||||
|
|
||||||
$: monthColor = monthColors[new Date().getMonth() + 1]
|
let monthColor = $derived(monthColors[new Date().getMonth() + 1])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -12,9 +12,19 @@
|
|||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
export let page: number = 0
|
interface Props {
|
||||||
export let cursor: { next?: string; back?: string } | undefined = undefined
|
page?: number;
|
||||||
export let hasMore: boolean = true
|
cursor?: { next?: string; back?: string } | undefined;
|
||||||
|
hasMore?: boolean;
|
||||||
|
children?: import('svelte').Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
page = $bindable(0),
|
||||||
|
cursor = undefined,
|
||||||
|
hasMore = true,
|
||||||
|
children
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ change: number; cursor: string }>()
|
const dispatcher = createEventDispatcher<{ change: number; cursor: string }>()
|
||||||
</script>
|
</script>
|
||||||
@@ -23,9 +33,9 @@
|
|||||||
aria-label={$t('aria.pagination.nav')}
|
aria-label={$t('aria.pagination.nav')}
|
||||||
class="flex flex-row w-full gap-4 items-center justify-center"
|
class="flex flex-row w-full gap-4 items-center justify-center"
|
||||||
>
|
>
|
||||||
{#if $$slots.default}
|
{#if children}
|
||||||
<span class="text-sm text-slate-600 dark:text-zinc-400 font-medium">
|
<span class="text-sm text-slate-600 dark:text-zinc-400 font-medium">
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</span>
|
</span>
|
||||||
<hr class="border-slate-200 dark:border-zinc-800 flex-1" />
|
<hr class="border-slate-200 dark:border-zinc-800 flex-1" />
|
||||||
{/if}
|
{/if}
|
||||||
@@ -41,7 +51,9 @@
|
|||||||
class="text-inherit dark:text-inherit disabled:!opacity-20 disabled:!bg-transparent"
|
class="text-inherit dark:text-inherit disabled:!opacity-20 disabled:!bg-transparent"
|
||||||
disabled={(!cursor?.back && cursor?.next) || page <= 1}
|
disabled={(!cursor?.back && cursor?.next) || page <= 1}
|
||||||
>
|
>
|
||||||
<Icon src={ChevronLeft} size="24" mini slot="suffix" />
|
{#snippet suffix()}
|
||||||
|
<Icon src={ChevronLeft} size="24" mini />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{#if page}
|
{#if page}
|
||||||
@@ -71,6 +83,8 @@
|
|||||||
class="text-inherit dark:text-inherit"
|
class="text-inherit dark:text-inherit"
|
||||||
disabled={!hasMore}
|
disabled={!hasMore}
|
||||||
>
|
>
|
||||||
<Icon src={ChevronRight} size="24" mini slot="suffix" />
|
{#snippet suffix()}
|
||||||
|
<Icon src={ChevronRight} size="24" mini />
|
||||||
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,13 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let icon: IconSource | undefined = undefined
|
|
||||||
|
|
||||||
export let title: string
|
interface Props {
|
||||||
export let description: string | undefined = undefined
|
icon?: IconSource | undefined;
|
||||||
export let center: boolean = false
|
title: string;
|
||||||
let clazz: string = ''
|
description?: string | undefined;
|
||||||
export { clazz as class }
|
center?: boolean;
|
||||||
|
class?: string;
|
||||||
|
children?: import('svelte').Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
icon = undefined,
|
||||||
|
title,
|
||||||
|
description = undefined,
|
||||||
|
center = false,
|
||||||
|
class: clazz = '',
|
||||||
|
children
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -32,5 +44,5 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy';
|
||||||
|
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { tweened } from 'svelte/motion'
|
import { tweened } from 'svelte/motion'
|
||||||
|
|
||||||
export let progress: number = 0
|
interface Props {
|
||||||
|
progress?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { progress = 0 }: Props = $props();
|
||||||
|
|
||||||
let tween = tweened(progress, { easing: expoOut })
|
let tween = tweened(progress, { easing: expoOut })
|
||||||
|
|
||||||
$: tween.set(progress)
|
run(() => {
|
||||||
|
tween.set(progress)
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="bg-primary-900 dark:bg-primary-100 h-1 rounded-full"
|
class="bg-primary-900 dark:bg-primary-100 h-1 rounded-full"
|
||||||
style="width: {$tween * 100}%;"
|
style="width: {$tween * 100}%;"
|
||||||
/>
|
></div>
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let small: boolean = false
|
interface Props {
|
||||||
let clazz: string = ''
|
small?: boolean;
|
||||||
export { clazz as class }
|
class?: string;
|
||||||
|
children?: import('svelte').Snippet;
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
let { small = false, class: clazz = '', children, ...rest }: Props = $props();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
{...$$restProps}
|
{...rest}
|
||||||
class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}"
|
class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</span>
|
</span>
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let clazz: string = ''
|
interface Props {
|
||||||
export { clazz as class }
|
class?: string;
|
||||||
|
children?: import('svelte').Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { class: clazz = '', children }: Props = $props();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<aside
|
<aside
|
||||||
@@ -8,5 +13,5 @@
|
|||||||
flex-col gap-4 px-6 pt-4 max-w-full w-full h-full
|
flex-col gap-4 px-6 pt-4 max-w-full w-full h-full
|
||||||
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {clazz}"
|
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {clazz}"
|
||||||
>
|
>
|
||||||
<slot />
|
{@render children?.()}
|
||||||
</aside>
|
</aside>
|
||||||
Loaded 100 of 225 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user