diff --git a/package.json b/package.json index b0a2971a..a1c9c481 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "1.19.0", + "version": "1.19.1", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte index 20493e85..21495bbc 100644 --- a/src/lib/components/lemmy/post/PostVote.svelte +++ b/src/lib/components/lemmy/post/PostVote.svelte @@ -14,6 +14,7 @@ import { Button, Popover, toast } from 'mono-svelte' import { site } from '$lib/lemmy.js' import { fly } from 'svelte/transition' + import { userSettings } from '$lib/settings.js' export let post: Post export let vote: number = 0 @@ -26,6 +27,16 @@ const voteColor = (vote: number, border: boolean = false) => vote == 1 ? `!text-blue-500` : vote == -1 ? `!text-red-500` : '' + const shouldShowVoteColor = ( + vote: number, + type: 'upvotes' | 'downvotes' + ): string => + (vote == -1 && type == 'downvotes') || + (vote == 1 && type == 'upvotes') || + !$userSettings.separateVotes + ? voteColor(vote) + : '' + const castVote = async (newVote: number) => { if (!$profile?.jwt) { toast({ content: 'You must be logged in to vote.', type: 'warning' }) @@ -41,58 +52,82 @@
- - - {#key score} +
+ + + {#key $userSettings.separateVotes ? upvotes : score} + + + + {/key} + +
+ {#if $userSettings.separateVotes} +
+
+
+ {/if} +
+ + {#if $userSettings.separateVotes} oldScore ? 4 : -4, duration: 200 }} - out:fly={{ y: score > oldScore ? -4 : 4, duration: 200 }} - style="grid-column: 1; grid-row: 1;" + class="font-medium transition-colors duration-200 grid {shouldShowVoteColor( + vote, + 'downvotes' + )}" + class:hidden={$profile?.user?.local_user_view.local_user + .show_scores == false} > - + {#key downvotes} + + + + {/key} - {/key} - - + {/if} +
- - diff --git a/src/lib/settings.ts b/src/lib/settings.ts index a59cde6b..c19b1a5c 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -71,6 +71,7 @@ interface Settings { newWidth: boolean markPostsAsRead: boolean + separateVotes: boolean } export const defaultSettings: Settings = { @@ -118,6 +119,7 @@ export const defaultSettings: Settings = { hidePhoton: toBool(env.PUBLIC_REMOVE_CREDIT) ?? false, newWidth: true, markPostsAsRead: true, + separateVotes: false, } export const userSettings = writable(defaultSettings) diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index ff00f3d4..79a38a02 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -159,6 +159,14 @@ {$userSettings.markReadPosts ? 'Enabled' : 'Disabled'} + + Vote style + + NSFW blur