feat(ott-2066): add likes in event list

keep-around/6db5a027c13ec45cc1285984cb2439309d35e848
nevainero 4 years ago
parent f4d742a0bb
commit 6db5a027c1
  1. BIN
      public/images/event-like-bg.png
  2. 16
      public/images/like-active-icon.svg
  3. 37
      public/images/like-icon.svg
  4. 5
      src/features/MatchSidePlaylists/components/EventButton/index.tsx
  5. 37
      src/features/MatchSidePlaylists/components/TabEvents/index.tsx
  6. 26
      src/features/MatchSidePlaylists/components/TabEvents/styled.tsx
  7. 3
      src/requests/getMatchEvents.tsx

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@ -0,0 +1,16 @@
<svg width="15" height="16" viewBox="0 0 15 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.69687 0.963867C8.03553 0.963867 8.25793 2.35231 8.25793 2.35231C8.25793 2.35231 6.84452 6.18129 5.49257 7.20178C5.20287 7.50074 5.02144 7.83132 4.90732 8.10153C4.88098 8.16765 4.85757 8.23089 4.83708 8.28838C4.74637 8.46948 4.55323 8.74832 4.14062 8.99266L5.49257 14.7678C5.49257 14.7678 7.58488 15.0351 9.68303 14.992C10.5229 15.0581 11.4125 15.0638 12.1206 14.9144C14.5261 14.4113 13.9232 12.7642 13.9232 12.7642C15.2196 11.8069 14.4822 10.6111 14.4822 10.6111C15.6351 9.4296 14.5026 8.43786 14.5026 8.43786C14.5026 8.43786 15.1259 7.48349 14.3212 6.76196C13.3175 5.85933 10.5931 6.46013 10.5931 6.46013C10.4029 6.49175 10.201 6.53199 9.98444 6.58374C9.98444 6.58374 9.04217 7.01493 9.98444 4.20643C10.9296 1.39793 9.35821 0.963867 8.69687 0.963867Z" fill="white"/>
<path d="M8.69687 0.963867C8.03553 0.963867 8.25793 2.35231 8.25793 2.35231C8.25793 2.35231 6.84452 6.18129 5.49257 7.20178C5.20287 7.50074 5.02144 7.83132 4.90732 8.10153C4.88098 8.16765 4.85757 8.23089 4.83708 8.28838C4.74637 8.46948 4.55323 8.74832 4.14062 8.99266L5.49257 14.7678C5.49257 14.7678 7.58488 15.0351 9.68303 14.992C10.5229 15.0581 11.4125 15.0638 12.1206 14.9144C14.5261 14.4113 13.9232 12.7642 13.9232 12.7642C15.2196 11.8069 14.4822 10.6111 14.4822 10.6111C15.6351 9.4296 14.5026 8.43786 14.5026 8.43786C14.5026 8.43786 15.1259 7.48349 14.3212 6.76196C13.3175 5.85933 10.5931 6.46013 10.5931 6.46013C10.4029 6.49175 10.201 6.53199 9.98444 6.58374C9.98444 6.58374 9.04217 7.01493 9.98444 4.20643C10.9296 1.39793 9.35821 0.963867 8.69687 0.963867Z" fill="url(#paint0_linear_22484_182929)" fill-opacity="0.8"/>
<path d="M4.52121 14.351L3.49701 9.57055C3.43848 9.29746 3.15756 9.07324 2.87371 9.07324H0.918942L0.916016 14.8455H4.1086C4.39538 14.8483 4.57973 14.6241 4.52121 14.351Z" fill="white"/>
<path d="M4.52121 14.351L3.49701 9.57055C3.43848 9.29746 3.15756 9.07324 2.87371 9.07324H0.918942L0.916016 14.8455H4.1086C4.39538 14.8483 4.57973 14.6241 4.52121 14.351Z" fill="url(#paint1_linear_22484_182929)" fill-opacity="0.8"/>
<defs>
<linearGradient id="paint0_linear_22484_182929" x1="9.57029" y1="0.963867" x2="9.57029" y2="15.0363" gradientUnits="userSpaceOnUse">
<stop stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0"/>
</linearGradient>
<linearGradient id="paint1_linear_22484_182929" x1="2.72403" y1="9.07324" x2="2.72403" y2="14.8455" gradientUnits="userSpaceOnUse">
<stop stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 369 KiB

