feat: new vote design
This commit is contained in:
1 parent
6630b89bce
commit
bc553804ce
4 files changed
+40
-28
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { slide } from 'svelte/transition'
|
||||
|
||||
export let node: CommentNodeI
|
||||
export let postId: number
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
const dispatcher = createEventDispatcher<{ edit: CommentView }>()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row gap-2 items-center mt-1 h-[26px] relative">
|
||||
<div class="flex flex-row gap-2 items-center mt-1 h-7 relative">
|
||||
<CommentVote
|
||||
bind:score={comment.counts.score}
|
||||
bind:vote={comment.my_vote}
|
||||
@@ -80,16 +80,11 @@
|
||||
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
|
||||
<CommentModerationMenu bind:item={comment} />
|
||||
{/if}
|
||||
<Menu
|
||||
let:toggleOpen
|
||||
class="h-[26px] top-0 leading-3"
|
||||
alignment="bottom-center"
|
||||
>
|
||||
<Menu let:toggleOpen class="h-7 top-0 leading-3" alignment="bottom-center">
|
||||
<Button
|
||||
slot="button"
|
||||
color="elevatedLow"
|
||||
on:click={toggleOpen}
|
||||
size="sm"
|
||||
class="!p-1"
|
||||
aria-label="Comment actions"
|
||||
>
|
||||
|
||||
@@ -113,10 +113,10 @@
|
||||
<PostVote post={post.post} vote={post.my_vote} score={post.counts.score} />
|
||||
|
||||
<Button
|
||||
color="elevated"
|
||||
color="secondary"
|
||||
size="sm"
|
||||
href="/post/{getInstance()}/{post.post.id}"
|
||||
class="px-3 h-full"
|
||||
class="px-3 h-full !text-inherit"
|
||||
>
|
||||
<Icon slot="icon" src={ChatBubbleOvalLeft} width={16} height={16} />
|
||||
<FormattedNumber number={post.counts.comments} />
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||
import {
|
||||
ArrowDownCircle,
|
||||
ArrowUpCircle,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Icon,
|
||||
} from 'svelte-hero-icons'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { slide } from 'svelte/transition'
|
||||
|
||||
@@ -64,32 +70,42 @@
|
||||
})
|
||||
.catch((_) => undefined)
|
||||
}
|
||||
|
||||
const voteColor = (vote: number) =>
|
||||
vote == 1
|
||||
? $userSettings.revertColors
|
||||
? '!text-orange-500'
|
||||
: '!text-blue-400'
|
||||
: vote == -1
|
||||
? $userSettings.revertColors
|
||||
? '!text-blue-500'
|
||||
: '!text-red-500'
|
||||
: ''
|
||||
</script>
|
||||
|
||||
<slot {upvote} {downvote} {vote} {score}>
|
||||
<div
|
||||
class="{Color.border} text-sm gap-0.5 rounded-md flex flex-row items-center
|
||||
transition-colors cursor-pointer bg-slate-100 dark:bg-zinc-800
|
||||
hover:bg-slate-200 dark:hover:bg-zinc-700 h-full"
|
||||
>
|
||||
<button
|
||||
<div class="flex items-center text-sm gap-1 rounded-md border-zinc-700">
|
||||
<Button
|
||||
aria-label="Upvote"
|
||||
class:text-orange-500={vote == 1 && $userSettings.revertColors}
|
||||
class:text-blue-500={vote == 1 && !$userSettings.revertColors}
|
||||
class="py-1 pr-0.5 pl-2"
|
||||
class={vote == 1 ? voteColor(vote) : ''}
|
||||
on:click={upvote}
|
||||
size="square-md"
|
||||
color="tertiary"
|
||||
alignment="center"
|
||||
>
|
||||
<Icon src={ChevronUp} mini width={20} height={20} />
|
||||
</button>
|
||||
<FormattedNumber number={score} />
|
||||
<button
|
||||
<Icon src={ArrowUpCircle} mini={vote == 1} width={20} height={20} />
|
||||
</Button>
|
||||
<span class="font-medium {voteColor(vote)}">
|
||||
<FormattedNumber number={score} />
|
||||
</span>
|
||||
<Button
|
||||
aria-label="Downvote"
|
||||
class:text-blue-500={vote == -1 && $userSettings.revertColors}
|
||||
class:text-red-500={vote == -1 && !$userSettings.revertColors}
|
||||
class="py-1 pl-0.5 pr-2"
|
||||
class={vote == -1 ? voteColor(vote) : ''}
|
||||
on:click={downvote}
|
||||
size="square-md"
|
||||
color="tertiary"
|
||||
>
|
||||
<Icon src={ChevronDown} mini width={20} height={20} />
|
||||
</button>
|
||||
<Icon src={ArrowDownCircle} solid={vote == -1} width={20} height={20} />
|
||||
</Button>
|
||||
</div>
|
||||
</slot>
|
||||
Reference in new issue
Block a user