diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index fb56e2bd..aac0550b 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -25,6 +25,7 @@ import CommentForm from './CommentForm.svelte' import type { CommentNodeI } from './comments.svelte' import { page } from '$app/state' + import { keybindComment } from '$lib/ui/keybinds.svelte' import { settings } from '$lib/settings.svelte' interface Props { @@ -118,9 +119,15 @@ {/if} + +
  • + keybindComment(e, node.comment_view.comment.id, () => (open = !open))} + tabindex="0" > {#if meta} {/snippet} diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index 676951dd..6fd0d78b 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -4,6 +4,7 @@ import type { CommentNodeI } from './comments.svelte' import Comments from './CommentTree.svelte' import { onMount } from 'svelte' + import { keybindFeed } from '$lib/ui/keybinds.svelte' interface Props { nodes: CommentNodeI[] @@ -13,8 +14,8 @@ onMount(() => { if (scrollTo) { - const element = document?.getElementById(scrollTo) setTimeout(() => { + const element = document?.getElementById(scrollTo) element?.scrollIntoView({ behavior: 'smooth', block: 'start' }) }, 100) } @@ -38,6 +39,8 @@ let initialOffset = $derived(offsetEl?.offsetTop) + +
    {#if offsetEl} { + export const castVote = async (newVote: number) => { if (!profile.current?.jwt) { toast({ content: $t('toast.loginVoteGate'), type: 'warning' }) return } + switch (vote ?? 0) { + case 0: + // nothing was removed + if (newVote == 1) upvotes++ + else downvotes++ + break + case 1: + // removed an upvote + upvotes-- + if (newVote == -1) downvotes++ + break + case -1: + // removed a downvote + downvotes-- + if (newVote == 1) upvotes++ + break + } + vote = newVote - const res = await getClient().likeComment({ - comment_id: commentId, - score: vote, - }) - ;({ upvotes, downvotes } = res.comment_view.counts) + client() + .likeComment({ + comment_id: commentId, + score: vote, + }) + .then(res => ({ upvotes, downvotes } = res.comment_view.counts)) } let voteRatio = $derived( diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 4d7c249c..edb0ace3 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -14,6 +14,7 @@ import type { PostView } from 'lemmy-js-client' import type { ClassValue } from 'svelte/elements' import PostBody from './PostBody.svelte' + import { keybindPost } from '$lib/ui/keybinds.svelte' function getTagRule(tags: Tag[]): 'blur-sm' | 'hide' | undefined { const tagContent = tags.map(t => t.content.toLowerCase()) @@ -28,9 +29,9 @@ return rule } - function onClick(e: Event) { + function onclick(e: Event) { const event = e as Event - const parent = document.getElementById(post.post.id.toString()) + const parent = document.getElementById(`item-${post.post.id.toString()}`) if (event.target == parent) { goto(postLink(post.post)) @@ -79,6 +80,8 @@ admin: post.creator_is_admin, moderator: post.creator_is_moderator, }) + + let voteComponent = $state<{ castVote: (vote: number) => void }>()
    history.back()} - onkeydown={e => { - if (e.key == 'Escape') history.back() - }} use:focusTrap + onclick={() => history.back()} > -
      +
        {#if items} - {#each items as item, index (item)} + {#each items as item, index}
      • :global(li) { + background-color: var(--color-slate-25); + + &:hover { + background-color: var(--color-slate-50); + } + } + + :global(.dark) ul.secondary > :global(li) { + background-color: var(--color-zinc-925); + + &:hover { + background-color: var(--color-zinc-800); + } + } + @keyframes pop-in { from { transform: translateY(16px); diff --git a/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte b/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte index 934fc090..19eda457 100644 --- a/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte +++ b/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte @@ -1,5 +1,6 @@ @@ -74,7 +76,7 @@ {/if}
    {/if} -
    +
    {#if icon}