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

Switch logo #1

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions icons/networks/wvm-icon-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions icons/networks/wvm-icon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/networks/wvm-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions icons/networks/wvm-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/icons/name.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
| "networks"
| "networks/icon-placeholder"
| "networks/logo-placeholder"
| "networks/wvm-icon-dark"
| "networks/wvm-icon-light"
| "networks/wvm-logo-dark"
| "networks/wvm-logo-light"
| "nft_shield"
| "output_roots"
| "payment_link"
Expand Down
93 changes: 71 additions & 22 deletions ui/snippets/networkMenu/NetworkLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Box, Image, useColorModeValue, Skeleton, chakra } from '@chakra-ui/react';
import {
Box,
Image,
useColorMode,
useColorModeValue,
Skeleton,
chakra,
} from '@chakra-ui/react';
import React from 'react';

import { route } from 'nextjs-routes';
Expand All @@ -12,50 +19,84 @@ interface Props {
className?: string;
}

const LogoFallback = ({ isCollapsed, isSmall }: { isCollapsed?: boolean; isSmall?: boolean }) => {
const LogoFallback = ({
isCollapsed,
isSmall,
}: {
isCollapsed?: boolean;
isSmall?: boolean;
}) => {
const field = isSmall ? 'icon' : 'logo';
const logoColor = useColorModeValue('blue.600', 'white');
const { colorMode } = useColorMode();

const iconPath =
colorMode === 'light' ?
'networks/wvm-icon-dark' :
'networks/wvm-icon-light';
const logoPath =
colorMode === 'dark' ? 'networks/wvm-logo-light' : 'networks/wvm-logo-dark';

const display = isSmall ? {
base: 'none',
lg: isCollapsed === false ? 'none' : 'block',
xl: isCollapsed ? 'block' : 'none',
} : {
base: 'block',
lg: isCollapsed === false ? 'block' : 'none',
xl: isCollapsed ? 'none' : 'block',
};
const display = isSmall ?
{
base: 'none',
lg: isCollapsed === false ? 'none' : 'block',
xl: isCollapsed ? 'block' : 'none',
} :
{
base: 'block',
lg: isCollapsed === false ? 'block' : 'none',
xl: isCollapsed ? 'none' : 'block',
};

if (config.UI.sidebar[field].default) {
return <Skeleton w="100%" borderRadius="sm" display={ display }/>;
}

return (
<IconSvg
name={ isSmall ? 'networks/icon-placeholder' : 'networks/logo-placeholder' }
name={ isSmall ? `${ iconPath }` : `${ logoPath }` }
width="auto"
height="100%"
color={ logoColor }
display={ display }
/>
);
};

const NetworkLogo = ({ isCollapsed, onClick, className }: Props) => {
const logoSrc = useColorModeValue(
config.UI.sidebar.logo.default,
config.UI.sidebar.logo.dark || config.UI.sidebar.logo.default,
);

const logoSrc = useColorModeValue(config.UI.sidebar.logo.default, config.UI.sidebar.logo.dark || config.UI.sidebar.logo.default);
const iconSrc = useColorModeValue(config.UI.sidebar.icon.default, config.UI.sidebar.icon.dark || config.UI.sidebar.icon.default);
const iconSrc = useColorModeValue(
config.UI.sidebar.icon.default,
config.UI.sidebar.icon.dark || config.UI.sidebar.icon.default,
);
const darkModeFilter = { filter: 'brightness(0) invert(1)' };
const logoStyle = useColorModeValue({}, !config.UI.sidebar.logo.dark ? darkModeFilter : {});
const iconStyle = useColorModeValue({}, !config.UI.sidebar.icon.dark ? darkModeFilter : {});
const logoStyle = useColorModeValue(
{},
!config.UI.sidebar.logo.dark ? darkModeFilter : {},
);
const iconStyle = useColorModeValue(
{},
!config.UI.sidebar.icon.dark ? darkModeFilter : {},
);

return (
<Box
className={ className }
as="a"
href={ route({ pathname: '/' }) }
width={{ base: '120px', lg: isCollapsed === false ? '120px' : '30px', xl: isCollapsed ? '30px' : '120px' }}
height={{ base: '24px', lg: isCollapsed === false ? '24px' : '30px', xl: isCollapsed ? '30px' : '24px' }}
width={{
base: '120px',
lg: isCollapsed === false ? '120px' : '30px',
xl: isCollapsed ? '30px' : '120px',
}}
height={{
base: '24px',
lg: isCollapsed === false ? '24px' : '30px',
xl: isCollapsed ? '30px' : '24px',
}}
display="inline-flex"
overflow="hidden"
onClick={ onClick }
Expand All @@ -69,7 +110,11 @@ const NetworkLogo = ({ isCollapsed, onClick, className }: Props) => {
src={ logoSrc }
alt={ `${ config.chain.name } network logo` }
fallback={ <LogoFallback isCollapsed={ isCollapsed }/> }
display={{ base: 'block', lg: isCollapsed === false ? 'block' : 'none', xl: isCollapsed ? 'none' : 'block' }}
display={{
base: 'block',
lg: isCollapsed === false ? 'block' : 'none',
xl: isCollapsed ? 'none' : 'block',
}}
style={ logoStyle }
/>
{ /* small logo */ }
Expand All @@ -79,7 +124,11 @@ const NetworkLogo = ({ isCollapsed, onClick, className }: Props) => {
src={ iconSrc }
alt={ `${ config.chain.name } network logo` }
fallback={ <LogoFallback isCollapsed={ isCollapsed } isSmall/> }
display={{ base: 'none', lg: isCollapsed === false ? 'none' : 'block', xl: isCollapsed ? 'block' : 'none' }}
display={{
base: 'none',
lg: isCollapsed === false ? 'none' : 'block',
xl: isCollapsed ? 'block' : 'none',
}}
style={ iconStyle }
/>
</Box>
Expand Down
Loading