cleanup: remove 'filtertabs' and custom profile coloring

This commit is contained in:
James Xylight committed 2025-02-02 17:55:02 -08:00
1 parent e978aaa2f0
commit 8191093b46
3 files changed
+10 -120

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 })}
+1 -1
View File
@@ -21,7 +21,7 @@
{#if profile}
<div style="width: {size}px; height: {size}px;">
{#if profile.avatar && !profile.color}
{#if profile.avatar}
<img
src="{profile.avatar}?thumbnail=32&format=webp"
alt={profile.username}
+9 -46
View File
@@ -34,7 +34,6 @@
import { expoOut } from 'svelte/easing'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import FilterTabs from '$lib/components/ui/tabs/FilterTabs.svelte'
import { fly } from 'svelte/transition'
let debugging = $state(false)
@@ -159,25 +158,15 @@
</div>
{/snippet}
</Header>
<FilterTabs items={$profileData.profiles} id={(i) => i.instance}>
{#snippet children({ items })}
<EditableList
on:action={(acc) => {
removing.account = acc.detail
removing.shown = !removing.shown
}}
>
{#snippet children({ action })}
{#each items as profile, index (profile.id)}
<div>
{#each $profileData.profiles as profile, index (profile.id)}
<div
class="flex flex-row gap-2 items-center py-3"
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
animate:flip={{ duration: 500, easing: expoOut }}
>
<Button
title={profile.id == $currentProfile?.id
? 'Switch'
: 'Current'}
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'}
onclick={async () => {
if (profile.id != $currentProfile?.id) {
switching = profile.id
@@ -186,9 +175,7 @@
}
}}
size="square-md"
color={profile.id == $currentProfile?.id
? 'primary'
: 'ghost'}
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
loading={switching == profile.id}
disabled={switching == profile.id}
rounding="pill"
@@ -202,27 +189,12 @@
{/snippet}
</Button>
<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">
<span class="font-medium">{profile.username}</span>
<span class="text-sm text-slate-600 dark:text-zinc-400">
@@ -261,15 +233,6 @@
{/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={() => {
@@ -285,7 +248,10 @@
{/if}
{#if !LINKED_INSTANCE_URL || profile.user}
<MenuButton
onclick={() => action(profile)}
onclick={() => {
removing.account = profile
removing.shown = !removing.shown
}}
color="danger-subtle"
>
{#snippet prefix()}
@@ -297,9 +263,6 @@
</Menu>
</div>
{/each}
{/snippet}
</EditableList>
{/snippet}
</FilterTabs>
</div>
</div>
{/if}