misc: Add setting
This commit is contained in:
1 parent
fab41a6784
commit
ae07e8b14b
5 files changed
+76
-5
No files matched your search
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
export let enabled = false
|
||||
</script>
|
||||
|
||||
<label>
|
||||
<div
|
||||
class="relative w-10 border-2 h-6 transition-colors cursor-pointer
|
||||
rounded-full flex flex-row items-center shadow-lg {enabled
|
||||
? 'bg-blue-500 border-blue-500'
|
||||
: 'bg-slate-200 dark:bg-zinc-800 border-slate-200 dark:border-zinc-800'}"
|
||||
>
|
||||
<div
|
||||
class="w-5 h-5 rounded-full transition-transform
|
||||
bg-white dark:bg-zinc-700 {enabled ? 'translate-x-4' : 'translate-x-0'}"
|
||||
/>
|
||||
</div>
|
||||
<input type="checkbox" bind:checked={enabled} class="hidden" />
|
||||
</label>
|
||||
@@ -17,6 +17,7 @@
|
||||
import UserLink from '$lib/components/user/UserLink.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
|
||||
export let node: CommentNodeI
|
||||
export let postId: number
|
||||
@@ -86,7 +87,9 @@
|
||||
commentId={node.comment_view.comment.id}
|
||||
/>
|
||||
<button
|
||||
class="{Color.borderDark} h-full px-2 flex flex-row items-center gap-1
|
||||
class="{$userSettings.newComments
|
||||
? Color.borderDark
|
||||
: 'hover:bg-slate-200 hover:dark:bg-zinc-800'} h-full px-2 flex flex-row items-center gap-1
|
||||
rounded-md transition-colors"
|
||||
on:click={() => (replying = !replying)}
|
||||
>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import { Color } from '$lib/ui/colors'
|
||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { authData, getClient } from '$lib/lemmy'
|
||||
import { userSettings } from '$lib/settings'
|
||||
|
||||
export let vote: number = 0
|
||||
export let score: number
|
||||
@@ -58,7 +59,9 @@
|
||||
|
||||
<div
|
||||
class="flex flex-row items-center rounded-md transition-colors
|
||||
cursor-pointer h-full {Color.borderDark}"
|
||||
cursor-pointer h-full {$userSettings.newComments
|
||||
? Color.borderDark
|
||||
: 'hover:bg-slate-200 hover:dark:bg-zinc-800'}"
|
||||
>
|
||||
<button
|
||||
on:click={upvote}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
interface Settings {
|
||||
newComments: boolean
|
||||
}
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
newComments: true,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
function mergeObjects<T>(obj1: any, obj2: any): T {
|
||||
for (let prop in obj2) {
|
||||
if (!(prop in obj1) || obj1[prop] == null || obj2[prop] == '') {
|
||||
obj1[prop] = obj2[prop]
|
||||
}
|
||||
}
|
||||
return obj1
|
||||
}
|
||||
|
||||
if (typeof window != 'undefined') {
|
||||
let oldUserSettings = JSON.parse(
|
||||
localStorage.getItem('settings') ?? JSON.stringify(defaultSettings)
|
||||
)
|
||||
|
||||
userSettings.set(mergeObjects<Settings>(oldUserSettings, defaultSettings))
|
||||
}
|
||||
|
||||
userSettings.subscribe((settings) => {
|
||||
if (typeof window != 'undefined') {
|
||||
localStorage.setItem('settings', JSON.stringify(settings))
|
||||
}
|
||||
})
|
||||
@@ -1 +1,14 @@
|
||||
<span>Coming soon...</span>
|
||||
<script>
|
||||
import Switch from '$lib/components/input/Switch.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import { userSettings } from '$lib/settings'
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<h1 class="text-3xl font-bold">Experiments</h1>
|
||||
<Card class="flex flex-col gap-2 p-4 text-sm">
|
||||
<h1 class="text-lg font-bold">New comment design</h1>
|
||||
<span>Makes comment actions look slightly different.</span>
|
||||
<Switch bind:enabled={$userSettings.newComments} />
|
||||
</Card>
|
||||
</div>
|
||||
Reference in new issue
Block a user