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}
|
{style}
|
||||||
>
|
>
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
<Avatar
|
<Popover autoClose={false} popoverClass="backdrop-blur-xl rounded-2xl">
|
||||||
url={community?.icon}
|
{#snippet target()}
|
||||||
width={view == 'compact' ? 24 : 32}
|
<button
|
||||||
alt={community?.name}
|
class="row-span-2 flex-shrink-0 mr-2 self-center group/btn bg-slate-200 dark:bg-zinc-800 rounded-full"
|
||||||
class="row-span-2 flex-shrink-0 mr-2 self-center"
|
>
|
||||||
/>
|
<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}
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
<CommunityLink
|
<CommunityLink
|
||||||
|
|||||||
@@ -72,16 +72,16 @@
|
|||||||
<button
|
<button
|
||||||
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
||||||
transition-all bg-slate-50 dark:bg-zinc-900 relative
|
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')}
|
title={$t('profile.profile')}
|
||||||
>
|
>
|
||||||
{#if profile.data?.user}
|
{#if profile.data?.user}
|
||||||
<div
|
<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
|
<Avatar
|
||||||
url={profile.data.user.local_user_view.person.avatar}
|
url={profile.data.user.local_user_view.person.avatar}
|
||||||
width={32}
|
width={36}
|
||||||
alt={profile.data.user.local_user_view.person.name}
|
alt={profile.data.user.local_user_view.person.name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
loading={switching}
|
loading={switching}
|
||||||
loaderWidth={20}
|
loaderWidth={22}
|
||||||
selected={profile.data?.id == prof.id}
|
selected={profile.data?.id == prof.id}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
switching = true
|
switching = true
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
import type { HTMLButtonAttributes } from 'svelte/elements'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
href?: string | undefined
|
href?: string | undefined
|
||||||
@@ -29,7 +25,7 @@
|
|||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
run(() => {
|
$effect(() => {
|
||||||
if (href != undefined) {
|
if (href != undefined) {
|
||||||
selected = page.url.pathname == href
|
selected = page.url.pathname == href
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,23 @@
|
|||||||
profile = undefined,
|
profile = undefined,
|
||||||
selected = false,
|
selected = false,
|
||||||
index = 0,
|
index = 0,
|
||||||
size = 20,
|
size = 22,
|
||||||
guest = false,
|
guest = false,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if profile}
|
{#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}
|
{#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}
|
||||||
width={size}
|
width={size}
|
||||||
height={size}
|
height={size}
|
||||||
class="flex-shrink-0 rounded-full ring-slate-800/50 dark:ring-zinc-200/50"
|
class={['flex-shrink-0 rounded-full', selected && 'scale-75']}
|
||||||
class:ring-2={selected}
|
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
interface Props {
|
interface Props {
|
||||||
openOnHover?: boolean
|
openOnHover?: boolean
|
||||||
open?: boolean
|
open?: boolean
|
||||||
|
autoClose?: boolean
|
||||||
placement?: Placement
|
placement?: Placement
|
||||||
middleware?: Middleware[]
|
middleware?: Middleware[]
|
||||||
strategy?: Strategy
|
strategy?: Strategy
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
let {
|
let {
|
||||||
openOnHover = false,
|
openOnHover = false,
|
||||||
open = $bindable(false),
|
open = $bindable(false),
|
||||||
|
autoClose = false,
|
||||||
placement = 'bottom-start',
|
placement = 'bottom-start',
|
||||||
middleware = [offset(6), shift(), flip()],
|
middleware = [offset(6), shift(), flip()],
|
||||||
strategy = 'fixed',
|
strategy = 'fixed',
|
||||||
@@ -60,6 +62,7 @@
|
|||||||
let canUseContents = $state(true)
|
let canUseContents = $state(true)
|
||||||
|
|
||||||
let el: any = $state()
|
let el: any = $state()
|
||||||
|
let popoverEl: any = $state()
|
||||||
|
|
||||||
const [floatingRef, floatingContent] = createFloatingActions({
|
const [floatingRef, floatingContent] = createFloatingActions({
|
||||||
strategy: strategy,
|
strategy: strategy,
|
||||||
@@ -90,7 +93,13 @@
|
|||||||
if (openOnHover) return
|
if (openOnHover) return
|
||||||
|
|
||||||
if (!el?.contains(e.target) && open) {
|
if (!el?.contains(e.target) && open) {
|
||||||
open = false
|
if (!autoClose) {
|
||||||
|
if (popoverEl && !popoverEl.contains(e.target)) {
|
||||||
|
open = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
open = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onkeydown={async (e) => {
|
onkeydown={async (e) => {
|
||||||
@@ -128,6 +137,7 @@
|
|||||||
class="z-[150] {popoverClass}"
|
class="z-[150] {popoverClass}"
|
||||||
use:customFloatingContent
|
use:customFloatingContent
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
|
bind:this={popoverEl}
|
||||||
>
|
>
|
||||||
{#if popover}{@render popover()}{:else}
|
{#if popover}{@render popover()}{:else}
|
||||||
<Material elevation="high" color="distinct" class="flex flex-col">
|
<Material elevation="high" color="distinct" class="flex flex-col">
|
||||||
|
|||||||
Reference in new issue
Block a user