mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Update navbar component
This commit is contained in:
@@ -5,32 +5,33 @@ import { Wrapper } from './styles';
|
|||||||
import { Avatar, Link, Menu, Text } from '..';
|
import { Avatar, Link, Menu, Text } from '..';
|
||||||
import { Settings, Logout, Logo } from '../../assets';
|
import { Settings, Logout, Logo } from '../../assets';
|
||||||
|
|
||||||
type NavbarProps = {
|
const Navbar = () => {
|
||||||
withSidebar: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Navbar = ({ withSidebar }: NavbarProps) => {
|
|
||||||
const user = useReactiveVar(userVar);
|
const user = useReactiveVar(userVar);
|
||||||
const role = useReactiveVar(roleVar);
|
const role = useReactiveVar(roleVar);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper color={role} withSidebar={withSidebar}>
|
<Wrapper color={role}>
|
||||||
<Link href='/'>
|
<Link href='/'>
|
||||||
<Logo />
|
<Logo />
|
||||||
</Link>
|
</Link>
|
||||||
<div className='menu'></div>
|
<div className='menu'></div>
|
||||||
<div className='user' id='user'>
|
<div className='user' id='user'>
|
||||||
<Avatar text='H' color={role} />
|
<Avatar
|
||||||
|
text={
|
||||||
|
(user?.firstName && user?.firstName[0].toLocaleUpperCase()) ||
|
||||||
|
(role && role[0].toLocaleUpperCase()) ||
|
||||||
|
'C'
|
||||||
|
}
|
||||||
|
color={role}
|
||||||
|
/>
|
||||||
<Text variant='body' weight='bold'>
|
<Text variant='body' weight='bold'>
|
||||||
{user?.firstName} {user?.lastName}
|
{user?.firstName} {user?.lastName}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<Menu
|
<Menu
|
||||||
component='user'
|
component='user'
|
||||||
items={
|
items={[
|
||||||
role !== 'admin'
|
|
||||||
? [
|
|
||||||
{
|
{
|
||||||
icon: <Settings />,
|
icon: <Settings />,
|
||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
@@ -46,19 +47,7 @@ const Navbar = ({ withSidebar }: NavbarProps) => {
|
|||||||
},
|
},
|
||||||
avoid: true,
|
avoid: true,
|
||||||
},
|
},
|
||||||
]
|
]}
|
||||||
: [
|
|
||||||
{
|
|
||||||
icon: <Logout />,
|
|
||||||
label: 'Logout',
|
|
||||||
action: () => {
|
|
||||||
tokenVar(undefined);
|
|
||||||
history.push('/login');
|
|
||||||
},
|
|
||||||
avoid: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import styled from 'styled-components';
|
|||||||
|
|
||||||
type WrapperProps = {
|
type WrapperProps = {
|
||||||
color?: 'client' | 'productOwner' | 'developer' | 'admin';
|
color?: 'client' | 'productOwner' | 'developer' | 'admin';
|
||||||
withSidebar: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Wrapper = styled.div<WrapperProps>`
|
export const Wrapper = styled.div<WrapperProps>`
|
||||||
@@ -11,8 +10,7 @@ export const Wrapper = styled.div<WrapperProps>`
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr auto;
|
grid-template-columns: auto 1fr auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: ${({ withSidebar }) =>
|
padding: 15px 45px 15px 120px;
|
||||||
withSidebar ? '15px 45px 15px 120px' : '15px 45px'};
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user