feat: add profile recoloring
This commit is contained in:
1 parent
343e3cf78a
commit
8182fa09e7
4 files changed
+78
-11
No files matched your search
+2
-1
@@ -25,13 +25,14 @@ function setFromStorage(key: string, item: any, stringify: boolean = true) {
|
|||||||
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item)
|
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Profile {
|
export interface Profile {
|
||||||
id: number
|
id: number
|
||||||
instance: string
|
instance: string
|
||||||
jwt?: string
|
jwt?: string
|
||||||
user?: PersonData
|
user?: PersonData
|
||||||
username?: string
|
username?: string
|
||||||
favorites?: number[]
|
favorites?: number[]
|
||||||
|
color?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
||||||
|
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
@@ -68,13 +69,10 @@
|
|||||||
? ''
|
? ''
|
||||||
: '!p-1.5'} {$profile?.id == prof.id ? 'font-bold' : ''}"
|
: '!p-1.5'} {$profile?.id == prof.id ? 'font-bold' : ''}"
|
||||||
>
|
>
|
||||||
<Icon
|
<ProfileAvatar
|
||||||
src={UserCircle}
|
profile={prof}
|
||||||
mini={$profile?.id == prof.id}
|
{index}
|
||||||
size="20"
|
selected={$profile?.id == prof.id}
|
||||||
title={prof.username}
|
|
||||||
class="text-blue-500"
|
|
||||||
style="filter: hue-rotate({index * 50}deg)"
|
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
class:hidden={!$userSettings.expandSidebar}
|
class:hidden={!$userSettings.expandSidebar}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Profile } from '$lib/auth.js'
|
||||||
|
import { Icon, UserCircle } from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
export let profile: Profile | undefined = undefined
|
||||||
|
export let selected: boolean = false
|
||||||
|
export let index: number = 0
|
||||||
|
export let size: number = 20
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if profile}
|
||||||
|
<Icon
|
||||||
|
src={UserCircle}
|
||||||
|
mini={selected}
|
||||||
|
size={`${size}`}
|
||||||
|
title={profile.username}
|
||||||
|
class="text-blue-500"
|
||||||
|
style={profile.color
|
||||||
|
? `color: ${profile.color}`
|
||||||
|
: `filter: hue-rotate(${index * 50}deg)`}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
import Button from '$lib/components/input/Button.svelte'
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||||
import EditableList from '$lib/components/ui/list/EditableList.svelte'
|
import EditableList from '$lib/components/ui/list/EditableList.svelte'
|
||||||
|
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||||
|
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||||
import {
|
import {
|
||||||
DEFAULT_INSTANCE_URL,
|
DEFAULT_INSTANCE_URL,
|
||||||
@@ -16,7 +18,16 @@
|
|||||||
instance,
|
instance,
|
||||||
} from '$lib/instance.js'
|
} from '$lib/instance.js'
|
||||||
import { validateInstance } from '$lib/lemmy.js'
|
import { validateInstance } from '$lib/lemmy.js'
|
||||||
import { ArrowLeftOnRectangle, Icon, Plus, Trash } from 'svelte-hero-icons'
|
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
||||||
|
import {
|
||||||
|
ArrowLeftOnRectangle,
|
||||||
|
ArrowUturnLeft,
|
||||||
|
EllipsisHorizontal,
|
||||||
|
Icon,
|
||||||
|
PaintBrush,
|
||||||
|
Plus,
|
||||||
|
Trash,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
import { flip } from 'svelte/animate'
|
import { flip } from 'svelte/animate'
|
||||||
|
|
||||||
let newInstance: string = $profileData.defaultInstance ?? DEFAULT_INSTANCE_URL
|
let newInstance: string = $profileData.defaultInstance ?? DEFAULT_INSTANCE_URL
|
||||||
@@ -110,18 +121,53 @@
|
|||||||
}}
|
}}
|
||||||
let:action
|
let:action
|
||||||
>
|
>
|
||||||
{#each $profileData.profiles as profile (profile.id)}
|
{#each $profileData.profiles as profile, index (profile.id)}
|
||||||
<div
|
<div
|
||||||
class="flex flex-row gap-4 items-center py-4"
|
class="flex flex-row gap-2 items-center py-4"
|
||||||
animate:flip={{ duration: 250 }}
|
animate:flip={{ duration: 250 }}
|
||||||
>
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div class="relative group flex-col items-center">
|
||||||
|
<ProfileAvatar
|
||||||
|
{profile}
|
||||||
|
{index}
|
||||||
|
selected={$currentProfile?.id == profile.id}
|
||||||
|
size={24}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 w-full h-full opacity-0
|
||||||
|
grid group-hover:opacity-100 z-20 place-items-center
|
||||||
|
bg-slate-200 dark:bg-zinc-900 border border-slate-300 dark:border-zinc-800 rounded-full
|
||||||
|
transition-all"
|
||||||
|
>
|
||||||
|
<Icon src={PaintBrush} mini size="14" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="color"
|
||||||
|
class="opacity-0 absolute top-0 left-0 h-full w-full rounded-full cursor-pointer z-30"
|
||||||
|
bind:value={profile.color}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span class="font-bold">{profile.username}</span>
|
<span class="font-bold">{profile.username}</span>
|
||||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||||
{profile.instance}
|
{profile.instance}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="ml-auto" />
|
<div class="ml-auto" />
|
||||||
|
<Menu let:toggleOpen alignment="bottom-right">
|
||||||
|
<Button on:click={toggleOpen} size="square-md" slot="button">
|
||||||
|
<Icon src={EllipsisHorizontal} mini size="16" slot="icon" />
|
||||||
|
</Button>
|
||||||
|
<MenuButton
|
||||||
|
disabled={!profile.color}
|
||||||
|
on:click={() => (profile.color = undefined)}
|
||||||
|
>
|
||||||
|
<Icon src={ArrowUturnLeft} size="16" mini slot="icon" />
|
||||||
|
Reset color
|
||||||
|
</MenuButton>
|
||||||
|
</Menu>
|
||||||
<Button
|
<Button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (profile.id == $currentProfile?.id) {
|
if (profile.id == $currentProfile?.id) {
|
||||||
|
|||||||
Reference in new issue
Block a user