feat: add community header back on press
This commit is contained in:
6 files changed
+46
-20
No files matched your search
@@ -129,12 +129,30 @@
|
||||
{style}
|
||||
>
|
||||
{#if showCommunity && community}
|
||||
<Avatar
|
||||
url={community?.icon}
|
||||
width={view == 'compact' ? 24 : 32}
|
||||
alt={community?.name}
|
||||
class="row-span-2 flex-shrink-0 mr-2 self-center"
|
||||
/>
|
||||
<Popover autoClose={false} popoverClass="backdrop-blur-xl rounded-2xl">
|
||||
{#snippet target()}
|
||||
<button
|
||||
class="row-span-2 flex-shrink-0 mr-2 self-center group/btn bg-slate-200 dark:bg-zinc-800 rounded-full"
|
||||
>
|
||||
<Avatar
|
||||
url={community?.icon}
|
||||
width={view == 'compact' ? 24 : 32}
|
||||
alt={community?.name}
|
||||
class="group-hover/btn:scale-90 group-active/btn:scale-[.85] transition-transform"
|
||||
/>
|
||||
</button>
|
||||
{/snippet}
|
||||
{#snippet popover()}
|
||||
{#if community && subscribed}
|
||||
<div
|
||||
class="bg-white/80 dark:bg-zinc-900/90 border border-slate-200 dark:border-zinc-800 rounded-2xl shadow-xl p-4
|
||||
max-w-2xl w-full max-h-[32rem] overflow-auto"
|
||||
>
|
||||
<CommunityHeader {community} {subscribed} />
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Popover>
|
||||
{/if}
|
||||
{#if showCommunity && community}
|
||||
<CommunityLink
|
||||
|
||||
@@ -72,16 +72,16 @@
|
||||
<button
|
||||
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
||||
transition-all bg-slate-50 dark:bg-zinc-900 relative
|
||||
hover:bg-slate-200 hover:dark:bg-zinc-700 {buttonClass}"
|
||||
hover:bg-slate-200 hover:dark:bg-zinc-700 group {buttonClass}"
|
||||
title={$t('profile.profile')}
|
||||
>
|
||||
{#if profile.data?.user}
|
||||
<div
|
||||
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center"
|
||||
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center group-hover:scale-90 transition-transform group-active:scale-[85%]"
|
||||
>
|
||||
<Avatar
|
||||
url={profile.data.user.local_user_view.person.avatar}
|
||||
width={32}
|
||||
width={36}
|
||||
alt={profile.data.user.local_user_view.person.name}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
color="tertiary"
|
||||
alignment="left"
|
||||
loading={switching}
|
||||
loaderWidth={20}
|
||||
loaderWidth={22}
|
||||
selected={profile.data?.id == prof.id}
|
||||
onclick={async () => {
|
||||
switching = true
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { page } from '$app/state'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
import type { HTMLButtonAttributes } from 'svelte/elements'
|
||||
|
||||
interface Props {
|
||||
href?: string | undefined
|
||||
@@ -29,7 +25,7 @@
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
if (href != undefined) {
|
||||
selected = page.url.pathname == href
|
||||
}
|
||||
|
||||
@@ -14,21 +14,23 @@
|
||||
profile = undefined,
|
||||
selected = false,
|
||||
index = 0,
|
||||
size = 20,
|
||||
size = 22,
|
||||
guest = false,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
{#if profile}
|
||||
<div style="width: {size}px; height: {size}px;">
|
||||
<div
|
||||
style="width: {size}px; height: {size}px;"
|
||||
class={[profile.avatar && 'bg-slate-200 rounded-full dark:bg-zinc-700']}
|
||||
>
|
||||
{#if profile.avatar}
|
||||
<img
|
||||
src="{profile.avatar}?thumbnail=32&format=webp"
|
||||
alt={profile.username}
|
||||
width={size}
|
||||
height={size}
|
||||
class="flex-shrink-0 rounded-full ring-slate-800/50 dark:ring-zinc-200/50"
|
||||
class:ring-2={selected}
|
||||
class={['flex-shrink-0 rounded-full', selected && 'scale-75']}
|
||||
/>
|
||||
{:else}
|
||||
<Icon
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
interface Props {
|
||||
openOnHover?: boolean
|
||||
open?: boolean
|
||||
autoClose?: boolean
|
||||
placement?: Placement
|
||||
middleware?: Middleware[]
|
||||
strategy?: Strategy
|
||||
@@ -46,6 +47,7 @@
|
||||
let {
|
||||
openOnHover = false,
|
||||
open = $bindable(false),
|
||||
autoClose = false,
|
||||
placement = 'bottom-start',
|
||||
middleware = [offset(6), shift(), flip()],
|
||||
strategy = 'fixed',
|
||||
@@ -60,6 +62,7 @@
|
||||
let canUseContents = $state(true)
|
||||
|
||||
let el: any = $state()
|
||||
let popoverEl: any = $state()
|
||||
|
||||
const [floatingRef, floatingContent] = createFloatingActions({
|
||||
strategy: strategy,
|
||||
@@ -90,7 +93,13 @@
|
||||
if (openOnHover) return
|
||||
|
||||
if (!el?.contains(e.target) && open) {
|
||||
open = false
|
||||
if (!autoClose) {
|
||||
if (popoverEl && !popoverEl.contains(e.target)) {
|
||||
open = false
|
||||
}
|
||||
} else {
|
||||
open = false
|
||||
}
|
||||
}
|
||||
}}
|
||||
onkeydown={async (e) => {
|
||||
@@ -128,6 +137,7 @@
|
||||
class="z-[150] {popoverClass}"
|
||||
use:customFloatingContent
|
||||
use:focusTrap
|
||||
bind:this={popoverEl}
|
||||
>
|
||||
{#if popover}{@render popover()}{:else}
|
||||
<Material elevation="high" color="distinct" class="flex flex-col">
|
||||
|
||||
Reference in new issue
Block a user