cleanup: remove 'filtertabs' and custom profile coloring
This commit is contained in:
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 })}
|
|
||||||
@@ -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}
|
||||||
|
|||||||
@@ -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,25 +158,15 @@
|
|||||||
</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
|
|
||||||
on:action={(acc) => {
|
|
||||||
removing.account = acc.detail
|
|
||||||
removing.shown = !removing.shown
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#snippet children({ action })}
|
|
||||||
{#each items as profile, index (profile.id)}
|
|
||||||
<div
|
<div
|
||||||
class="flex flex-row gap-2 items-center py-3"
|
class="flex flex-row gap-2 items-center py-3"
|
||||||
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
animate:flip={{ duration: 500, easing: expoOut }}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
title={profile.id == $currentProfile?.id
|
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'}
|
||||||
? 'Switch'
|
|
||||||
: 'Current'}
|
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (profile.id != $currentProfile?.id) {
|
if (profile.id != $currentProfile?.id) {
|
||||||
switching = profile.id
|
switching = profile.id
|
||||||
@@ -186,9 +175,7 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color={profile.id == $currentProfile?.id
|
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
|
||||||
? 'primary'
|
|
||||||
: 'ghost'}
|
|
||||||
loading={switching == profile.id}
|
loading={switching == profile.id}
|
||||||
disabled={switching == profile.id}
|
disabled={switching == profile.id}
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
@@ -202,27 +189,12 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<div class="relative group flex-col items-center">
|
|
||||||
<ProfileAvatar
|
<ProfileAvatar
|
||||||
{profile}
|
{profile}
|
||||||
{index}
|
{index}
|
||||||
selected={$currentProfile?.id == profile.id}
|
selected={$currentProfile?.id == profile.id}
|
||||||
size={24}
|
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-medium">{profile.username}</span>
|
<span class="font-medium">{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">
|
||||||
@@ -261,15 +233,6 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</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}
|
{#if settings.debugInfo}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
@@ -285,7 +248,10 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if !LINKED_INSTANCE_URL || profile.user}
|
{#if !LINKED_INSTANCE_URL || profile.user}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => action(profile)}
|
onclick={() => {
|
||||||
|
removing.account = profile
|
||||||
|
removing.shown = !removing.shown
|
||||||
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -297,9 +263,6 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/snippet}
|
</div>
|
||||||
</EditableList>
|
|
||||||
{/snippet}
|
|
||||||
</FilterTabs>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
Reference in new issue
Block a user