From 0e816563413fb7e74aef0dfb294a8eb2c6d54762 Mon Sep 17 00:00:00 2001 From: Armen <35077035+Armen9393@users.noreply.github.com> Date: Wed, 2 Sep 2020 17:59:58 +0300 Subject: [PATCH] Ott 325 many favorites bug (#119) --- src/features/PlayerPage/index.tsx | 2 - src/features/TeamPage/index.tsx | 2 - src/features/TournamentPage/index.tsx | 2 - .../UserFavorites/TooltipBlock/index.tsx | 4 +- .../UserFavorites/TooltipBlock/styled.tsx | 7 +- src/features/UserFavorites/index.tsx | 78 +++++++++++-------- src/features/UserFavorites/styled.tsx | 23 +++--- 7 files changed, 70 insertions(+), 48 deletions(-) diff --git a/src/features/PlayerPage/index.tsx b/src/features/PlayerPage/index.tsx index 40aa6a34..4587151f 100644 --- a/src/features/PlayerPage/index.tsx +++ b/src/features/PlayerPage/index.tsx @@ -1,7 +1,6 @@ import React, { Fragment } from 'react' import { ProfileTypes } from 'config' -import { UserFavorites } from 'features/UserFavorites' import { ProfileCard } from 'features/ProfileCard' import { Matches } from 'features/Matches' @@ -16,7 +15,6 @@ export const PlayerPage = () => { return ( - { return ( - { return ( - ( - + {playerFirstName && playerLastName && `${playerFirstName} ${playerLastName}`} diff --git a/src/features/UserFavorites/TooltipBlock/styled.tsx b/src/features/UserFavorites/TooltipBlock/styled.tsx index 341afa74..e20778a4 100644 --- a/src/features/UserFavorites/TooltipBlock/styled.tsx +++ b/src/features/UserFavorites/TooltipBlock/styled.tsx @@ -1,10 +1,15 @@ import styled, { css } from 'styled-components/macro' -export const TooltipBlockWrapper = styled.div` +export const TooltipBlockWrapper = styled.div<{top: number | null}>` background-color: #fff; border-radius: 10px; padding: 12px; white-space: nowrap; + position: fixed; + top: ${({ top }) => top && `${top + 50}px`}; + left: 40px; + z-index: 5; + &::before { position: absolute; top: -8px; diff --git a/src/features/UserFavorites/index.tsx b/src/features/UserFavorites/index.tsx index 77054480..f9cfad91 100644 --- a/src/features/UserFavorites/index.tsx +++ b/src/features/UserFavorites/index.tsx @@ -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 { FavoritesActions } from 'requests' import { handleImageError } from 'helpers' @@ -20,6 +20,7 @@ import { ExclamationSign, FavoriteModal, Text, + ScrollWrapper, } from './styled' export const UserFavorites = () => { @@ -30,43 +31,58 @@ export const UserFavorites = () => { userFavorites, } = useUserFavoritesStore() + const [position, setPosition] = useState(null) + + const getPosition = (event: MouseEvent | FocusEvent) => { + if (event.currentTarget) { + setPosition(event.currentTarget.getBoundingClientRect().top) + } + } + return ( - { - map(userFavorites, (item) => ( - - addRemoveFavorite({ - action: FavoritesActions.REMOVE, - id: item.id, - sport: item.sport, - type: item.type, - })} - /> - - - handleImageError({ - e, + + { + map(userFavorites, (item) => ( + + addRemoveFavorite({ + action: FavoritesActions.REMOVE, + id: item.id, sport: item.sport, type: item.type, })} /> - - - )) - } + + + handleImageError({ + e, + sport: item.sport, + type: item.type, + })} + /> + + + )) + } +