Ott 325 many favorites bug (#119)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Armen 5 years ago committed by GitHub
parent dca47f25b9
commit 0e81656341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/features/PlayerPage/index.tsx
  2. 2
      src/features/TeamPage/index.tsx
  3. 2
      src/features/TournamentPage/index.tsx
  4. 4
      src/features/UserFavorites/TooltipBlock/index.tsx
  5. 7
      src/features/UserFavorites/TooltipBlock/styled.tsx
  6. 78
      src/features/UserFavorites/index.tsx
  7. 23
      src/features/UserFavorites/styled.tsx

@ -1,7 +1,6 @@
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import { ProfileTypes } from 'config' import { ProfileTypes } from 'config'
import { UserFavorites } from 'features/UserFavorites'
import { ProfileCard } from 'features/ProfileCard' import { ProfileCard } from 'features/ProfileCard'
import { Matches } from 'features/Matches' import { Matches } from 'features/Matches'
@ -16,7 +15,6 @@ export const PlayerPage = () => {
return ( return (
<Fragment> <Fragment>
<UserFavorites />
<ProfileCard <ProfileCard
profileType={ProfileTypes.PLAYERS} profileType={ProfileTypes.PLAYERS}
name={name} name={name}

@ -2,7 +2,6 @@ import React, { Fragment } from 'react'
import { ProfileTypes } from 'config' import { ProfileTypes } from 'config'
import { UserFavorites } from 'features/UserFavorites'
import { ProfileCard } from 'features/ProfileCard' import { ProfileCard } from 'features/ProfileCard'
import { Matches } from 'features/Matches' import { Matches } from 'features/Matches'
@ -18,7 +17,6 @@ export const TeamPage = () => {
return ( return (
<Fragment> <Fragment>
<UserFavorites />
<Content> <Content>
<ProfileCard <ProfileCard
profileType={ProfileTypes.TEAMS} profileType={ProfileTypes.TEAMS}

@ -2,7 +2,6 @@ import React, { Fragment } from 'react'
import { ProfileTypes } from 'config' import { ProfileTypes } from 'config'
import { UserFavorites } from 'features/UserFavorites'
import { ProfileCard } from 'features/ProfileCard' import { ProfileCard } from 'features/ProfileCard'
import { Matches } from 'features/Matches' import { Matches } from 'features/Matches'
@ -18,7 +17,6 @@ export const TournamentPage = () => {
return ( return (
<Fragment> <Fragment>
<UserFavorites />
<Content> <Content>
<ProfileCard <ProfileCard
profileType={ProfileTypes.TOURNAMENTS} profileType={ProfileTypes.TOURNAMENTS}

@ -19,6 +19,7 @@ type TooltipBlockProps = {
playerTeamName?: string, playerTeamName?: string,
sport: SportTypes, sport: SportTypes,
teamName?: string, teamName?: string,
topPosition: number | null,
} }
export const TooltipBlock = ({ export const TooltipBlock = ({
@ -28,8 +29,9 @@ export const TooltipBlock = ({
playerTeamName, playerTeamName,
sport, sport,
teamName, teamName,
topPosition,
}: TooltipBlockProps) => ( }: TooltipBlockProps) => (
<TooltipBlockWrapper> <TooltipBlockWrapper top={topPosition}>
<TooltipBlockItem> <TooltipBlockItem>
{playerFirstName && playerLastName && `${playerFirstName} ${playerLastName}`} {playerFirstName && playerLastName && `${playerFirstName} ${playerLastName}`}
</TooltipBlockItem> </TooltipBlockItem>

@ -1,10 +1,15 @@
import styled, { css } from 'styled-components/macro' import styled, { css } from 'styled-components/macro'
export const TooltipBlockWrapper = styled.div` export const TooltipBlockWrapper = styled.div<{top: number | null}>`
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
padding: 12px; padding: 12px;
white-space: nowrap; white-space: nowrap;
position: fixed;
top: ${({ top }) => top && `${top + 50}px`};
left: 40px;
z-index: 5;
&::before { &::before {
position: absolute; position: absolute;
top: -8px; top: -8px;

@ -1,7 +1,7 @@
import React from 'react' import type { MouseEvent, FocusEvent } from 'react'
import React, { useState } from 'react'
import map from 'lodash/map' import map from 'lodash/map'
import { FavoritesActions } from 'requests' import { FavoritesActions } from 'requests'
import { handleImageError } from 'helpers' import { handleImageError } from 'helpers'
@ -20,6 +20,7 @@ import {
ExclamationSign, ExclamationSign,
FavoriteModal, FavoriteModal,
Text, Text,
ScrollWrapper,
} from './styled' } from './styled'
export const UserFavorites = () => { export const UserFavorites = () => {
@ -30,43 +31,58 @@ export const UserFavorites = () => {
userFavorites, userFavorites,
} = useUserFavoritesStore() } = useUserFavoritesStore()
const [position, setPosition] = useState<number | null>(null)
const getPosition = (event: MouseEvent<HTMLDivElement> | FocusEvent<HTMLDivElement>) => {
if (event.currentTarget) {
setPosition(event.currentTarget.getBoundingClientRect().top)
}
}
return ( return (
<UserSportFavWrapper> <UserSportFavWrapper>
<UserSportFavLogoWrapper height={12} width={52} /> <UserSportFavLogoWrapper height={12} width={52} />
<UserSportFavStar /> <UserSportFavStar />
{ <ScrollWrapper>
map(userFavorites, (item) => ( {
<UserSportFavItemLogoWrapper key={`${item.type}_${item.sport}_${item.id}`}> map(userFavorites, (item) => (
<UserSportFavXWrapper <UserSportFavItemLogoWrapper
onClick={() => addRemoveFavorite({ onFocus={getPosition}
action: FavoritesActions.REMOVE, onMouseOver={getPosition}
id: item.id, key={`${item.type}_${item.sport}_${item.id}`}
sport: item.sport, >
type: item.type, <UserSportFavXWrapper
})} onClick={() => addRemoveFavorite({
/> action: FavoritesActions.REMOVE,
<TooltipBlock id: item.id,
countryName={item.countryName}
teamName={item.name}
playerTeamName={item.teamName}
playerFirstName={item.firstname}
playerLastName={item.lastname}
sport={item.sport}
/>
<StyledLink to={item.profileUrl} target='_blank'>
<UserSportFavImgWrapper
src={item.profileLogo}
alt={item.name}
onError={(e) => handleImageError({
e,
sport: item.sport, sport: item.sport,
type: item.type, type: item.type,
})} })}
/> />
</StyledLink> <TooltipBlock
</UserSportFavItemLogoWrapper> topPosition={position}
)) countryName={item.countryName}
} teamName={item.name}
playerTeamName={item.teamName}
playerFirstName={item.firstname}
playerLastName={item.lastname}
sport={item.sport}
/>
<StyledLink to={item.profileUrl} target='_blank'>
<UserSportFavImgWrapper
src={item.profileLogo}
alt={item.name}
onError={(e) => handleImageError({
e,
sport: item.sport,
type: item.type,
})}
/>
</StyledLink>
</UserSportFavItemLogoWrapper>
))
}
</ScrollWrapper>
<Modal <Modal
isOpen={isOpen} isOpen={isOpen}
close={close} close={close}

@ -4,23 +4,31 @@ import styled from 'styled-components/macro'
import { Logo } from 'features/Logo' import { Logo } from 'features/Logo'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { customScrollbar } from 'features/Common'
import { TooltipBlockWrapper } from './TooltipBlock/styled' import { TooltipBlockWrapper } from './TooltipBlock/styled'
export const StyledLink = styled(Link)`` export const StyledLink = styled(Link)``
export const UserSportFavWrapper = styled.aside` export const UserSportFavWrapper = styled.aside`
display: flex;
flex-direction: column;
align-items: center;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
background: rgba(255, 255, 255, 0.1);
z-index: 1;
`
export const ScrollWrapper = styled.div`
width: 80px; width: 80px;
height: auto;
display: flex; display: flex;
flex: 0 0 auto; flex-direction: column;
flex-direction:column;
align-items: center; align-items: center;
background: rgba(255, 255, 255, 0.1); overflow-y: auto;
z-index: 2; ${customScrollbar}
` `
export const UserSportFavLogoWrapper = styled(Logo)` export const UserSportFavLogoWrapper = styled(Logo)`
@ -42,22 +50,18 @@ export const UserSportFavXWrapper = styled.span`
export const UserSportFavItemLogoWrapper = styled.div` export const UserSportFavItemLogoWrapper = styled.div`
position: relative; position: relative;
width: 48px; width: 48px;
min-height: 48px;
height: 48px; height: 48px;
border-radius: 50%; border-radius: 50%;
padding: 5px; padding: 5px;
background-color: #fff; background-color: #fff;
margin-bottom: 16px; margin-bottom: 16px;
${UserSportFavXWrapper} { ${UserSportFavXWrapper} {
display: none; display: none;
} }
${TooltipBlockWrapper} { ${TooltipBlockWrapper} {
display: none; display: none;
position: absolute;
left: 40%;
top: 120%;
z-index: 2;
} }
&:hover { &:hover {
@ -81,6 +85,7 @@ export const UserSportFavImgWrapper = styled.img`
export const UserSportFavStar = styled.div` export const UserSportFavStar = styled.div`
width: 48px; width: 48px;
height: 48px; height: 48px;
min-height: 48px;
border-radius: 50%; border-radius: 50%;
background: #3f3f3f url('/images/sportFavStar.png') no-repeat center; background: #3f3f3f url('/images/sportFavStar.png') no-repeat center;
margin-bottom: 16px; margin-bottom: 16px;

Loading…
Cancel
Save