|
|
|
|
@ -1,11 +1,17 @@ |
|
|
|
|
import { isMobileDevice } from 'config/userAgent' |
|
|
|
|
import type { ComponentProps } from 'react' |
|
|
|
|
import { createPortal } from 'react-dom' |
|
|
|
|
|
|
|
|
|
import { isMobileDevice } from 'config' |
|
|
|
|
|
|
|
|
|
import { getTeamAbbr } from 'helpers' |
|
|
|
|
|
|
|
|
|
import { Tooltip } from 'features/Tooltip' |
|
|
|
|
import { useModalRoot } from 'hooks' |
|
|
|
|
|
|
|
|
|
import { T9n } from 'features/T9n' |
|
|
|
|
import { useMatchPageStore } from 'features/MatchPage/store' |
|
|
|
|
import { Name } from 'features/Name' |
|
|
|
|
import { TCircleAnimation, TSetCircleAnimation } from 'features/CircleAnimationBar' |
|
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
|
|
|
|
|
|
import { Tabs } from './config' |
|
|
|
|
import { useTabStats } from './hooks' |
|
|
|
|
@ -20,27 +26,44 @@ import { |
|
|
|
|
Switch, |
|
|
|
|
SwitchTitle, |
|
|
|
|
SwitchButton, |
|
|
|
|
Tooltip, |
|
|
|
|
TabTitle, |
|
|
|
|
} from './styled' |
|
|
|
|
|
|
|
|
|
const tabPanes = { |
|
|
|
|
[Tabs.TEAMS]: TeamsStatsTable, |
|
|
|
|
[Tabs.TEAM1]: PlayersTable, |
|
|
|
|
[Tabs.TEAM2]: PlayersTable, |
|
|
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
|
|
|
[Tabs.TEAM1]: (props: ComponentProps<typeof PlayersTable>) => <PlayersTable {...props} />, |
|
|
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
|
|
|
[Tabs.TEAM2]: (props: ComponentProps<typeof PlayersTable>) => <PlayersTable {...props} />, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const TabStats = () => { |
|
|
|
|
type Props = { |
|
|
|
|
circleAnimation?: TCircleAnimation, |
|
|
|
|
setCircleAnimation?: TSetCircleAnimation, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const TabStats = ({ circleAnimation, setCircleAnimation }: Props) => { |
|
|
|
|
const { |
|
|
|
|
isFinalStatsType, |
|
|
|
|
isTooltipShown, |
|
|
|
|
isVisibleTeam1PlayersTab, |
|
|
|
|
isVisibleTeam2PlayersTab, |
|
|
|
|
isVisibleTeamsTab, |
|
|
|
|
onMouseLeave, |
|
|
|
|
onMouseOver, |
|
|
|
|
selectedTab, |
|
|
|
|
setSelectedTab, |
|
|
|
|
switchButtonTooltipLexic, |
|
|
|
|
switchTitleLexic, |
|
|
|
|
toggleStatsType, |
|
|
|
|
tooltipLexic, |
|
|
|
|
tooltipStyle, |
|
|
|
|
tooltipText, |
|
|
|
|
} = useTabStats() |
|
|
|
|
const { profile: matchProfile } = useMatchPageStore() |
|
|
|
|
const { suffix, translate } = useLexicsStore() |
|
|
|
|
|
|
|
|
|
const modalRoot = useModalRoot() |
|
|
|
|
|
|
|
|
|
const TabPane = tabPanes[selectedTab] |
|
|
|
|
|
|
|
|
|
@ -57,7 +80,9 @@ export const TabStats = () => { |
|
|
|
|
aria-pressed={selectedTab === Tabs.TEAMS} |
|
|
|
|
onClick={() => setSelectedTab(Tabs.TEAMS)} |
|
|
|
|
> |
|
|
|
|
<T9n t='team' /> |
|
|
|
|
<TabTitle> |
|
|
|
|
<T9n t='team' /> |
|
|
|
|
</TabTitle> |
|
|
|
|
</Tab> |
|
|
|
|
)} |
|
|
|
|
{isVisibleTeam1PlayersTab && ( |
|
|
|
|
@ -65,11 +90,25 @@ export const TabStats = () => { |
|
|
|
|
aria-pressed={selectedTab === Tabs.TEAM1} |
|
|
|
|
onClick={() => setSelectedTab(Tabs.TEAM1)} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={{ |
|
|
|
|
name_eng: team1.abbrev_eng || getTeamAbbr(team1.name_eng), |
|
|
|
|
name_rus: team1.abbrev_rus || getTeamAbbr(team1.name_rus), |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<TabTitle |
|
|
|
|
onMouseOver={isMobileDevice |
|
|
|
|
? undefined |
|
|
|
|
: onMouseOver({ |
|
|
|
|
anchorId: 'team1Tab', |
|
|
|
|
horizontalPosition: 'left', |
|
|
|
|
indent: 25, |
|
|
|
|
tooltipText: team1[`name_${suffix}`], |
|
|
|
|
})} |
|
|
|
|
onMouseLeave={isMobileDevice ? undefined : onMouseLeave} |
|
|
|
|
> |
|
|
|
|
<Name |
|
|
|
|
id='team1Tab' |
|
|
|
|
nameObj={{ |
|
|
|
|
name_eng: team1.abbrev_eng || getTeamAbbr(team1.name_eng), |
|
|
|
|
name_rus: team1.abbrev_rus || getTeamAbbr(team1.name_rus), |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
</TabTitle> |
|
|
|
|
</Tab> |
|
|
|
|
)} |
|
|
|
|
{isVisibleTeam2PlayersTab && ( |
|
|
|
|
@ -77,27 +116,56 @@ export const TabStats = () => { |
|
|
|
|
aria-pressed={selectedTab === Tabs.TEAM2} |
|
|
|
|
onClick={() => setSelectedTab(Tabs.TEAM2)} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={{ |
|
|
|
|
name_eng: team2.abbrev_eng || getTeamAbbr(team2.name_eng), |
|
|
|
|
name_rus: team2.abbrev_rus || getTeamAbbr(team2.name_rus), |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<TabTitle |
|
|
|
|
onMouseOver={isMobileDevice |
|
|
|
|
? undefined |
|
|
|
|
: onMouseOver({ |
|
|
|
|
anchorId: 'team2Tab', |
|
|
|
|
horizontalPosition: 'left', |
|
|
|
|
indent: 25, |
|
|
|
|
tooltipText: team2[`name_${suffix}`], |
|
|
|
|
})} |
|
|
|
|
onMouseLeave={isMobileDevice ? undefined : onMouseLeave} |
|
|
|
|
> |
|
|
|
|
<Name |
|
|
|
|
id='team2Tab' |
|
|
|
|
nameObj={{ |
|
|
|
|
name_eng: team2.abbrev_eng || getTeamAbbr(team2.name_eng), |
|
|
|
|
name_rus: team2.abbrev_rus || getTeamAbbr(team2.name_rus), |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
</TabTitle> |
|
|
|
|
</Tab> |
|
|
|
|
)} |
|
|
|
|
</TabList> |
|
|
|
|
<Switch> |
|
|
|
|
<SwitchTitle t={switchTitleLexic} /> |
|
|
|
|
<SwitchButton |
|
|
|
|
id='switchButton' |
|
|
|
|
isFinalStatsType={isFinalStatsType} |
|
|
|
|
onClick={toggleStatsType} |
|
|
|
|
> |
|
|
|
|
{!isMobileDevice && <Tooltip lexic={tooltipLexic} />} |
|
|
|
|
</SwitchButton> |
|
|
|
|
onMouseOver={isMobileDevice |
|
|
|
|
? undefined |
|
|
|
|
: onMouseOver({ |
|
|
|
|
anchorId: 'switchButton', |
|
|
|
|
horizontalPosition: 'right', |
|
|
|
|
tooltipText: translate(switchButtonTooltipLexic), |
|
|
|
|
})} |
|
|
|
|
onMouseLeave={isMobileDevice ? undefined : onMouseLeave} |
|
|
|
|
/> |
|
|
|
|
</Switch> |
|
|
|
|
</Header> |
|
|
|
|
<TabPane |
|
|
|
|
teamId={selectedTab === Tabs.TEAM1 ? team1.id : team2.id} |
|
|
|
|
circleAnimation={circleAnimation} |
|
|
|
|
setCircleAnimation={setCircleAnimation} |
|
|
|
|
/> |
|
|
|
|
{isTooltipShown && modalRoot.current && createPortal( |
|
|
|
|
<Tooltip style={tooltipStyle}> |
|
|
|
|
{tooltipText} |
|
|
|
|
</Tooltip>, |
|
|
|
|
modalRoot.current, |
|
|
|
|
)} |
|
|
|
|
</Container> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|