@ -15,6 +15,7 @@ import {
Title,
SubTitle,
EventTime,
EventLike,
} from '../TabEvents/styled'
type Props = {
@ -57,6 +58,7 @@ export const EventButton = ({
active={active}
disabled={disabled}
isHomeTeam={isHomeTeam}
like={event.like}
>
{avatarId && (
<Avatar
@ -68,6 +70,9 @@ export const EventButton = ({
/>
)}
<EventInfo>
{event.like && (
<EventLike src='/images/like-active-icon.svg' />
)}
<EventTime>
{clearTime}
</EventTime>

@ -1,17 +1,21 @@
import { Fragment, useMemo } from 'react'
import {
Fragment,
useCallback,
useMemo,
useState,
} from 'react'
import groupBy from 'lodash/groupBy'
import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map'
import reverse from 'lodash/reverse'
import filter from 'lodash/filter'
import values from 'lodash/values'
import type { Events, MatchInfo } from 'requests'
import { useToggle } from 'hooks'
import type { PlaylistOption } from 'features/MatchPage/types'
import { T9n } from 'features/T9n'
import type { PlaylistOption } from 'features/MatchPage/types'
import { useToggle } from 'hooks'
import type { Events, MatchInfo } from 'requests'
import { EventsList } from '../EventsList'
import {
@ -21,6 +25,7 @@ import {
HalfEvents,
Tabs,
Tab,
LikeToggle,
} from './styled'
type Props = {
@ -42,22 +47,33 @@ export const TabEvents = ({
open: setReversed,
} = useToggle()
const [likesOnly, setLikesOnly] = useState(false)
const likeToggle = useCallback(() => setLikesOnly((state) => !state), [])
const likeImage = likesOnly ? '/images/like-active-icon.svg' : '/images/like-icon.svg'
const isLiveMatch = profile?.live
const reverseStatus = (areEventsReversed || isLiveMatch) && (areEventsReversed !== isLiveMatch)
const activeStatus = isLiveMatch ? areEventsReversed : !areEventsReversed
const reversedGroupEvents = useMemo(() => {
const eventsList = likesOnly ? filter(events, 'like') : events
const groupedEvents = values(
groupBy(
reverseStatus
? reverse([...events])
: events,
? reverse([...eventsList])
: eventsList,
({ h }) => h,
),
)
return reverseStatus
? reverse(groupedEvents)
: groupedEvents
}, [events, reverseStatus])
const activeStatus = isLiveMatch ? areEventsReversed : !areEventsReversed
}, [
events,
likesOnly,
reverseStatus,
])
if (!profile) return null
return (
@ -84,6 +100,7 @@ export const TabEvents = ({
<T9n t='from_end_match' />
</Tab>
</Tabs>
<LikeToggle src={likeImage} onClick={likeToggle} />
<HalfList>
{
map(reversedGroupEvents, (halfEvents, idx) => {

@ -14,6 +14,7 @@ export const Wrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
position: relative;
`
export const HalfList = styled.ul`
@ -86,6 +87,7 @@ export const Avatar = styled(ProfileLogo)<AvatarProps>`
export const EventInfo = styled.div`
display: flex;
width: 100%;
position: relative;
`
export const EventDesc = styled.div`
@ -117,6 +119,14 @@ export const SubTitle = styled(Title)`
margin-top: 2px;
`
export const EventLike = styled.img`
position: absolute;
left: -14px;
top: 2px;
width: 10px;
height: 10px;
`
export const EventTime = styled(Title)`
font-size: 14px;
font-weight: normal;
@ -139,6 +149,15 @@ export const Tab = styled(TabBase)`
}
`
export const LikeToggle = styled.img`
position: absolute;
right: 0;
top: 9px;
width: 15px;
height: 15px;
cursor: pointer;
`
export const BlockTitle = styled(BlockTitleBase)`
text-align: center;
width: 100%;
@ -147,9 +166,16 @@ export const BlockTitle = styled(BlockTitleBase)`
type ButtonProps = {
isHomeTeam: boolean,
like?: boolean,
}
export const Button = styled(ButtonBase)<ButtonProps>`
${({ like }) => (
like ? css`
background: url(/images/event-like-bg.png);
` : ''
)}
&:hover ${EventDesc} {
overflow: visible;
}

@ -27,6 +27,9 @@ export type Event = Episode & {
/** event lexic */
l: number,
/** like */
like?: boolean,
/** event id */
n: number,

Loading…
Cancel
Save