mirror of
https://github.com/dergigi/boris.git
synced 2025-12-21 16:44:19 +01:00
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:
47
src/components/UserHeader.tsx
Normal file
47
src/components/UserHeader.tsx
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user