From 93612879f2c4661713092d87e1e3903daabcea84 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Mon, 27 Oct 2025 10:21:47 +0100 Subject: [PATCH] got rid of profile drawer and hover --- src/PageManager.tsx | 81 ++++++++++++++++++++--------- src/components/UserAvatar/index.tsx | 69 +++++++----------------- src/components/Username/index.tsx | 65 ++++++++--------------- 3 files changed, 95 insertions(+), 120 deletions(-) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 51cd9a8..e7a33c4 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -172,15 +172,14 @@ export function useSmartProfileNavigation() { const { setPrimaryNoteView } = usePrimaryNoteView() const navigateToProfile = (url: string) => { - if (!showRecommendedRelaysPanel) { - // When right panel is hidden, show profile in primary area - // Extract profile ID from URL (e.g., "/users/npub1..." -> "npub1...") + if (showRecommendedRelaysPanel) { + // Secondary panel is available - show profile in secondary panel + pushSecondary(url) + } else { + // Secondary panel is not available - show profile in primary panel const profileId = url.replace('/users/', '') window.history.replaceState(null, '', url) setPrimaryNoteView(, 'profile') - } else { - // Normal behavior - use secondary navigation - pushSecondary(url) } } @@ -678,28 +677,58 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { - {!!secondaryStack.length && - secondaryStack.map((item, index) => ( -
- {item.component} + {primaryNoteView ? ( + // Show primary note view with back button on mobile +
+
+
+ +
+
+
+ {primaryNoteView}
- ))} - {primaryPages.map(({ name, element, props }) => ( -
- {props ? cloneElement(element as React.ReactElement, props) : element}
- ))} + ) : ( + <> + {!!secondaryStack.length && + secondaryStack.map((item, index) => ( +
+ {item.component} +
+ ))} + {primaryPages.map(({ name, element, props }) => ( +
+ {props ? cloneElement(element as React.ReactElement, props) : element} +
+ ))} + + )} diff --git a/src/components/UserAvatar/index.tsx b/src/components/UserAvatar/index.tsx index 07c4d8f..6176ba8 100644 --- a/src/components/UserAvatar/index.tsx +++ b/src/components/UserAvatar/index.tsx @@ -1,13 +1,11 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' -import { Drawer, DrawerContent, DrawerOverlay } from '@/components/ui/drawer' -import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card' import { Skeleton } from '@/components/ui/skeleton' import { useFetchProfile } from '@/hooks' import { generateImageByPubkey } from '@/lib/pubkey' +import { toProfile } from '@/lib/link' import { cn } from '@/lib/utils' -import { useScreenSize } from '@/providers/ScreenSizeProvider' -import { useMemo, useState } from 'react' -import ProfileCard from '../ProfileCard' +import { useSmartProfileNavigation } from '@/PageManager' +import { useMemo } from 'react' const UserAvatarSizeCnMap = { large: 'w-24 h-24', @@ -30,8 +28,7 @@ export default function UserAvatar({ size?: 'large' | 'big' | 'semiBig' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny' }) { const { profile } = useFetchProfile(userId) - const { isSmallScreen } = useScreenSize() - const [drawerOpen, setDrawerOpen] = useState(false) + const { navigateToProfile } = useSmartProfileNavigation() const defaultAvatar = useMemo( () => (profile?.pubkey ? generateImageByPubkey(profile.pubkey) : ''), [profile] @@ -42,59 +39,30 @@ export default function UserAvatar({ ) } - const { avatar, pubkey } = profile - if (isSmallScreen) { - return ( - <> - setDrawerOpen(true)} - > - - - {pubkey} - - - - setDrawerOpen(false)} /> - -
- -
-
-
- - ) - } + const { avatar, pubkey } = profile return ( - - - - - - {pubkey} - - - - - - - + navigateToProfile(toProfile(pubkey))} + > + + + {pubkey} + + ) } export function SimpleUserAvatar({ userId, size = 'normal', - className, - onClick + className }: { userId: string - size?: 'large' | 'big' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny' + size?: 'large' | 'big' | 'semiBig' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny' className?: string - onClick?: (e: React.MouseEvent) => void }) { const { profile } = useFetchProfile(userId) const defaultAvatar = useMemo( @@ -107,14 +75,15 @@ export function SimpleUserAvatar({ ) } + const { avatar, pubkey } = profile return ( - + {pubkey} ) -} +} \ No newline at end of file diff --git a/src/components/Username/index.tsx b/src/components/Username/index.tsx index 4b1ffa6..c693342 100644 --- a/src/components/Username/index.tsx +++ b/src/components/Username/index.tsx @@ -1,11 +1,8 @@ -import { Drawer, DrawerContent, DrawerOverlay } from '@/components/ui/drawer' -import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card' import { Skeleton } from '@/components/ui/skeleton' import { useFetchProfile } from '@/hooks' +import { toProfile } from '@/lib/link' import { cn } from '@/lib/utils' -import { useScreenSize } from '@/providers/ScreenSizeProvider' -import { useState } from 'react' -import ProfileCard from '../ProfileCard' +import { useSmartProfileNavigation } from '@/PageManager' export default function Username({ userId, @@ -21,8 +18,7 @@ export default function Username({ withoutSkeleton?: boolean }) { const { profile } = useFetchProfile(userId) - const { isSmallScreen } = useScreenSize() - const [drawerOpen, setDrawerOpen] = useState(false) + const { navigateToProfile } = useSmartProfileNavigation() if (!profile && !withoutSkeleton) { return ( @@ -31,44 +27,21 @@ export default function Username({
) } - if (!profile) return null - const { username, pubkey } = profile - - if (isSmallScreen) { - return ( - <> -
setDrawerOpen(true)} - > - {showAt && '@'} - {username} -
- - setDrawerOpen(false)} /> - -
- -
-
-
- - ) + if (!profile) { + return null } + const { username, pubkey } = profile + return ( - - -
- {showAt && '@'} - {username} -
-
- - - -
+
navigateToProfile(toProfile(pubkey))} + > + {showAt && '@'} + {username} +
) } @@ -86,6 +59,7 @@ export function SimpleUsername({ withoutSkeleton?: boolean }) { const { profile } = useFetchProfile(userId) + if (!profile && !withoutSkeleton) { return (
@@ -93,14 +67,17 @@ export function SimpleUsername({
) } - if (!profile) return null + + if (!profile) { + return null + } const { username } = profile return ( -
+
{showAt && '@'} {username}
) -} +} \ No newline at end of file