mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* basic login button implementation * refactoring and add dynamic auth button to the other pages * connect wallet without authenticating an user * login and logout user in blockscout account * refactoring and RPC overrides * authenticate user with connected wallet * add ENS to profile button * override evm chains and fix contract write with waas wallet * disconnect wallet and fix docker build * add dynamic imports to components that use web3 wallet packages * refactor user profile directory * clean up * tweaks * update pw ci script * fix "connect wallet" button behavior * handle linking email to profile with dynamic provider * fix test * async loading web3 hooks and remove dynamic loading from components that use them * fix pw tests * add account navigation in horizontal layout when auth provider is dynamic * fix address verification modal * review fixes * spelling fixes
85 lines
2.5 KiB
TypeScript
85 lines
2.5 KiB
TypeScript
import { Box, Flex } from '@chakra-ui/react';
|
|
import dynamic from 'next/dynamic';
|
|
import React from 'react';
|
|
|
|
import config from 'configs/app';
|
|
import { useIsSticky } from 'toolkit/hooks/useIsSticky';
|
|
import RewardsButton from 'ui/rewards/RewardsButton';
|
|
import NetworkIcon from 'ui/snippets/networkLogo/NetworkIcon';
|
|
import UserProfileAuth0 from 'ui/snippets/user/profile/auth0/UserProfileMobile';
|
|
import UserWalletMobile from 'ui/snippets/user/wallet/UserWalletMobile';
|
|
|
|
import RollupStageBadge from '../navigation/RollupStageBadge';
|
|
import TestnetBadge from '../navigation/TestnetBadge';
|
|
import SearchBarMobile from '../searchBar/SearchBarMobile';
|
|
import Burger from './Burger';
|
|
|
|
const UserProfileDynamic = dynamic(() => import('ui/snippets/user/profile/dynamic/UserProfile'), { ssr: false });
|
|
|
|
type Props = {
|
|
hideSearchButton?: boolean;
|
|
onGoToSearchResults?: (searchTerm: string) => void;
|
|
};
|
|
|
|
const HeaderMobile = ({ hideSearchButton, onGoToSearchResults }: Props) => {
|
|
const ref = React.useRef<HTMLDivElement>(null);
|
|
const isSticky = useIsSticky(ref, 5);
|
|
|
|
const userProfile = (() => {
|
|
const accountFeature = config.features.account;
|
|
if (accountFeature.isEnabled) {
|
|
switch (accountFeature.authProvider) {
|
|
case 'auth0':
|
|
return <UserProfileAuth0/>;
|
|
case 'dynamic':
|
|
return <UserProfileDynamic/>;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
if (config.features.blockchainInteraction.isEnabled) {
|
|
return <UserWalletMobile/>;
|
|
}
|
|
})();
|
|
|
|
return (
|
|
<Box
|
|
ref={ ref }
|
|
bgColor="bg.primary"
|
|
display={{ base: 'block', lg: 'none' }}
|
|
position="sticky"
|
|
top="-1px"
|
|
left={ 0 }
|
|
zIndex="sticky2"
|
|
pt="1px"
|
|
height="56px"
|
|
>
|
|
<Flex
|
|
as="header"
|
|
paddingX={ 3 }
|
|
paddingY={ 2 }
|
|
bgColor="bg.primary"
|
|
width="100%"
|
|
alignItems="center"
|
|
transitionProperty="box-shadow"
|
|
transitionDuration="slow"
|
|
boxShadow={ isSticky ? 'md' : 'none' }
|
|
>
|
|
<Burger/>
|
|
<Flex alignItems="center" flexGrow={ 1 } mx={ 2 }>
|
|
<NetworkIcon/>
|
|
<TestnetBadge ml={ 2 }/>
|
|
<RollupStageBadge ml={ 2 }/>
|
|
</Flex>
|
|
<Flex columnGap={ 2 }>
|
|
{ !hideSearchButton && <SearchBarMobile onGoToSearchResults={ onGoToSearchResults }/> }
|
|
{ config.features.rewards.isEnabled && <RewardsButton/> }
|
|
{ userProfile }
|
|
</Flex>
|
|
</Flex>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default React.memo(HeaderMobile);
|