feat(ott-205): menu (#27)
parent
60ea64a577
commit
35f1780a6a
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,4 @@ |
||||
export const authenticatedLexics = { |
||||
logout: 4306, |
||||
user_account: 12928, |
||||
} |
||||
@ -1,9 +1,52 @@ |
||||
import React from 'react' |
||||
|
||||
import { Wrapper, ToggleButton } from './styled' |
||||
import { PAGES } from 'config' |
||||
import { useToggle } from 'hooks' |
||||
import { useAuthStore } from 'features/AuthStore' |
||||
import { T9n } from 'features/T9n' |
||||
import { OutsideClick } from 'features/OutsideClick' |
||||
|
||||
export const Menu = () => ( |
||||
<Wrapper> |
||||
<ToggleButton /> |
||||
</Wrapper> |
||||
) |
||||
import { |
||||
Wrapper, |
||||
ToggleButton, |
||||
MenuList, |
||||
MenuItem, |
||||
Icon, |
||||
StyledLink, |
||||
linkStyles, |
||||
} from './styled' |
||||
|
||||
export const Menu = () => { |
||||
const { |
||||
close, |
||||
isOpen, |
||||
open, |
||||
} = useToggle() |
||||
const { logout } = useAuthStore() |
||||
|
||||
return ( |
||||
<OutsideClick onClick={close}> |
||||
<Wrapper> |
||||
<ToggleButton onClick={open} /> |
||||
{isOpen && ( |
||||
<MenuList> |
||||
<MenuItem> |
||||
<Icon image='userAccount' /> |
||||
<StyledLink to={PAGES.useraccount}> |
||||
<T9n t='user_account' /> |
||||
</StyledLink> |
||||
</MenuItem> |
||||
<MenuItem> |
||||
<Icon image='logout' /> |
||||
<T9n |
||||
t='logout' |
||||
onClick={logout} |
||||
customStyles={linkStyles} |
||||
/> |
||||
</MenuItem> |
||||
</MenuList> |
||||
)} |
||||
</Wrapper> |
||||
</OutsideClick> |
||||
) |
||||
} |
||||
|
||||
@ -1,16 +1,32 @@ |
||||
import React from 'react' |
||||
import styled from 'styled-components/macro' |
||||
import styled, { css } from 'styled-components/macro' |
||||
|
||||
import { useLexicsStore } from 'features/LexicsStore' |
||||
|
||||
const Text = styled.span`` |
||||
type TCustomStyles = { customStyles?: string | ReturnType<typeof css> } |
||||
|
||||
type Props = { |
||||
className?: string, |
||||
const Text = styled.span<TCustomStyles>` |
||||
${({ customStyles }) => customStyles} |
||||
` |
||||
|
||||
type TT9n = { |
||||
onClick?: () => void, |
||||
t: string | number, |
||||
} |
||||
} & TCustomStyles |
||||
|
||||
export const T9n = ({ className, t }: Props) => { |
||||
export const T9n = ({ |
||||
customStyles, |
||||
onClick, |
||||
t, |
||||
}: TT9n) => { |
||||
const { translate } = useLexicsStore() |
||||
return <Text className={className}>{translate(String(t))}</Text> |
||||
|
||||
return ( |
||||
<Text |
||||
onClick={onClick} |
||||
customStyles={customStyles} |
||||
> |
||||
{translate(String(t))} |
||||
</Text> |
||||
) |
||||
} |
||||
|
||||
Loading…
Reference in new issue