misc: redesign postvote
This commit is contained in:
1 parent
1e53cfa798
commit
88aca6991f
6 files changed
+33
-73
No files matched your search
@@ -36,8 +36,9 @@
|
|||||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||||
const seenUrls = new Set<string>()
|
const seenUrls = new Set<string>()
|
||||||
|
|
||||||
posts.forEach((post) => {
|
posts?.forEach((post) => {
|
||||||
if (!post.post.url) {
|
if (!post) return
|
||||||
|
if (!post?.post?.url) {
|
||||||
results.push(post)
|
results.push(post)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -70,7 +71,7 @@
|
|||||||
? 'gap-3 md:gap-4'
|
? 'gap-3 md:gap-4'
|
||||||
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||||
>
|
>
|
||||||
{#if posts.length == 0}
|
{#if posts?.length == 0}
|
||||||
<div class="h-full grid place-items-center">
|
<div class="h-full grid place-items-center">
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={ArchiveBox}
|
icon={ArchiveBox}
|
||||||
|
|||||||
@@ -50,83 +50,48 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot {vote} {score}>
|
<slot {vote} {score}>
|
||||||
<!-- <Popover openOnHover placement="bottom"> -->
|
|
||||||
<div
|
<div
|
||||||
class="flex items-center text-sm rounded-lg border {buttonColor.secondary} hover:bg-white dark:hover:bg-zinc-900 px-1 h-8 cursor-pointer"
|
class="{buttonColor.secondary} rounded-lg h-full flex items-center [&>*]:p-2
|
||||||
class:pr-2.5={$userSettings.separateVotes}
|
hover:bg-white hover:dark:bg-zinc-900 overflow-hidden"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<button
|
||||||
<Button
|
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
||||||
aria-label="Upvote"
|
class="flex items-center gap-0.5 {buttonColor.secondary} transition-colors border-0
|
||||||
class={vote == 1
|
{vote == 1 ? shouldShowVoteColor(vote, 'upvotes') : ''}"
|
||||||
? voteColor(vote)
|
|
||||||
: 'hover:dark:text-blue-600 hover:text-blue-500'}
|
|
||||||
on:click={async () => castVote(vote == 1 ? 0 : 1)}
|
|
||||||
size="square-sm"
|
|
||||||
color="tertiary"
|
|
||||||
alignment="center"
|
|
||||||
>
|
>
|
||||||
<Icon src={ChevronUp} mini size="18" />
|
<Icon src={ChevronUp} size="18" mini />
|
||||||
</Button>
|
<span class="grid text-sm">
|
||||||
|
{#key upvotes}
|
||||||
<span
|
<span
|
||||||
class="font-medium transition-colors duration-200 grid {shouldShowVoteColor(
|
|
||||||
vote,
|
|
||||||
'upvotes'
|
|
||||||
)}"
|
|
||||||
class:hidden={$profile?.user?.local_user_view.local_user.show_scores ==
|
|
||||||
false}
|
|
||||||
>
|
|
||||||
{#key $userSettings.separateVotes ? upvotes : score}
|
|
||||||
<span
|
|
||||||
in:fly={{ y: -4, duration: 200 }}
|
|
||||||
out:fly={{ y: 4, duration: 200 }}
|
|
||||||
style="grid-column: 1; grid-row: 1;"
|
style="grid-column: 1; grid-row: 1;"
|
||||||
|
in:fly={{ duration: 200, y: -6 }}
|
||||||
|
out:fly={{ duration: 200, y: 6 }}
|
||||||
>
|
>
|
||||||
<FormattedNumber
|
<FormattedNumber number={upvotes} />
|
||||||
number={$userSettings.separateVotes ? upvotes : score}
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
{/key}
|
{/key}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</button>
|
||||||
{#if $userSettings.separateVotes}
|
<div
|
||||||
<div class="h-full py-1.5 pl-2 pr-0.5">
|
class="border-l h-6 w-0 !p-0 border-slate-200 dark:border-zinc-800"
|
||||||
<div class="border-l dark:border-zinc-700 h-full" />
|
></div>
|
||||||
</div>
|
<button
|
||||||
{/if}
|
on:click={() => castVote(vote == -1 ? 0 : -1)}
|
||||||
<div class="flex items-center">
|
class="flex items-center gap-0.5 !pr-2.5 {buttonColor.secondary} transition-colors border-0
|
||||||
<Button
|
{vote == -1 ? shouldShowVoteColor(vote, 'downvotes') : ''}"
|
||||||
aria-label="Downvote"
|
|
||||||
class="{vote == -1 ? voteColor(vote) : ''} {$site?.site_view.local_site
|
|
||||||
.enable_downvotes
|
|
||||||
? 'hover:dark:text-red-600 hover:text-red-500'
|
|
||||||
: 'pointer-events-none opacity-50'}"
|
|
||||||
on:click={async () => castVote(vote == -1 ? 0 : -1)}
|
|
||||||
size="square-sm"
|
|
||||||
color="tertiary"
|
|
||||||
>
|
|
||||||
<Icon src={ChevronDown} mini size="18" />
|
|
||||||
</Button>
|
|
||||||
{#if $userSettings.separateVotes}
|
|
||||||
<span
|
|
||||||
class="font-medium transition-colors duration-200 grid {shouldShowVoteColor(
|
|
||||||
vote,
|
|
||||||
'downvotes'
|
|
||||||
)}"
|
|
||||||
class:hidden={$profile?.user?.local_user_view.local_user
|
|
||||||
.show_scores == false}
|
|
||||||
>
|
>
|
||||||
|
<Icon src={ChevronDown} size="18" mini />
|
||||||
|
<span class="grid text-sm">
|
||||||
{#key downvotes}
|
{#key downvotes}
|
||||||
<span
|
<span
|
||||||
in:fly={{ y: -4, duration: 200 }}
|
|
||||||
out:fly={{ y: 4, duration: 200 }}
|
|
||||||
style="grid-column: 1; grid-row: 1;"
|
style="grid-column: 1; grid-row: 1;"
|
||||||
|
in:fly={{ duration: 200, y: -6 }}
|
||||||
|
out:fly={{ duration: 200, y: 6 }}
|
||||||
>
|
>
|
||||||
<FormattedNumber number={downvotes} />
|
<FormattedNumber number={downvotes} />
|
||||||
</span>
|
</span>
|
||||||
{/key}
|
{/key}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
@@ -6,4 +6,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span>{Intl.NumberFormat(locale, options).format(number)}</span>
|
<span>
|
||||||
|
{Intl.NumberFormat(locale, options).format(number)}
|
||||||
|
</span>
|
||||||
@@ -16,7 +16,7 @@ export async function load({ params, fetch, url }) {
|
|||||||
return {
|
return {
|
||||||
sort: sort,
|
sort: sort,
|
||||||
page: page || 1,
|
page: page || 1,
|
||||||
posts: client({ func: fetch }).getPosts({
|
posts: await client({ func: fetch }).getPosts({
|
||||||
limit: 40,
|
limit: 40,
|
||||||
community_name: params.name,
|
community_name: params.name,
|
||||||
page: page,
|
page: page,
|
||||||
|
|||||||
@@ -101,14 +101,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting>
|
|
||||||
<span slot="title">Vote style</span>
|
|
||||||
<MultiSelect
|
|
||||||
options={[false, true]}
|
|
||||||
optionNames={['Combined', 'Separate']}
|
|
||||||
bind:selected={$userSettings.separateVotes}
|
|
||||||
/>
|
|
||||||
</Setting>
|
|
||||||
<ToggleSetting
|
<ToggleSetting
|
||||||
bind:checked={$userSettings.openLinksInNewTab}
|
bind:checked={$userSettings.openLinksInNewTab}
|
||||||
title="Open posts in new tab"
|
title="Open posts in new tab"
|
||||||
|
|||||||
Reference in new issue
Block a user