Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marketplace improvements #1356

Merged
merged 22 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Home = () => {
</Heading>
<Box display={{ base: 'none', lg: 'flex' }}>
{ config.features.account.isEnabled && <ProfileMenuDesktop isHomePage/> }
<WalletMenuDesktop isHomePage/>
{ config.features.blockchainInteraction.isEnabled && <WalletMenuDesktop isHomePage/> }
</Box>
</Flex>
<LightMode>
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/Web3ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Web3ModalProvider = ({ children, fallback }: Props) => {
const web3ModalTheme = useColorModeValue('light', 'dark');

if (!wagmiConfig || !ethereumClient || !feature.isEnabled) {
return typeof fallback === 'function' ? fallback() : (fallback || null);
return typeof fallback === 'function' ? fallback() : (fallback || <>{ children }</>); // eslint-disable-line react/jsx-no-useless-fragment
maxaleks marked this conversation as resolved.
Show resolved Hide resolved
}

return (
Expand Down
8 changes: 6 additions & 2 deletions ui/snippets/header/Burger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import NetworkMenuButton from 'ui/snippets/networkMenu/NetworkMenuButton';
import NetworkMenuContentMobile from 'ui/snippets/networkMenu/NetworkMenuContentMobile';
import useNetworkMenu from 'ui/snippets/networkMenu/useNetworkMenu';

const Burger = () => {
interface Props {
isAppPage?: boolean;
maxaleks marked this conversation as resolved.
Show resolved Hide resolved
}

const Burger = ({ isAppPage }: Props) => {
const iconColor = useColorModeValue('gray.600', 'white');
const { isOpen, onOpen, onClose } = useDisclosure();
const networkMenu = useNetworkMenu();
Expand Down Expand Up @@ -57,7 +61,7 @@ const Burger = () => {
</Flex>
{ networkMenu.isOpen ?
<NetworkMenuContentMobile tabs={ networkMenu.availableTabs } items={ networkMenu.data }/> :
<NavigationMobile onNavLinkClick={ onClose }/>
<NavigationMobile onNavLinkClick={ onClose } isAppPage={ isAppPage }/>
}
</DrawerBody>
</DrawerContent>
Expand Down
12 changes: 5 additions & 7 deletions ui/snippets/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ const Header = ({ isHomePage, isAppPage, renderSearchBar }: Props) => {
>
<Burger/>
<NetworkLogo/>
<Box display="flex">
<Flex columnGap={ 2 }>
{ config.features.account.isEnabled ? <ProfileMenuMobile/> : <Box boxSize={ 10 }/> }
<Box ml={ 2 }>
<WalletMenuMobile/>
</Box>
</Box>
{ config.features.blockchainInteraction.isEnabled && <WalletMenuMobile/> }
</Flex>
</Flex>
{ !isHomePage && searchBar }
</Box>
Expand All @@ -65,7 +63,7 @@ const Header = ({ isHomePage, isAppPage, renderSearchBar }: Props) => {
>
{ isAppPage && (
<Box display="flex" alignItems="center" gap={ 3 }>
<Burger/>
<Burger isAppPage/>
<NetworkLogo isCollapsed/>
</Box>
) }
Expand All @@ -74,7 +72,7 @@ const Header = ({ isHomePage, isAppPage, renderSearchBar }: Props) => {
</Box>
<Box display="flex">
{ config.features.account.isEnabled && <ProfileMenuDesktop/> }
<WalletMenuDesktop/>
{ config.features.blockchainInteraction.isEnabled && <WalletMenuDesktop/> }
</Box>
</HStack>
) }
Expand Down
5 changes: 3 additions & 2 deletions ui/snippets/navigation/NavLinkGroupMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import useNavLinkStyleProps from './useNavLinkStyleProps';
type Props = {
item: NavGroupItem;
onClick: () => void;
isExpanded?: boolean;
}

const NavLinkGroup = ({ item, onClick }: Props) => {
const styleProps = useNavLinkStyleProps({ isActive: item.isActive });
const NavLinkGroup = ({ item, onClick, isExpanded }: Props) => {
const styleProps = useNavLinkStyleProps({ isActive: item.isActive, isExpanded });

return (
<Box as="li" listStyleType="none" w="100%" onClick={ onClick }>
Expand Down
7 changes: 4 additions & 3 deletions ui/snippets/navigation/NavigationMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import NavLinkGroupMobile from './NavLinkGroupMobile';

interface Props {
onNavLinkClick?: () => void;
isAppPage?: boolean;
}

const NavigationMobile = ({ onNavLinkClick }: Props) => {
const NavigationMobile = ({ onNavLinkClick, isAppPage }: Props) => {
const { mainNavItems, accountNavItems } = useNavItems();

const [ openedGroupIndex, setOpenedGroupIndex ] = React.useState(-1);
Expand Down Expand Up @@ -61,9 +62,9 @@ const NavigationMobile = ({ onNavLinkClick }: Props) => {
>
{ mainNavItems.map((item, index) => {
if (isGroupItem(item)) {
return <NavLinkGroupMobile key={ item.text } item={ item } onClick={ onGroupItemOpen(index) }/>;
return <NavLinkGroupMobile key={ item.text } item={ item } onClick={ onGroupItemOpen(index) } isExpanded={ isAppPage }/>;
} else {
return <NavLink key={ item.text } item={ item } onClick={ onNavLinkClick }/>;
return <NavLink key={ item.text } item={ item } onClick={ onNavLinkClick } isCollapsed={ isAppPage ? false : undefined }/>;
}
}) }
</VStack>
Expand Down
12 changes: 6 additions & 6 deletions ui/snippets/profileMenu/ProfileMenuDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IconButtonProps } from '@chakra-ui/react';
import { Popover, PopoverContent, PopoverBody, PopoverTrigger, IconButton, useColorModeValue, Tooltip, Box } from '@chakra-ui/react';
import { Popover, PopoverContent, PopoverBody, PopoverTrigger, IconButton, Tooltip, Box } from '@chakra-ui/react';
import React from 'react';

import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
Expand All @@ -8,13 +8,16 @@ import * as mixpanel from 'lib/mixpanel/index';
import UserAvatar from 'ui/shared/UserAvatar';
import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent';

import useMenuButtonColors from '../useMenuButtonColors';

type Props = {
isHomePage?: boolean;
};

const ProfileMenuDesktop = ({ isHomePage }: Props) => {
const { data, error, isPending } = useFetchProfileInfo();
const loginUrl = useLoginUrl();
const { themedBackground, themedBorderColor, themedColor } = useMenuButtonColors();
const [ hasMenu, setHasMenu ] = React.useState(false);

React.useEffect(() => {
Expand Down Expand Up @@ -51,16 +54,13 @@ const ProfileMenuDesktop = ({ isHomePage }: Props) => {
}, [ hasMenu, isHomePage ]);

let iconButtonStyles: Partial<IconButtonProps> = {};
const themedBackground = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const themedBorderColor = useColorModeValue('gray.300', 'gray.700');
const themedColor = useColorModeValue('blackAlpha.800', 'gray.400');
if (hasMenu) {
iconButtonStyles = {
bg: isHomePage ? '#EBF8FF' : themedBackground,
bg: isHomePage ? 'blue.50' : themedBackground,
};
} else if (isHomePage) {
iconButtonStyles = {
color: '#fff',
color: 'white',
};
} else {
iconButtonStyles = {
Expand Down
10 changes: 4 additions & 6 deletions ui/snippets/profileMenu/ProfileMenuMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconButton, useColorModeValue } from '@chakra-ui/react';
import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconButton } from '@chakra-ui/react';
import type { IconButtonProps } from '@chakra-ui/react';
import React from 'react';

Expand All @@ -8,11 +8,13 @@ import * as mixpanel from 'lib/mixpanel/index';
import UserAvatar from 'ui/shared/UserAvatar';
import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent';

import useMenuButtonColors from '../useMenuButtonColors';

const ProfileMenuMobile = () => {
const { isOpen, onOpen, onClose } = useDisclosure();

const { data, error, isPending } = useFetchProfileInfo();
const loginUrl = useLoginUrl();
const { themedBackground, themedBorderColor, themedColor } = useMenuButtonColors();
const [ hasMenu, setHasMenu ] = React.useState(false);

const handleSignInClick = React.useCallback(() => {
Expand Down Expand Up @@ -41,10 +43,6 @@ const ProfileMenuMobile = () => {
};
})();

const themedBackground = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const themedBorderColor = useColorModeValue('gray.300', 'gray.700');
const themedColor = useColorModeValue('blackAlpha.800', 'gray.400');

return (
<>
<IconButton
Expand Down
9 changes: 9 additions & 0 deletions ui/snippets/useMenuButtonColors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useColorModeValue } from '@chakra-ui/react';

export default function useMenuColors() {
const themedBackground = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const themedBorderColor = useColorModeValue('gray.300', 'gray.700');
const themedColor = useColorModeValue('blackAlpha.800', 'gray.400');

return { themedBackground, themedBorderColor, themedColor };
}
74 changes: 35 additions & 39 deletions ui/snippets/walletMenu/WalletMenuContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Button, Text, useColorModeValue } from '@chakra-ui/react';
import { Box, Button, Text } from '@chakra-ui/react';
import React from 'react';

import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
Expand All @@ -9,43 +9,39 @@ type Props = {
disconnect?: () => void;
};

const WalletMenuContent = ({ address, disconnect }: Props) => {
const primaryTextColor = useColorModeValue('blackAlpha.800', 'whiteAlpha.800');
return (
<Box>
<Text
fontSize="sm"
fontWeight={ 600 }
mb={ 1 }
color={ primaryTextColor }
{ ...getDefaultTransitionProps() }
>
My wallet
</Text>
<Text
fontSize="sm"
mb={ 5 }
fontWeight={ 400 }
color="gray.500"
{ ...getDefaultTransitionProps() }
>
Your wallet is used to interact with apps and contracts in the explorer.
</Text>
<AddressEntity
address={{ hash: address }}
noLink
noTooltip
truncation="dynamic"
fontSize="sm"
fontWeight={ 700 }
color={ primaryTextColor }
mb={ 6 }
/>
<Button size="sm" width="full" variant="outline" onClick={ disconnect }>
Disconnect
</Button>
</Box>
);
};
const WalletMenuContent = ({ address, disconnect }: Props) => (
<Box>
<Text
fontSize="sm"
fontWeight={ 600 }
mb={ 1 }
{ ...getDefaultTransitionProps() }
>
My wallet
</Text>
<Text
fontSize="sm"
mb={ 5 }
fontWeight={ 400 }
color="text_secondary"
{ ...getDefaultTransitionProps() }
>
Your wallet is used to interact with apps and contracts in the explorer.
</Text>
<AddressEntity
address={{ hash: address }}
noLink
noTooltip
truncation="dynamic"
fontSize="sm"
fontWeight={ 700 }
color="text"
mb={ 6 }
/>
<Button size="sm" width="full" variant="outline" onClick={ disconnect }>
Disconnect
</Button>
</Box>
);

export default WalletMenuContent;
12 changes: 6 additions & 6 deletions ui/snippets/walletMenu/WalletMenuDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import type { ButtonProps } from '@chakra-ui/react';
import { Popover, PopoverContent, PopoverBody, PopoverTrigger, Button, useColorModeValue, Box, useBoolean, Tooltip } from '@chakra-ui/react';
import { Popover, PopoverContent, PopoverBody, PopoverTrigger, Button, Box, useBoolean, Tooltip } from '@chakra-ui/react';
import React from 'react';

import AddressIdenticon from 'ui/shared/entities/address/AddressIdenticon';
import HashStringShorten from 'ui/shared/HashStringShorten';
import useWallet from 'ui/snippets/walletMenu/useWallet';
import WalletMenuContent from 'ui/snippets/walletMenu/WalletMenuContent';

import useMenuButtonColors from '../useMenuButtonColors';

type Props = {
isHomePage?: boolean;
};

const WalletMenuDesktop = ({ isHomePage }: Props) => {
const { isWalletConnected, address, connect, disconnect, isModalOpening, isModalOpen } = useWallet();
const { themedBackground, themedBorderColor, themedColor } = useMenuButtonColors();
const [ isPopoverOpen, setIsPopoverOpen ] = useBoolean(false);
const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false);

Expand All @@ -32,20 +35,17 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
}, [ isWalletConnected, isHomePage ]);

let buttonStyles: Partial<ButtonProps> = {};
const themedBackground = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const themedBorderColor = useColorModeValue('gray.300', 'gray.700');
const themedColor = useColorModeValue('blackAlpha.800', 'gray.400');
if (isWalletConnected) {
buttonStyles = {
bg: isHomePage ? '#EBF8FF' : themedBackground,
bg: isHomePage ? 'blue.50' : themedBackground,
color: isHomePage ? 'blackAlpha.800' : themedColor,
_hover: {
color: isHomePage ? 'blackAlpha.800' : themedColor,
},
};
} else if (isHomePage) {
buttonStyles = {
color: '#FFFFFF',
color: 'white',
};
} else {
buttonStyles = {
Expand Down
9 changes: 4 additions & 5 deletions ui/snippets/walletMenu/WalletMenuMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconButton, useColorModeValue, Icon } from '@chakra-ui/react';
import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconButton, Icon } from '@chakra-ui/react';
import React from 'react';

import walletIcon from 'icons/wallet.svg';
import AddressIdenticon from 'ui/shared/entities/address/AddressIdenticon';
import useWallet from 'ui/snippets/walletMenu/useWallet';
import WalletMenuContent from 'ui/snippets/walletMenu/WalletMenuContent';

import useMenuButtonColors from '../useMenuButtonColors';

const WalletMenuMobile = () => {
const { isOpen, onOpen, onClose } = useDisclosure();
const { isWalletConnected, address, connect, disconnect, isModalOpening, isModalOpen } = useWallet();

const themedBackground = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const themedBorderColor = useColorModeValue('gray.300', 'gray.700');
const themedColor = useColorModeValue('blackAlpha.800', 'gray.400');
const { themedBackground, themedBorderColor, themedColor } = useMenuButtonColors();

return (
<>
Expand Down
Loading