14 files changed
+206
-33
No files matched your search
@@ -30,5 +30,6 @@
|
||||
class="w-full px-3 text-sm py-2.5 bg-white dark:bg-black
|
||||
border border-slate-300 dark:border-zinc-700 dark:focus:border-white
|
||||
focus:outline-none focus:border-black transition-colors rounded-md {clazz}"
|
||||
{...$$restProps}
|
||||
/>
|
||||
</label>
|
||||
@@ -17,7 +17,7 @@
|
||||
${value.length != 0 ? 'invalid:border-red-400' : ''}
|
||||
w-full px-3 text-sm py-2.5 bg-white dark:bg-zinc-950
|
||||
border border-slate-300 dark:border-zinc-700 dark:focus:border-white
|
||||
focus:outline-none focus:border-black transition-colors rounded-md
|
||||
focus:outline-none focus:border-black transition-colors rounded-md disabled:bg-slate-200 disabled:bg-zinc-800 disabled:opacity-70
|
||||
${$$props.class}
|
||||
`
|
||||
</script>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
export let node: CommentNodeI
|
||||
export let postId: number
|
||||
export let op: boolean = false
|
||||
export let actions: boolean = true
|
||||
|
||||
export let open = true
|
||||
export let replying = false
|
||||
@@ -71,7 +72,7 @@
|
||||
{/if}
|
||||
|
||||
<li
|
||||
class="py-2 {node.depth == 0
|
||||
class="py-2 pb-3 {node.depth == 0
|
||||
? 'border-b border-slate-200 dark:border-zinc-800'
|
||||
: ''}"
|
||||
id="#{node.comment_view.comment.id.toString()}"
|
||||
@@ -140,13 +141,15 @@
|
||||
<div class="max-w-full mt-0.5 break-words text-sm leading-[22px]">
|
||||
<Markdown source={node.comment_view.comment.content} />
|
||||
</div>
|
||||
<div class="flex flex-row gap-2 items-center h-[26px]">
|
||||
<CommentActions
|
||||
comment={node.comment_view}
|
||||
bind:replying
|
||||
on:edit={() => (editing = true)}
|
||||
/>
|
||||
</div>
|
||||
{#if actions}
|
||||
<div class="flex flex-row gap-2 items-center h-[26px]">
|
||||
<CommentActions
|
||||
comment={node.comment_view}
|
||||
bind:replying
|
||||
on:edit={() => (editing = true)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if replying}
|
||||
<div class="max-w-sm my-2">
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
BookmarkSlash,
|
||||
ChatBubbleOvalLeft,
|
||||
EllipsisHorizontal,
|
||||
Flag,
|
||||
Icon,
|
||||
PencilSquare,
|
||||
Trash,
|
||||
@@ -21,6 +22,7 @@
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { isCommentMutable } from '$lib/components/lemmy/post/helpers.js'
|
||||
import { report } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
|
||||
export let comment: CommentView
|
||||
export let replying: boolean = false
|
||||
@@ -114,6 +116,15 @@
|
||||
<span>Delete</span>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $authData && $user?.person.id != comment.creator.id}
|
||||
<MenuButton
|
||||
on:click={() => report(comment)}
|
||||
color={Color.dangerSecondary}
|
||||
>
|
||||
<Icon src={Flag} mini size="16" />
|
||||
<span>Report</span>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{/if}
|
||||
</Menu>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { modals } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ReportModal from './ReportModal.svelte'
|
||||
</script>
|
||||
|
||||
<ReportModal bind:open={$modals.reporting.open} item={$modals.reporting.item} />
|
||||
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import TextArea from '$lib/components/input/TextArea.svelte'
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
|
||||
export let open: boolean
|
||||
export let item: PostView | CommentView | undefined = undefined
|
||||
|
||||
const isComment = (item: PostView | CommentView): item is CommentView =>
|
||||
'comment' in item
|
||||
|
||||
const isPost = (item: PostView | CommentView): item is PostView =>
|
||||
!isComment(item)
|
||||
|
||||
let loading = false
|
||||
let reason = ''
|
||||
|
||||
async function report() {
|
||||
if (!item || !$authData) return
|
||||
loading = true
|
||||
|
||||
try {
|
||||
if (isComment(item)) {
|
||||
await getClient().createCommentReport({
|
||||
auth: $authData.token,
|
||||
comment_id: item.comment.id,
|
||||
reason: reason,
|
||||
})
|
||||
} else if (isPost(item)) {
|
||||
await getClient().createPostReport({
|
||||
auth: $authData.token,
|
||||
post_id: item.post.id,
|
||||
reason: reason,
|
||||
})
|
||||
}
|
||||
toast({
|
||||
content: 'That submission has been reported.',
|
||||
type: ToastType.success,
|
||||
})
|
||||
} catch (err) {
|
||||
toast({ content: err as any, type: ToastType.error })
|
||||
}
|
||||
|
||||
loading = false
|
||||
}
|
||||
|
||||
const resetText = () => (reason = '')
|
||||
|
||||
$: {
|
||||
if (item) {
|
||||
resetText()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:open>
|
||||
<h1 class="font-bold text-2xl" slot="title">Report</h1>
|
||||
<form class="flex flex-col gap-4" on:submit|preventDefault={report}>
|
||||
{#if item}
|
||||
<span>Reporting this submission</span>
|
||||
<div class="pointer-events-none list-none">
|
||||
{#if isComment(item)}
|
||||
<Comment
|
||||
actions={false}
|
||||
node={{
|
||||
children: [],
|
||||
comment_view: item,
|
||||
depth: 1,
|
||||
loading: false,
|
||||
}}
|
||||
postId={item.post.id}
|
||||
/>
|
||||
{:else if isPost(item)}
|
||||
<Post actions={false} post={item} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<TextArea
|
||||
required
|
||||
rows={3}
|
||||
label="Reason"
|
||||
placeholder="he's being a meanie :("
|
||||
bind:value={reason}
|
||||
/>
|
||||
<Button submit {loading} disabled={loading} color="primary" size="lg">
|
||||
Submit
|
||||
</Button>
|
||||
</form>
|
||||
</Modal>
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
interface Modals {
|
||||
reporting: {
|
||||
open: boolean
|
||||
item: PostView | CommentView | undefined
|
||||
}
|
||||
}
|
||||
|
||||
export let modals = writable<Modals>({
|
||||
reporting: {
|
||||
open: false,
|
||||
item: undefined,
|
||||
},
|
||||
})
|
||||
|
||||
export function report(item: PostView | CommentView) {
|
||||
modals.update((m) => ({
|
||||
...m,
|
||||
reporting: {
|
||||
open: true,
|
||||
item: item,
|
||||
},
|
||||
}))
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
|
||||
export let post: PostView
|
||||
|
||||
export let actions: boolean = true
|
||||
</script>
|
||||
|
||||
<Card class="bg-white flex flex-col w-full p-5 gap-2.5">
|
||||
@@ -111,16 +113,18 @@
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
<PostActions
|
||||
{post}
|
||||
on:edit={(e) => {
|
||||
post.post.name = e.detail.post.name
|
||||
post.post.body = e.detail.post.body
|
||||
post.post.url = e.detail.post.url
|
||||
toast({
|
||||
content: 'The post was edited successfully.',
|
||||
type: ToastType.success,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{#if actions}
|
||||
<PostActions
|
||||
{post}
|
||||
on:edit={(e) => {
|
||||
post.post.name = e.detail.post.name
|
||||
post.post.body = e.detail.post.body
|
||||
post.post.url = e.detail.post.url
|
||||
toast({
|
||||
content: 'The post was edited successfully.',
|
||||
type: ToastType.success,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</Card>
|
||||
@@ -9,6 +9,7 @@
|
||||
BookmarkSlash,
|
||||
ChatBubbleOvalLeft,
|
||||
EllipsisHorizontal,
|
||||
Flag,
|
||||
Icon,
|
||||
Newspaper,
|
||||
PencilSquare,
|
||||
@@ -27,6 +28,7 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import PostForm from '$lib/components/lemmy/post/PostForm.svelte'
|
||||
import { report } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
|
||||
export let post: PostView
|
||||
|
||||
@@ -142,12 +144,18 @@
|
||||
<Icon src={post.saved ? BookmarkSlash : Bookmark} width={16} mini />
|
||||
{post.saved ? 'Unsave' : 'Save'}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $user && isMutable(post, $user)}
|
||||
<MenuButton on:click={deletePost} color={Color.dangerSecondary}>
|
||||
<Icon src={Trash} width={16} mini />
|
||||
Delete
|
||||
</MenuButton>
|
||||
{#if $user && isMutable(post, $user)}
|
||||
<MenuButton on:click={deletePost} color={Color.dangerSecondary}>
|
||||
<Icon src={Trash} width={16} mini />
|
||||
Delete
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $user?.person.id != post.creator.id}
|
||||
<MenuButton on:click={() => report(post)} color={Color.dangerSecondary}>
|
||||
<Icon src={Flag} width={16} mini />
|
||||
Report
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{/if}
|
||||
</Menu>
|
||||
</div>
|
||||
@@ -64,6 +64,14 @@
|
||||
@apply list-decimal pl-4 leading-3;
|
||||
}
|
||||
|
||||
.markdown :global(ul > *) {
|
||||
@apply leading-[22px];
|
||||
}
|
||||
|
||||
.markdown :global(ol > *) {
|
||||
@apply leading-[22px];
|
||||
}
|
||||
|
||||
.markdown :global(li) {
|
||||
@apply m-0 leading-[22px] !important;
|
||||
}
|
||||
@@ -75,4 +83,8 @@
|
||||
.markdown :global(blockquote) {
|
||||
@apply border-l-2 border-black/20 dark:border-white/20 pl-2 my-1 h-max;
|
||||
}
|
||||
|
||||
.markdown :global(p) {
|
||||
@apply leading-[22px];
|
||||
}
|
||||
</style>
|
||||
@@ -2,6 +2,7 @@
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Icon, XMark } from 'svelte-hero-icons'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fade, scale } from 'svelte/transition'
|
||||
|
||||
@@ -23,15 +24,18 @@ flex flex-col items-center justify-center bg-black/50 backdrop-blur-sm"
|
||||
<div
|
||||
on:click|stopPropagation={() => {}}
|
||||
transition:scale={{ start: 0.9, easing: expoOut }}
|
||||
class={$$props.class}
|
||||
class="overflow-y-auto {$$props.class} my-4 rounded-xl"
|
||||
>
|
||||
<Card class="w-[calc(100vw-1rem)] dark:!bg-zinc-950 rounded-xl max-w-xl">
|
||||
<div class="p-6 flex flex-col gap-4">
|
||||
{#if $$slots.title}
|
||||
<h1 class="font-bold text-2xl">
|
||||
<div class="flex flex-row">
|
||||
<h1 class="font-bold text-2xl w-max">
|
||||
<slot name="title" />
|
||||
</h1>
|
||||
{/if}
|
||||
<Button class="!p-2 ml-auto" on:click={() => (open = false)}>
|
||||
<Icon src={XMark} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
{#if action}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { env } from '$env/dynamic/public'
|
||||
|
||||
export const LINKED_INSTANCE_URL = env.PUBLIC_INSTANCE_URL
|
||||
export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemm.ee'
|
||||
export let instance = writable(DEFAULT_INSTANCE_URL)
|
||||
export let corsSupported = writable(true)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import nProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte'
|
||||
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
|
||||
|
||||
nProgress.configure({
|
||||
minimum: 0.4,
|
||||
@@ -30,6 +31,7 @@
|
||||
|
||||
<Navbar />
|
||||
<ToastContainer />
|
||||
<Moderation />
|
||||
<main class="mx-auto max-w-5xl p-4 flex-1 w-full">
|
||||
<slot />
|
||||
</main>
|
||||
@@ -10,15 +10,15 @@
|
||||
} from '$lib/components/ui/toasts/toasts.js'
|
||||
import {
|
||||
DEFAULT_INSTANCE_URL,
|
||||
LINKED_INSTANCE_URL,
|
||||
authData,
|
||||
getClient,
|
||||
user,
|
||||
validateInstance,
|
||||
} from '$lib/lemmy.js'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
|
||||
let data = {
|
||||
instance: '',
|
||||
instance: DEFAULT_INSTANCE_URL,
|
||||
username: '',
|
||||
password: '',
|
||||
totp: '',
|
||||
@@ -89,6 +89,7 @@
|
||||
id="instance_url"
|
||||
label="Instance URL"
|
||||
placeholder={DEFAULT_INSTANCE_URL}
|
||||
disabled={LINKED_INSTANCE_URL != undefined}
|
||||
bind:value={data.instance}
|
||||
class="flex-1"
|
||||
required
|
||||
|
||||
Reference in new issue
Block a user