cleanup: remove 'filtertabs' and custom profile coloring
This commit is contained in:
1 parent
e978aaa2f0
commit
8191093b46
3 files changed
+105
-215
No files matched your search
@@ -1,73 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import { Icon, XMark } from 'svelte-hero-icons'
|
|
||||||
import { expoOut } from 'svelte/easing'
|
|
||||||
import { fly, slide } from 'svelte/transition'
|
|
||||||
import TextProps from '../text/TextProps.svelte'
|
|
||||||
|
|
||||||
type T = $$Generic
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
items: T[]
|
|
||||||
id: (item: T) => string | number | symbol
|
|
||||||
identifier?: import('svelte').Snippet<[any]>
|
|
||||||
children?: import('svelte').Snippet<[any]>
|
|
||||||
}
|
|
||||||
|
|
||||||
let { items, id, identifier, children }: Props = $props()
|
|
||||||
|
|
||||||
let filters: Set<string | number | symbol> = $state(new Set())
|
|
||||||
|
|
||||||
let filteredItems = $derived(
|
|
||||||
filters.size > 0 ? items.filter((i) => filters.has(id(i))) : items,
|
|
||||||
)
|
|
||||||
let uniqueIds = $derived(new Set(items.map(id)))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex flex-row overflow-auto space-x-2">
|
|
||||||
{#if filters.size > 0}
|
|
||||||
<div
|
|
||||||
in:slide={{ duration: 300, easing: expoOut, axis: 'x' }}
|
|
||||||
out:slide={{ duration: 300, easing: expoOut, axis: 'x', delay: 100 }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
out:fly={{ duration: 300, easing: expoOut, y: 6 }}
|
|
||||||
in:fly={{ duration: 300, easing: expoOut, y: 6, delay: 100 }}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
onclick={() => {
|
|
||||||
filters.clear()
|
|
||||||
filters = filters
|
|
||||||
}}
|
|
||||||
color="ghost"
|
|
||||||
class="text-inherit dark:text-inherit text-xs aspect-square h-full"
|
|
||||||
rounding="pill"
|
|
||||||
size="square-sm"
|
|
||||||
>
|
|
||||||
<Icon src={XMark} size="14" micro />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{#each uniqueIds as id}
|
|
||||||
<Button
|
|
||||||
onclick={() => {
|
|
||||||
if (filters.has(id)) filters.delete(id)
|
|
||||||
else filters.add(id)
|
|
||||||
filters = filters
|
|
||||||
}}
|
|
||||||
color={filters.has(id) ? 'primary' : 'ghost'}
|
|
||||||
class="text-xs px-2.5"
|
|
||||||
rounding="pill"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
{#if identifier}{@render identifier({ string: id })}{:else}
|
|
||||||
<TextProps wrap="no-wrap">
|
|
||||||
{id}
|
|
||||||
</TextProps>
|
|
||||||
{/if}
|
|
||||||
</Button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{@render children?.({ items: filteredItems })}
|
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
{#if profile}
|
{#if profile}
|
||||||
<div style="width: {size}px; height: {size}px;">
|
<div style="width: {size}px; height: {size}px;">
|
||||||
{#if profile.avatar && !profile.color}
|
{#if profile.avatar}
|
||||||
<img
|
<img
|
||||||
src="{profile.avatar}?thumbnail=32&format=webp"
|
src="{profile.avatar}?thumbnail=32&format=webp"
|
||||||
alt={profile.username}
|
alt={profile.username}
|
||||||
|
|||||||
+104
-141
@@ -34,7 +34,6 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import FilterTabs from '$lib/components/ui/tabs/FilterTabs.svelte'
|
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
let debugging = $state(false)
|
let debugging = $state(false)
|
||||||
@@ -159,147 +158,111 @@
|
|||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
<FilterTabs items={$profileData.profiles} id={(i) => i.instance}>
|
<div>
|
||||||
{#snippet children({ items })}
|
{#each $profileData.profiles as profile, index (profile.id)}
|
||||||
<EditableList
|
<div
|
||||||
on:action={(acc) => {
|
class="flex flex-row gap-2 items-center py-3"
|
||||||
removing.account = acc.detail
|
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
||||||
removing.shown = !removing.shown
|
animate:flip={{ duration: 500, easing: expoOut }}
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{#snippet children({ action })}
|
<Button
|
||||||
{#each items as profile, index (profile.id)}
|
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'}
|
||||||
<div
|
onclick={async () => {
|
||||||
class="flex flex-row gap-2 items-center py-3"
|
if (profile.id != $currentProfile?.id) {
|
||||||
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
switching = profile.id
|
||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
await setUserID(profile.id)
|
||||||
|
switching = -69
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
size="square-md"
|
||||||
|
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
|
||||||
|
loading={switching == profile.id}
|
||||||
|
disabled={switching == profile.id}
|
||||||
|
rounding="pill"
|
||||||
|
>
|
||||||
|
{#snippet prefix()}
|
||||||
|
{#if profile.id == $currentProfile?.id}
|
||||||
|
<Icon src={Check} mini size="16" />
|
||||||
|
{:else}
|
||||||
|
<Icon src={ArrowsRightLeft} size="16" mini />
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
</Button>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<ProfileAvatar
|
||||||
|
{profile}
|
||||||
|
{index}
|
||||||
|
selected={$currentProfile?.id == profile.id}
|
||||||
|
size={24}
|
||||||
|
/>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="font-medium">{profile.username}</span>
|
||||||
|
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||||
|
{profile.instance}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ml-auto"></div>
|
||||||
|
<Menu placement="bottom-end">
|
||||||
|
{#snippet target()}
|
||||||
|
<Button size="square-md">
|
||||||
|
{#snippet prefix()}
|
||||||
|
<Icon src={EllipsisHorizontal} mini size="16" />
|
||||||
|
{/snippet}
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
|
<div class="px-4 py-2 flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
size="square-md"
|
||||||
|
color="secondary"
|
||||||
|
title={$t('account.moveUp')}
|
||||||
|
onclick={() => moveProfile(profile.id, true)}
|
||||||
>
|
>
|
||||||
<Button
|
{#snippet prefix()}
|
||||||
title={profile.id == $currentProfile?.id
|
<Icon src={ChevronUp} size="16" mini />
|
||||||
? 'Switch'
|
{/snippet}
|
||||||
: 'Current'}
|
</Button>
|
||||||
onclick={async () => {
|
<Button
|
||||||
if (profile.id != $currentProfile?.id) {
|
size="square-md"
|
||||||
switching = profile.id
|
color="secondary"
|
||||||
await setUserID(profile.id)
|
title={$t('account.moveDown')}
|
||||||
switching = -69
|
onclick={() => moveProfile(profile.id, false)}
|
||||||
}
|
>
|
||||||
}}
|
{#snippet prefix()}
|
||||||
size="square-md"
|
<Icon src={ChevronDown} size="16" mini />
|
||||||
color={profile.id == $currentProfile?.id
|
{/snippet}
|
||||||
? 'primary'
|
</Button>
|
||||||
: 'ghost'}
|
</div>
|
||||||
loading={switching == profile.id}
|
{#if settings.debugInfo}
|
||||||
disabled={switching == profile.id}
|
<MenuButton
|
||||||
rounding="pill"
|
onclick={() => {
|
||||||
>
|
debugProfile = profile
|
||||||
{#snippet prefix()}
|
debugging = !debugging
|
||||||
{#if profile.id == $currentProfile?.id}
|
}}
|
||||||
<Icon src={Check} mini size="16" />
|
>
|
||||||
{:else}
|
{#snippet prefix()}
|
||||||
<Icon src={ArrowsRightLeft} size="16" mini />
|
<Icon src={BugAnt} size="16" mini />
|
||||||
{/if}
|
{/snippet}
|
||||||
{/snippet}
|
{$t('common.debug')}
|
||||||
</Button>
|
</MenuButton>
|
||||||
<div class="flex items-center gap-2">
|
{/if}
|
||||||
<div class="relative group flex-col items-center">
|
{#if !LINKED_INSTANCE_URL || profile.user}
|
||||||
<ProfileAvatar
|
<MenuButton
|
||||||
{profile}
|
onclick={() => {
|
||||||
{index}
|
removing.account = profile
|
||||||
selected={$currentProfile?.id == profile.id}
|
removing.shown = !removing.shown
|
||||||
size={24}
|
}}
|
||||||
/>
|
color="danger-subtle"
|
||||||
<div
|
>
|
||||||
class="absolute top-0 left-0 w-full h-full opacity-0
|
{#snippet prefix()}
|
||||||
grid group-hover:opacity-100 z-20 place-items-center
|
<Icon src={ArrowRightOnRectangle} size="16" mini />
|
||||||
bg-slate-200 dark:bg-zinc-900 border border-slate-300 dark:border-zinc-800 rounded-full
|
{/snippet}
|
||||||
transition-all"
|
{$t('account.logout')}
|
||||||
>
|
</MenuButton>
|
||||||
<Icon src={PaintBrush} mini size="14" />
|
{/if}
|
||||||
</div>
|
</Menu>
|
||||||
<input
|
</div>
|
||||||
type="color"
|
{/each}
|
||||||
class="opacity-0 absolute top-0 left-0 h-full w-full rounded-full cursor-pointer z-30"
|
</div>
|
||||||
bind:value={profile.color}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<span class="font-medium">{profile.username}</span>
|
|
||||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
|
||||||
{profile.instance}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="ml-auto"></div>
|
|
||||||
<Menu placement="bottom-end">
|
|
||||||
{#snippet target()}
|
|
||||||
<Button size="square-md">
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={EllipsisHorizontal} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
<div class="px-4 py-2 flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
size="square-md"
|
|
||||||
color="secondary"
|
|
||||||
title={$t('account.moveUp')}
|
|
||||||
onclick={() => moveProfile(profile.id, true)}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ChevronUp} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="square-md"
|
|
||||||
color="secondary"
|
|
||||||
title={$t('account.moveDown')}
|
|
||||||
onclick={() => moveProfile(profile.id, false)}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ChevronDown} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<MenuButton
|
|
||||||
disabled={!profile.color}
|
|
||||||
onclick={() => (profile.color = undefined)}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ArrowUturnLeft} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.resetColor')}
|
|
||||||
</MenuButton>
|
|
||||||
{#if settings.debugInfo}
|
|
||||||
<MenuButton
|
|
||||||
onclick={() => {
|
|
||||||
debugProfile = profile
|
|
||||||
debugging = !debugging
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={BugAnt} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('common.debug')}
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
{#if !LINKED_INSTANCE_URL || profile.user}
|
|
||||||
<MenuButton
|
|
||||||
onclick={() => action(profile)}
|
|
||||||
color="danger-subtle"
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ArrowRightOnRectangle} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.logout')}
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
</Menu>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
{/snippet}
|
|
||||||
</EditableList>
|
|
||||||
{/snippet}
|
|
||||||
</FilterTabs>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
Reference in new issue
Block a user