refactor(ui): move user info to top-right app header

- Create UserHeader component to display user info and logout button
- Move 'Logged in as: user' from sidebar to app-header in top-right
- Remove user info display from BookmarkList and Bookmarks components
- Simplify bookmarks-header layout (only contains collapse button now)
- Update CSS to display user info and logout button inline with proper spacing
This commit is contained in:
Gigi
2025-10-03 01:56:16 +02:00
parent 448c4dac1c
commit e644f07828
5 changed files with 68 additions and 85 deletions

View File

@@ -0,0 +1,47 @@
import React from 'react'
import { Hooks } from 'applesauce-react'
import { useEventModel } from 'applesauce-react/hooks'
import { Models } from 'applesauce-core'
import { faRightFromBracket } from '@fortawesome/free-solid-svg-icons'
import IconButton from './IconButton'
interface UserHeaderProps {
onLogout: () => void
}
const UserHeader: React.FC<UserHeaderProps> = ({ onLogout }) => {
const activeAccount = Hooks.useActiveAccount()
const profile = useEventModel(Models.ProfileModel, activeAccount ? [activeAccount.pubkey] : null)
const formatUserDisplay = () => {
if (!activeAccount) return 'Unknown User'
if (profile?.name) {
return profile.name
}
if (profile?.display_name) {
return profile.display_name
}
if (profile?.nip05) {
return profile.nip05
}
return `${activeAccount.pubkey.slice(0, 8)}...${activeAccount.pubkey.slice(-8)}`
}
return (
<div className="app-header">
<p className="user-info">Logged in as: {formatUserDisplay()}</p>
<IconButton
icon={faRightFromBracket}
onClick={onLogout}
title="Logout"
ariaLabel="Logout"
variant="ghost"
/>
</div>
)
}
export default UserHeader