mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
169 lines
5.1 KiB
TypeScript
169 lines
5.1 KiB
TypeScript
import {
|
|
Dashboard,
|
|
Flex,
|
|
HStack,
|
|
LogOut,
|
|
Menu,
|
|
MenuButton,
|
|
MenuItem,
|
|
MenuList,
|
|
Profile,
|
|
Stack,
|
|
Text,
|
|
} from '@metafam/ds';
|
|
import { ConnectKitButton } from 'connectkit';
|
|
import { useAccount } from 'wagmi';
|
|
|
|
import { MetaLink } from '#components/Link';
|
|
import { PlayerAvatar } from '#components/Player/PlayerAvatar';
|
|
import { usePlayerHydrationContext } from '#contexts/PlayerHydrationContext';
|
|
import { useMounted, useUser, useWeb3 } from '#lib/hooks';
|
|
import { usePlayerName } from '#lib/hooks/player/usePlayerName';
|
|
import { usePlayerURL } from '#lib/hooks/player/usePlayerURL';
|
|
|
|
import { XPSeedsBalance } from './XPSeedsBalance';
|
|
|
|
// Display player XP and Seed
|
|
export const MegaMenuFooter = () => {
|
|
const { isConnected, isConnecting } = useAccount();
|
|
const { disconnect } = useWeb3();
|
|
const { fetching, user } = useUser();
|
|
const name = usePlayerName(user);
|
|
const linkURL = usePlayerURL(user);
|
|
const { hydratedPlayer: player } = usePlayerHydrationContext();
|
|
const mounted = useMounted();
|
|
|
|
return (
|
|
<Flex
|
|
align="center"
|
|
display={{ base: 'flex', lg: 'none' }}
|
|
pos="fixed"
|
|
left={0}
|
|
bottom={0}
|
|
justify={user ? 'space-between' : 'center'}
|
|
w="full"
|
|
h={20}
|
|
bg="rgba(0, 0, 0, 0.75)"
|
|
borderColor="#2B2244"
|
|
px={4}
|
|
backdropFilter="blur(10px)"
|
|
>
|
|
{isConnected && !!user && !fetching && !isConnecting ? (
|
|
<>
|
|
<Menu>
|
|
<MenuButton
|
|
bg="transparent"
|
|
aria-label="Menu Options"
|
|
transition="filter 2.75s"
|
|
_focus={{ outline: 'none' }}
|
|
_hover={{ filter: 'brightness(1.1)' }}
|
|
_active={{ filter: 'hue-rotate(30deg)' }}
|
|
>
|
|
<Flex>
|
|
<PlayerAvatar player={player} size="md" />
|
|
<Stack my={2} ml={2} justify="center">
|
|
<Text
|
|
fontSize={player.rank ? 14 : 22}
|
|
fontWeight="semibold"
|
|
m={0}
|
|
p={0}
|
|
lineHeight={1}
|
|
>
|
|
{name}
|
|
</Text>
|
|
{player.rank && (
|
|
<Text fontSize={12} m={0} p={0} lineHeight={1}>
|
|
{player.rank}
|
|
</Text>
|
|
)}
|
|
</Stack>
|
|
</Flex>
|
|
</MenuButton>
|
|
<MenuList
|
|
color="white"
|
|
boxShadow="2xl"
|
|
borderRadius="md"
|
|
bg="linear-gradient(180deg, rgba(42, 31, 71, 0.9) 6.18%, rgba(17, 3, 32, 0.86) 140%)"
|
|
border={0}
|
|
px={2}
|
|
position="relative"
|
|
transform="translateY(-7px)!important"
|
|
>
|
|
<MetaLink
|
|
color="white"
|
|
href={linkURL || '/'}
|
|
_hover={{ textDecoration: 'none' }}
|
|
>
|
|
<MenuItem
|
|
sx={{
|
|
'&:hover, &:active, &:focus': {
|
|
bg: 'rgba(0,0,0,0.56)',
|
|
color: 'white',
|
|
borderRadius: 'md',
|
|
},
|
|
}}
|
|
>
|
|
<Profile w={4} h={4} mr={4} /> View Profile
|
|
</MenuItem>
|
|
</MetaLink>
|
|
<MetaLink
|
|
color="white"
|
|
href={'/profile/setup'}
|
|
_hover={{ textDecoration: 'none' }}
|
|
>
|
|
<MenuItem
|
|
sx={{
|
|
'&:hover, &:active, &:focus': {
|
|
bg: 'rgba(0,0,0,0.56)',
|
|
color: 'white',
|
|
borderRadius: 'md',
|
|
},
|
|
}}
|
|
>
|
|
<Profile w={4} h={4} mr={4} /> Profile Wizard
|
|
</MenuItem>
|
|
</MetaLink>
|
|
<MetaLink
|
|
color="white"
|
|
href={'/dashboard'}
|
|
_hover={{ textDecoration: 'none' }}
|
|
>
|
|
<MenuItem
|
|
sx={{
|
|
'&:hover, &:active, &:focus': {
|
|
bg: 'rgba(0,0,0,0.56)',
|
|
color: 'white',
|
|
borderRadius: 'md',
|
|
},
|
|
}}
|
|
>
|
|
<Dashboard w={4} h={4} mr={4} fill="white" color="red.500" />
|
|
Dashboard
|
|
</MenuItem>
|
|
</MetaLink>
|
|
<MenuItem
|
|
onClick={disconnect}
|
|
sx={{
|
|
'&:hover, &:active, &:focus': {
|
|
bg: 'rgba(0,0,0,0.56)',
|
|
color: 'white',
|
|
borderRadius: 'md',
|
|
},
|
|
}}
|
|
>
|
|
<LogOut w={4} h={4} mr={4} fill="white" />
|
|
Disconnect
|
|
</MenuItem>
|
|
</MenuList>
|
|
</Menu>
|
|
<HStack justify="flex-end">
|
|
<XPSeedsBalance totalXP={user.totalXP} mobile />
|
|
</HStack>
|
|
</>
|
|
) : (
|
|
<ConnectKitButton />
|
|
)}
|
|
</Flex>
|
|
);
|
|
};
|