feat: add user dropdown in navbar

This commit is contained in:
Sonny
2024-05-14 13:11:10 +02:00
committed by Sonny
parent 243984ca66
commit c916b5870b
6 changed files with 47 additions and 34 deletions

View File

@@ -1,5 +1,8 @@
import styled from '@emotion/styled';
import { Link } from '@inertiajs/react';
import { IoIosLogOut } from 'react-icons/io';
import Dropdown from '~/components/common/dropdown/dropdown';
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
import ExternalLink from '~/components/common/external_link';
import RoundedImage from '~/components/common/rounded_image';
import UnstyledList from '~/components/common/unstyled/unstyled_list';
@@ -25,10 +28,16 @@ const NavList = styled(UnstyledList)<NavbarListDirection>(
gap: '1.5em',
justifyContent: right ? 'flex-end' : 'flex-start',
transition: theme.transition.delay,
'& li': {
display: 'flex',
alignItems: 'center',
},
})
);
const UserCard = styled.div({
padding: '0.25em 0.5em',
display: 'flex',
gap: '0.35em',
alignItems: 'center',
@@ -64,16 +73,22 @@ export default function Navbar() {
<Link href={PATHS.DASHBOARD}>Dashboard</Link>
</li>
<li>
<a href={PATHS.AUTH.LOGOUT}>
<UserCard>
<RoundedImage
src={user.avatarUrl}
width={22}
referrerPolicy="no-referrer"
/>
{user.nickName}
</UserCard>
</a>
<Dropdown
label={
<UserCard>
<RoundedImage
src={user.avatarUrl}
width={22}
referrerPolicy="no-referrer"
/>
{user.nickName}
</UserCard>
}
>
<DropdownItemLink href={PATHS.AUTH.LOGOUT} danger>
<IoIosLogOut /> Logout
</DropdownItemLink>
</Dropdown>
</li>
</>
) : (