import { Box, Flex, HStack, Link, Text, VStack } from '@metafam/ds'; import { PlayerAvatar } from 'components/Player/PlayerAvatar'; import { PlayerFragmentFragment } from 'graphql/autogen/types'; import { getPersonalityInfo } from 'graphql/getPersonalityInfo'; import { PersonalityOption } from 'graphql/types'; import React, { useEffect } from 'react'; import { getPlayerDescription, getPlayerName, } from 'utils/playerHelpers'; import { FlexContainer } from '../../Container'; import { ProfileSection } from '../../ProfileSection'; import { ColorBar } from '../ColorBar'; import { PlayerContacts } from '../PlayerContacts'; import { PlayerBrightId } from './PlayerBrightId'; import { PlayerCollab } from './PlayerCollab'; const MAX_BIO_LENGTH = 240; type Props = { player: PlayerFragmentFragment }; export const PlayerHero: React.FC = ({ player }) => { const description = getPlayerDescription(player); const [show, setShow] = React.useState(description.length <= MAX_BIO_LENGTH); const [types, setTypes] = React.useState<{ [any: string]: PersonalityOption; }>(); const mask = player?.ColorAspect?.mask; const type = mask && types?.[mask]; const loadTypes = async () => { const { types: list } = await getPersonalityInfo(); setTypes(list); }; useEffect(() => { loadTypes(); }, []); return ( {getPlayerName(player)} {show ? description : `${description.substring(0, MAX_BIO_LENGTH - 9)}…`} {description.length > MAX_BIO_LENGTH && ( setShow((s) => !s)} pl={1} > Read {show ? 'less' : 'more'} )} {type && types && ( Color Disposition {type.description} )} {player.playerType?.title && ( {player.playerType.title} {player.playerType.description} )} ); };