feat: add new vvote design to comments

This commit is contained in:
Xyphyn committed 2023-08-15 16:23:01 -07:00
1 parent 9eacfef1c9
commit d5d4f69e0d
5 files changed
+97 -52

No files matched your search

@@ -69,8 +69,8 @@
commentId={comment.comment.id} commentId={comment.comment.id}
/> />
<Button <Button
color="elevatedLow"
size="sm" size="sm"
color="ghost"
on:click={() => (replying = !replying)} on:click={() => (replying = !replying)}
disabled={comment.post.locked} disabled={comment.post.locked}
> >
@@ -80,13 +80,13 @@
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))} {#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
<CommentModerationMenu bind:item={comment} /> <CommentModerationMenu bind:item={comment} />
{/if} {/if}
<Menu let:toggleOpen class="h-7 top-0 leading-3" alignment="bottom-center"> <Menu let:toggleOpen class="top-0 leading-3" alignment="bottom-center">
<Button <Button
slot="button" slot="button"
color="elevatedLow"
on:click={toggleOpen} on:click={toggleOpen}
class="!p-1" class="!p-1"
aria-label="Comment actions" aria-label="Comment actions"
color="ghost"
> >
<Icon src={EllipsisHorizontal} width={16} height={16} mini slot="icon" /> <Icon src={EllipsisHorizontal} width={16} height={16} mini slot="icon" />
</Button> </Button>
@@ -1,9 +1,17 @@
<script lang="ts"> <script lang="ts">
import { Color } from '$lib/ui/colors' import { Color } from '$lib/ui/colors'
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons' import {
ArrowDownCircle,
ArrowUpCircle,
ChevronDown,
ChevronUp,
Icon,
} from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy' import { getClient } from '$lib/lemmy'
import { userSettings } from '$lib/settings' import { userSettings } from '$lib/settings'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import Button from '$lib/components/input/Button.svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
export let vote: number = 0 export let vote: number = 0
export let score: number export let score: number
@@ -56,35 +64,82 @@
}) })
.catch((_) => undefined) .catch((_) => undefined)
} }
const voteColor = (vote: number) => `
${
vote == 1
? $userSettings.revertColors
? '!text-orange-500'
: '!text-blue-500'
: vote == -1
? $userSettings.revertColors
? '!text-blue-500'
: '!text-red-500'
: ''
}
`
</script> </script>
<div {#if $userSettings.newVote}
class="flex flex-row items-center rounded-md transition-colors <div
cursor-pointer h-full {Color.borderDark}" class="flex flex-row items-center rounded-md transition-colors
> cursor-pointer h-[26px] gap-0.5 !text-slate-600 dark:!text-zinc-300"
<button
on:click={upvote}
class="px-1.5 {vote == 1
? $userSettings.revertColors
? 'text-orange-500'
: 'dark:text-blue-500 text-blue-600'
: ''}"
aria-label="Upvote"
> >
<Icon src={ChevronUp} width={19} mini /> <Button
</button> on:click={upvote}
<span class="text-sm"> class={vote == 1
{score} ? voteColor(vote)
</span> : '!text-slate-600 dark:!text-zinc-300'}
<button aria-label="Upvote"
on:click={downvote} size="square-sm"
class="px-1.5 {vote == -1 color="tertiary"
? $userSettings.revertColors >
? 'dark:text-blue-500 text-blue-600' <Icon src={ArrowUpCircle} width={19} mini={vote == 1} />
: 'text-red-400' </Button>
: ''}" <span class="text-sm font-medium {voteColor(vote)}">
aria-label="Downvote" <FormattedNumber number={score} />
</span>
<Button
on:click={downvote}
class={vote == -1
? voteColor(vote)
: '!text-slate-600 dark:!text-zinc-300'}
aria-label="Downvote"
size="square-sm"
color="tertiary"
>
<Icon src={ArrowDownCircle} width={19} mini={vote == -1} />
</Button>
</div>
{:else}<div
class="flex flex-row items-center rounded-md transition-colors
cursor-pointer h-[26px] border border-slate-200
dark:border-zinc-700"
> >
<Icon src={ChevronDown} width={19} mini /> <button
</button> on:click={upvote}
</div> class="px-1.5 {vote == 1
? $userSettings.revertColors
? 'text-orange-500'
: 'dark:text-blue-500 text-blue-600'
: ''}"
aria-label="Upvote"
>
<Icon src={ChevronUp} width={19} mini />
</button>
<span class="text-sm font-medium {voteColor(vote)}">
<FormattedNumber number={score} />
</span>
<button
on:click={downvote}
class="px-1.5 {vote == -1
? $userSettings.revertColors
? 'dark:text-blue-500 text-blue-600'
: 'text-red-400'
: ''}"
aria-label="Downvote"
>
<Icon src={ChevronDown} width={19} mini />
</button>
</div>
{/if}
@@ -14,34 +14,21 @@
import { Color } from '$lib/ui/colors.js' import { Color } from '$lib/ui/colors.js'
import { isComment } from '$lib/lemmy/item.js' import { isComment } from '$lib/lemmy/item.js'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
export let item: PostView | CommentView export let item: PostView | CommentView
</script> </script>
<Menu let:toggleOpen alignment="bottom-center" class="top-0 h-[26px] w-[26px] "> <Menu let:toggleOpen alignment="bottom-center" class="top-0 h-[26px] w-[26px] ">
<Button <Button
class="!p-1 hover:!text-green-500 dark:text-zinc-400 text-slate-600" class="w-[26px] h-[26px] hover:!text-green-500 dark:text-zinc-400 text-slate-600"
size="sm" size="square-md"
on:click={toggleOpen} on:click={toggleOpen}
slot="button" slot="button"
color="elevatedLow" color="ghost"
{...$$restProps} {...$$restProps}
> >
<svg <ShieldIcon filled width={14} />
width="16"
height="16"
viewBox="0 0 20 22"
fill="none"
xmlns="http://www.w3.org/2000/svg"
slot="icon"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M10.516 1.17C10.3767 1.03791 10.192 0.964283 10 0.964283C9.80801 0.964283 9.62333 1.03791 9.484 1.17C7.36127 3.18588 4.53412 4.29133 1.607 4.25C1.44753 4.24793 1.29156 4.29674 1.16172 4.38935C1.03189 4.48196 0.934957 4.61355 0.885 4.765C0.462973 6.05116 0.248618 7.39637 0.25 8.75C0.25 14.692 4.314 19.683 9.813 21.098C9.93566 21.1296 10.0643 21.1296 10.187 21.098C15.686 19.683 19.75 14.692 19.75 8.75C19.75 7.36 19.527 6.02 19.115 4.765C19.0652 4.61336 18.9684 4.48156 18.8385 4.38875C18.7087 4.29595 18.5526 4.247 18.393 4.249L18.25 4.25C15.254 4.25 12.533 3.08 10.516 1.17Z"
fill="currentColor"
/>
</svg>
</Button> </Button>
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user) && item.community.local)} {#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user) && item.community.local)}
<li class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400"> <li class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
@@ -85,7 +85,7 @@
<slot {upvote} {downvote} {vote} {score}> <slot {upvote} {downvote} {vote} {score}>
{#if $userSettings.newVote} {#if $userSettings.newVote}
<div class="flex items-center text-sm gap-1 rounded-md border-zinc-700"> <div class="flex items-center text-sm rounded-md border-zinc-700">
<Button <Button
aria-label="Upvote" aria-label="Upvote"
class={vote == 1 ? voteColor(vote) : ''} class={vote == 1 ? voteColor(vote) : ''}
+4 -1
View File
@@ -17,6 +17,7 @@
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.js'
import { addSubscription } from '$lib/lemmy/user.js' import { addSubscription } from '$lib/lemmy/user.js'
import Link from '$lib/components/input/Link.svelte' import Link from '$lib/components/input/Link.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
export let data export let data
@@ -40,7 +41,9 @@
<div class="flex flex-col sm:flex-row gap-4 mt-4"> <div class="flex flex-col sm:flex-row gap-4 mt-4">
<MultiSelect <MultiSelect
options={['Subscribed', 'Local', 'All']} options={['Subscribed', 'Local', 'All']}
selected={$page.url.searchParams.get('type') ?? 'All'} selected={$page.url.searchParams.get('type') ?? LINKED_INSTANCE_URL
? 'Local'
: 'All'}
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')} on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
/> />
<div class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center"> <div class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center">