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 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 = () => ( |
import { |
||||||
<Wrapper> |
Wrapper, |
||||||
<ToggleButton /> |
ToggleButton, |
||||||
</Wrapper> |
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 React from 'react' |
||||||
import styled from 'styled-components/macro' |
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
import { useLexicsStore } from 'features/LexicsStore' |
import { useLexicsStore } from 'features/LexicsStore' |
||||||
|
|
||||||
const Text = styled.span`` |
type TCustomStyles = { customStyles?: string | ReturnType<typeof css> } |
||||||
|
|
||||||
type Props = { |
const Text = styled.span<TCustomStyles>` |
||||||
className?: string, |
${({ customStyles }) => customStyles} |
||||||
|
` |
||||||
|
|
||||||
|
type TT9n = { |
||||||
|
onClick?: () => void, |
||||||
t: string | number, |
t: string | number, |
||||||
} |
} & TCustomStyles |
||||||
|
|
||||||
export const T9n = ({ className, t }: Props) => { |
export const T9n = ({ |
||||||
|
customStyles, |
||||||
|
onClick, |
||||||
|
t, |
||||||
|
}: TT9n) => { |
||||||
const { translate } = useLexicsStore() |
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