sigit.io/src/components/username.tsx

47 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Typography, IconButton } from '@mui/material'
import { useSelector } from 'react-redux'
import { State } from '../store/rootReducer'
type Props = {
username: string
avatarContent: string
handleClick: (event: React.MouseEvent<HTMLElement>) => void
}
const Username = ({ username, avatarContent, handleClick }: Props) => {
const hexKey = useSelector((state: State) => state.auth.usersPubkey)
return (
<IconButton
2024-05-15 08:50:21 +00:00
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleClick}
2024-05-15 08:50:21 +00:00
color="inherit"
>
<img
src={avatarContent}
2024-05-15 08:50:21 +00:00
alt="user-avatar"
className="profile-image"
style={{
borderWidth: '3px',
borderStyle: hexKey ? 'solid' : 'none',
borderColor: `#${hexKey?.substring(0, 6)}`
}}
/>
<Typography
2024-05-15 08:50:21 +00:00
variant="h6"
sx={{
color: '#3e3e3e',
padding: '0 8px',
display: { xs: 'none', md: 'flex' }
}}
>
{username}
</Typography>
</IconButton>
)
}
export default Username