Ott 514 menus redesign (#217)

* refactor(#514): move score toggler and lang switcher to headers

* refactor(#514): header restyling

* refactor(#514): moved home link into Menus component
keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 0b0d6d4644
commit c917a8cd8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/config/lexics/indexLexics.tsx
  2. 12
      src/features/App/AuthenticatedApp.tsx
  3. 20
      src/features/App/UnauthenticatedApp.tsx
  4. 26
      src/features/Burger/index.tsx
  5. 53
      src/features/Burger/styled.tsx
  6. 25
      src/features/ExtendedSearchPage/components/DesktopHeader/index.tsx
  7. 7
      src/features/HeaderMobile/styled.tsx
  8. 56
      src/features/HomePage/components/Header/index.tsx
  9. 26
      src/features/LanguageSelect/index.tsx
  10. 10
      src/features/LanguageSelect/styled.tsx
  11. 4
      src/features/Login/styled.tsx
  12. 65
      src/features/Menu/index.tsx
  13. 85
      src/features/Menu/styled.tsx
  14. 32
      src/features/ProfileHeader/index.tsx
  15. 24
      src/features/ProfileHeader/styled.tsx
  16. 10
      src/features/Search/styled.tsx
  17. 10
      src/features/ToggleScore/styled.tsx
  18. 48
      src/features/Tooltip/index.tsx
  19. 2
      src/features/UserFavorites/TooltipBlock/styled.tsx

@ -37,6 +37,7 @@ export const indexLexics = {
select_language: 1005,
sport: 12993,
team: 658,
to_home: 13376,
tournament: 1009,
user_account: 12928,
watch_from_beginning: 13021,

@ -3,7 +3,6 @@ import {
Route,
Redirect,
Switch,
useRouteMatch,
} from 'react-router-dom'
import { indexLexics } from 'config/lexics/indexLexics'
@ -16,9 +15,8 @@ import { MatchPage } from 'features/MatchPage'
import { PlayerPage } from 'features/PlayerPage'
import { TournamentPage } from 'features/TournamentPage'
import { ExtendedSearchStore, ExtendedSearchPage } from 'features/ExtendedSearchPage'
import { LanguageSelect } from 'features/LanguageSelect'
import { UserAccount } from 'features/UserAccount'
import { ScoreStore, ToggleScore } from 'features/ToggleScore'
import { ScoreStore } from 'features/ToggleScore'
import { MainWrapper } from 'features/MainWrapper'
import { UserFavorites } from 'features/UserFavorites'
@ -29,17 +27,9 @@ import { FormStore } from 'features/FormStore'
export const AuthenticatedApp = () => {
useLexicsConfig(indexLexics)
const isMobile = useMediaQuery({ query: devices.tablet })
const isUserAccountPage = useRouteMatch(PAGES.useraccount)?.isExact || false
const isExtendedSearchPage = useRouteMatch(PAGES.extendedSearch)?.isExact || false
return (
<ScoreStore>
{
isMobile || isUserAccountPage
? null
: <LanguageSelect />
}
{isExtendedSearchPage ? null : <ToggleScore />}
<Switch>
<Route path={PAGES.useraccount}>
<UserAccountForm />

@ -1,10 +1,12 @@
import React, { Fragment } from 'react'
import React from 'react'
import {
Route,
Redirect,
Switch,
} from 'react-router-dom'
import styled from 'styled-components/macro'
import { PAGES } from 'config'
import { publicLexics } from 'config/lexics/public'
@ -12,13 +14,23 @@ import { useLexicsConfig } from 'features/LexicsStore'
import { Login } from 'features/Login'
import { Register } from 'features/Register'
import { LanguageSelect } from 'features/LanguageSelect'
import { HeaderStyled, HeaderGroup } from 'features/ProfileHeader/styled'
const Main = styled.main`
width: 100%;
`
export const UnauthenticatedApp = () => {
useLexicsConfig(publicLexics)
return (
<Fragment>
<LanguageSelect />
<Main>
<HeaderStyled>
<HeaderGroup />
<HeaderGroup>
<LanguageSelect />
</HeaderGroup>
</HeaderStyled>
<Switch>
<Route path={PAGES.login}>
<Login />
@ -30,6 +42,6 @@ export const UnauthenticatedApp = () => {
<Redirect to={PAGES.login} />
</Switch>
</Fragment>
</Main>
)
}

@ -1,26 +0,0 @@
import React from 'react'
import {
RowOne,
RowTwo,
RowThree,
StyledBurger,
} from './styled'
type Props = {
isOpen: boolean,
toggle: () => void,
}
export const Burger = (
{ isOpen, toggle }: Props,
) => (
<StyledBurger
open={isOpen}
onClick={toggle}
>
<RowOne />
<RowTwo />
<RowThree />
</StyledBurger>
)

@ -1,53 +0,0 @@
import styled from 'styled-components'
import { devices } from 'config/devices'
const BurgerRow = styled.div`
width: 19px;
height: 2px;
border-radius: 10px;
transition: all 0.3s linear;
position: relative;
transform-origin: 1px;
background: #666666;
@media ${devices.tablet} {
display: none;
}
`
export const RowOne = styled(BurgerRow)``
export const RowTwo = styled(BurgerRow)``
export const RowThree = styled(BurgerRow)``
export const StyledBurger = styled.div<{open: boolean}>`
display: flex;
flex-direction: column;
justify-content: space-around;
width: 22px;
height: 22px;
background: transparent;
border: none;
cursor: pointer;
padding: 2px;
z-index: 10;
${RowOne}{
transform: ${({ open }) => (open ? 'rotate(45deg)' : 'rotate(0)')};
}
${RowTwo}{
opacity: ${({ open }) => (open ? '0' : '1')};
}
${RowThree}{
transform: ${({ open }) => (open ? 'rotate(-45deg)' : 'rotate(0)')};
}
@media ${devices.tablet} {
background-size: 100%;
background-image: url(/images/userAccount.svg);
}
`

@ -1,23 +1,26 @@
import React from 'react'
import { PAGES } from 'config'
import { Menu } from 'features/Menu'
import { LanguageSelect } from 'features/LanguageSelect'
import {
Wrapper,
HeaderStyled,
HeaderGroup,
MenuWrapper,
HomeButtonLink,
} from 'features/ProfileHeader/styled'
import { Filters } from '../Filters'
export const DesktopHeader = () => (
<Wrapper>
<MenuWrapper>
<Menu />
<HomeButtonLink to={PAGES.home} />
</MenuWrapper>
<HeaderStyled>
<HeaderGroup>
<Filters />
</HeaderGroup>
<Filters />
</Wrapper>
<HeaderGroup>
<MenuWrapper>
<Menu />
</MenuWrapper>
<LanguageSelect />
</HeaderGroup>
</HeaderStyled>
)

@ -1,6 +1,6 @@
import styled from 'styled-components/macro'
import { Wrapper } from 'features/Menu/styled'
import { Nav } from 'features/Menu/styled'
export const HeaderMobileWrapper = styled.div`
width: 100%;
@ -36,13 +36,14 @@ export const HeaderIconsWrapper = styled.div`
justify-content: space-around;
min-width: 100px;
${Wrapper} {
${Nav} {
margin-right: 0;
}
`
export const IconFavWrapper = styled.div`
width: 20px;
width: 24px;
height: 20px;
background-image: url(/images/star-white.svg);
background-repeat: no-repeat;
`

@ -1,8 +1,9 @@
import React from 'react'
import { Menu } from 'features/Menu'
import { LanguageSelect } from 'features/LanguageSelect'
import { ToggleScore } from 'features/ToggleScore'
import { Search } from 'features/Search'
import {
DateFilter,
MatchStatusFilter,
@ -11,7 +12,8 @@ import {
} from 'features/HeaderFilters'
import {
Wrapper,
HeaderStyled,
HeaderGroup,
FilterWrapper,
SearchWrapper,
SportFilterWrapper,
@ -19,26 +21,32 @@ import {
} from 'features/ProfileHeader/styled'
export const Header = () => (
<Wrapper>
<MenuWrapper>
<Menu />
</MenuWrapper>
<SearchWrapper>
<Search />
</SearchWrapper>
<FilterWrapper>
<DateFilter />
</FilterWrapper>
<FilterWrapper>
<MatchStatusFilter />
</FilterWrapper>
<SportFilterWrapper>
<SportTypeFilter />
<TournamentFilter />
</SportFilterWrapper>
</Wrapper>
<HeaderStyled>
<HeaderGroup>
<SearchWrapper>
<Search />
</SearchWrapper>
<FilterWrapper>
<DateFilter />
</FilterWrapper>
<FilterWrapper>
<MatchStatusFilter />
</FilterWrapper>
<SportFilterWrapper>
<SportTypeFilter />
<TournamentFilter />
</SportFilterWrapper>
</HeaderGroup>
<HeaderGroup>
<ToggleScore />
<MenuWrapper>
<Menu />
</MenuWrapper>
<LanguageSelect />
</HeaderGroup>
</HeaderStyled>
)

@ -31,16 +31,16 @@ export const LanguageSelect = () => {
}
return (
<OutsideClick onClick={close}>
<Wrapper>
<WorldIcon
onClick={open}
active={isOpen}
title={translate('select_language')}
aria-expanded={isOpen}
aria-controls='langsList'
/>
{isOpen && (
<Wrapper>
<WorldIcon
onClick={open}
active={isOpen}
title={translate('select_language')}
aria-expanded={isOpen}
aria-controls='langsList'
/>
{isOpen && (
<OutsideClick onClick={close}>
<LangsList id='langsList'>
{
map(
@ -67,8 +67,8 @@ export const LanguageSelect = () => {
)
}
</LangsList>
)}
</Wrapper>
</OutsideClick>
</OutsideClick>
)}
</Wrapper>
)
}

@ -1,9 +1,9 @@
import styled from 'styled-components/macro'
export const Wrapper = styled.div`
position: absolute;
right: 31px;
top: 31px;
position: relative;
display: flex;
align-items: center;
`
type WorldIconProps = {
@ -40,8 +40,8 @@ export const LangsList = styled.ul`
background-color: #666666;
box-shadow: 0 2px 5px rgba(0,0,0,.5);
border-radius: 2px;
right: -16px;
top: 36px;
right: -92%;
top: calc(100% + 4px);
:before {
content: '';

@ -11,7 +11,7 @@ export const CenterBlock = styled.div`
flex-direction: column;
align-items: center;
justify-content: flex-start;
margin-top: 140px;
margin-top: 76px;
@media ${devices.laptop} {
margin-top: 177px;
@ -32,8 +32,6 @@ export const Form = styled.form<{forRegPage?: boolean}>`
@media ${devices.laptop} {
margin: ${({ forRegPage }) => (forRegPage ? '75px 0 140px 0' : '80px 0 140px 0')};
}
@media ${devices.mobile} {
width: auto;

@ -1,56 +1,49 @@
import React from 'react'
import { Link, useRouteMatch } from 'react-router-dom'
import { PAGES } from 'config'
import { useToggle } from 'hooks'
import { useAuthStore } from 'features/AuthStore'
import { T9n } from 'features/T9n'
import { OutsideClick } from 'features/OutsideClick'
import { Burger } from 'features/Burger'
import { Tooltip } from 'features/Tooltip'
import {
Wrapper,
Nav,
MenuList,
MenuItem,
Icon,
StyledLink,
Title,
} from './styled'
export const Menu = () => {
const {
close,
isOpen,
toggle,
} = useToggle()
const { logout } = useAuthStore()
const isHomePage = useRouteMatch(PAGES.home)?.isExact
return (
<OutsideClick onClick={close}>
<Wrapper>
<Burger
toggle={toggle}
isOpen={isOpen}
/>
{isOpen && (
<MenuList id='menuList'>
<Nav>
<MenuList id='menuList'>
{
!isHomePage && (
<MenuItem>
<Icon image='userAccount' />
<StyledLink to={PAGES.useraccount}>
<T9n t='user_account' />
</StyledLink>
<Tooltip lexic='to_home'>
<Link to={PAGES.home}>
<Icon image='home-btn-hover' />
</Link>
</Tooltip>
</MenuItem>
<MenuItem>
<Icon image='logout' />
<Title
t='logout'
onClick={logout}
/>
</MenuItem>
</MenuList>
)}
</Wrapper>
</OutsideClick>
)
}
<MenuItem>
<Tooltip lexic='user_account'>
<Link to={PAGES.useraccount}>
<Icon image='userAccount' />
</Link>
</Tooltip>
</MenuItem>
<MenuItem onClick={logout}>
<Tooltip lexic='logout'>
<Icon image='logout' />
</Tooltip>
</MenuItem>
</MenuList>
</Nav>
)
}

@ -1,67 +1,20 @@
import { Link } from 'react-router-dom'
import { devices } from 'config'
import styled, { css } from 'styled-components/macro'
import styled from 'styled-components/macro'
import { devices } from 'config/devices'
import { TooltipWrapper } from 'features/Tooltip'
import { T9n } from 'features/T9n'
export const Wrapper = styled.nav`
export const Nav = styled.nav`
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: auto;
height: 48px;
margin-left: 90px;
margin-right: 14px;
@media ${devices.desktop} {
margin-left: 16px;
margin-right: 10px;
}
`
export const MenuList = styled.ul`
position: absolute;
top: 50px;
left: -73px;
width: 288px;
border-radius: 2px;
background-color: #666;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
z-index: 1;
@media ${devices.laptop} {
top: 55px;
left: 0;
width: 288px;
}
@media ${devices.tablet} {
right: 0;
left: auto;
z-index: 3;
}
:before {
content: '';
position: absolute;
top: 0;
left: 82px;
width: 12px;
height: 12px;
transform: translate(-50%, -50%) rotate(45deg);
background-color: #666;
@media ${devices.laptop} {
left: 4%;
}
@media ${devices.tablet} {
left: 97%;
}
}
display: flex;
`
export const MenuItem = styled.li`
@ -71,25 +24,29 @@ export const MenuItem = styled.li`
line-height: 48px;
cursor: pointer;
:hover {
background-color: #999;
@media ${devices.tablet} {
height: 20px;
}
:hover ${TooltipWrapper} {
display: block;
}
`
export const Icon = styled.div<{ image: string }>`
width: 55px;
height: 100%;
background-image: url(/images/${({ image }) => `${image}.svg`});
background-repeat: no-repeat;
background-position: center;
`
opacity: 0.7;
export const linkStyles = css`
width: 100%;
font-size: 16px;
font-weight: bold;
color: #ccc;
`
export const Title = styled(T9n)`${linkStyles}`
&:hover {
opacity: 1;
}
export const StyledLink = styled(Link)`${linkStyles}`
@media ${devices.tablet} {
width: 34px;
background-size: contain;
}
`

@ -1,15 +1,17 @@
import React from 'react'
import { devices, PAGES } from 'config'
import { devices } from 'config'
import { Menu } from 'features/Menu'
import { LanguageSelect } from 'features/LanguageSelect'
import { ToggleScore } from 'features/ToggleScore'
import { Search } from 'features/Search'
import { HeaderMobile } from 'features/HeaderMobile'
import { useMediaQuery } from 'features/MediaQuery'
import {
Wrapper,
HomeButtonLink,
HeaderStyled,
HeaderGroup,
SearchWrapper,
MenuWrapper,
} from './styled'
@ -21,15 +23,21 @@ export const ProfileHeader = () => {
isMobile
? <HeaderMobile />
: (
<Wrapper>
<MenuWrapper>
<Menu />
<HomeButtonLink to={PAGES.home} />
</MenuWrapper>
<SearchWrapper>
<Search />
</SearchWrapper>
</Wrapper>
<HeaderStyled>
<HeaderGroup>
<SearchWrapper>
<Search />
</SearchWrapper>
</HeaderGroup>
<HeaderGroup>
<ToggleScore />
<MenuWrapper>
<Menu />
</MenuWrapper>
<LanguageSelect />
</HeaderGroup>
</HeaderStyled>
)
)
}

@ -1,24 +1,12 @@
import styled from 'styled-components/macro'
import { Link } from 'react-router-dom'
import { devices } from 'config/devices'
export const HomeButtonLink = styled(Link)`
width: 55px;
height: 48px;
background-image: url('/images/home-btn.svg');
background-repeat: no-repeat;
background-position: center;
&:hover {
background-image: url('/images/home-btn-hover.svg');
cursor:pointer;
}
`
export const Wrapper = styled.header`
export const HeaderStyled = styled.header`
display: flex;
padding-top: 16px;
justify-content: space-between;
height: 64px;
padding: 16px 29px 0 16px;
margin-bottom: 30px;
@media ${devices.laptop} {
@ -27,6 +15,10 @@ export const Wrapper = styled.header`
}
`
export const HeaderGroup = styled.div`
display: flex;
`
export const FilterWrapper = styled.div`
width: 288px;
height: 48px;

@ -67,22 +67,22 @@ export const Form = styled.form<{isMatch: boolean}>`
width: 348px;
position: ${({ isMatch }) => (isMatch ? 'static' : 'absolute')};
z-index: 4;
}
}
}
@media ${devices.tablet} {
width: 12px;
width: 30px;
:focus-within {
width: 252px;
top: -38px;
left: -240px;
}
left: -250px;
}
}
@media ${devices.mobile} {
:focus-within {
top: -33px;
}
}
}
${InputStyled} {

@ -4,13 +4,15 @@ import { T9n } from 'features/T9n'
import { devices } from 'config/devices'
export const Switch = styled.div`
position: absolute;
right: 99px;
top: 32px;
display: flex;
align-items: center;
cursor: pointer;
margin-right: 135px;
@media ${devices.laptop} {
margin-right: 12px;
}
@media ${devices.tablet} {
position: static;
}

@ -0,0 +1,48 @@
import type { ReactNode } from 'react'
import React, { Fragment } from 'react'
import styled from 'styled-components/macro'
import { devices } from 'config'
import { TooltipBlockWrapper } from 'features/UserFavorites/TooltipBlock/styled'
import { T9n } from 'features/T9n'
export const TooltipWrapper = styled(TooltipBlockWrapper)`
position: absolute;
top: calc(100% + 8px);
left: 50%;
transform: translateX(-50%);
padding: 8px 12px;
font-weight: normal;
font-size: 14px;
line-height: 18px;
text-align: center;
display: none;
@media ${devices.tablet} {
top: calc(100% + 16px);
}
&::before {
left: 50%;
transform: translateX(-50%);
}
`
type Props = {
children: ReactNode,
lexic: string,
}
export const Tooltip = ({
children,
lexic,
}: Props) => (
<Fragment>
<TooltipWrapper top={0}>
<T9n t={lexic} />
</TooltipWrapper>
{children}
</Fragment>
)

@ -2,7 +2,7 @@ import styled, { css } from 'styled-components/macro'
import { SportName } from 'features/Common'
export const TooltipBlockWrapper = styled.div<{top: number | null}>`
export const TooltipBlockWrapper = styled.div<{top?: number | null}>`
background-color: #fff;
border-radius: 10px;
padding: 12px;

Loading…
Cancel
Save