Skip to content

Commit

Permalink
chore: update sidebar options (#1234)
Browse files Browse the repository at this point in the history
* chore: update sidebar options

* chore
  • Loading branch information
Hemanthghs authored May 10, 2024
1 parent 2b49181 commit 4a0af23
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 77 deletions.
11 changes: 11 additions & 0 deletions frontend/public/history-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions frontend/public/menu-icon-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions frontend/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@
@apply flex;
}

.more-options-menu {
@apply rounded-2xl;
background: #0e0b26;
backdrop-filter: blur(10px);
box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.4);
}

.more-options-menu-item {
@apply px-4 text-[14px] font-medium leading-normal cursor-pointer flex items-center;
}

.more-options-menu-item:hover {
background: #221f38;
}

/* Side ads styles */
.ad-close {
@apply absolute right-3 top-1 cursor-pointer rounded-full bg-[#ffffff1a];
Expand Down
127 changes: 127 additions & 0 deletions frontend/src/components/MoreOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React, { useEffect, useRef, useState } from 'react';
import Image from 'next/image';
import { SIDENAV_MENU_ITEMS } from '@/utils/constants';
import Link from 'next/link';
import { useAppSelector } from '@/custom-hooks/StateHooks';
import { tabLink } from '@/utils/util';
import { Tooltip } from '@mui/material';

const MoreOptions = () => {
const [optionsOpen, setOptionsOpen] = useState(false);
const menuRef = useRef<HTMLDivElement>(null);
const menuRef2 = useRef<HTMLDivElement>(null);
const isAuthzMode = useAppSelector((state) => state.authz.authzModeEnabled);
const selectedNetwork = useAppSelector(
(state) => state.common.selectedNetwork.chainName
);

useEffect(() => {
const handleOutsideClick = (event: MouseEvent) => {
if (
menuRef.current &&
!menuRef.current.contains(event.target as Node) &&
menuRef2.current &&
!menuRef2.current.contains(event.target as Node)
) {
setOptionsOpen(false);
}
};

document.addEventListener('mousedown', handleOutsideClick);

return () => {
document.removeEventListener('mousedown', handleOutsideClick);
};
}, []);

return (
<div className="cursor-pointer sidebar-menu-item relative">
<div
ref={menuRef2}
onMouseEnter={() => setOptionsOpen(true)}
onMouseLeave={() => setOptionsOpen(false)}
title="Advanced"
className="relative"
>
<Image
onClick={() => setOptionsOpen((prev) => !prev)}
src="/menu-icon-filled.svg"
height={30}
width={30}
alt={'Advanced'}
/>
</div>
{optionsOpen && (
<div
ref={menuRef}
className="absolute right-[-130px] top-4 z-[100]"
onMouseEnter={() => setOptionsOpen(true)}
onMouseLeave={() => setOptionsOpen(false)}
>
<div className="more-options-menu py-4 flex flex-col gap-2">
{SIDENAV_MENU_ITEMS.moreOptions.map((option) => {
const isMetamaskSupported = () =>
option.isMetaMaskSupports ||
localStorage.getItem('WALLET_NAME') !== 'metamask';
const authzSupport = !isAuthzMode || option.authzSupported;
return (
<Link
href={
isMetamaskSupported() === false
? ''
: authzSupport
? tabLink(option.link, selectedNetwork)
: ''
}
key={option.link}
>
<Tooltip
className={
isMetamaskSupported() === false
? 'cursor-not-allowed'
: authzSupport
? ''
: 'cursor-not-allowed'
}
title={
isMetamaskSupported() === false
? "MetaMask doesn't support " + option.name
: authzSupport
? option.name
: 'authz mode is not supported for ' + option.name
}
placement="right"
>
<div className="more-options-menu-item">
<div className="w-[45px] h-[45px] flex-center-center">
<Image
src={option.icon}
height={
option.link.includes('cosmwasm') ||
option.link.includes('history')
? 32
: 45
}
width={
option.link.includes('cosmwasm') ||
option.link.includes('history')
? 32
: 45
}
alt={option.name}
/>
</div>
<div>{option.name}</div>
</div>
</Tooltip>
</Link>
);
})}
</div>
</div>
)}
</div>
);
};

export default MoreOptions;
12 changes: 9 additions & 3 deletions frontend/src/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ import {
} from '@/utils/constants';
// import useInitAuthz from '@/custom-hooks/useInitAuthz';
// import useInitFeegrant from '@/custom-hooks/useInitFeegrant';
import { getAllTokensPrice, setAllNetworksInfo } from '@/store/features/common/commonSlice';
import {
getAllTokensPrice,
setAllNetworksInfo,
} from '@/store/features/common/commonSlice';
import IBCSwapTxStatus from './IBCSwapTxStatus';
import MoreOptions from './MoreOptions';

const SideBar = ({ children }: { children: React.ReactNode }) => {
const pathName = usePathname();
Expand All @@ -36,17 +40,18 @@ const SideBar = ({ children }: { children: React.ReactNode }) => {
dispatch(setAllNetworksInfo());
dispatch(getAllTokensPrice());
}, []);

return (
<div className="main">
<TransactionSuccessPopup />
<IBCSwapTxStatus />

<div className="sidebar overflow-y-scroll">
<div className="sidebar">
<Link href="/">
<Image src="/vitwit-logo.png" height={30} width={55} alt="Resolute" />
</Link>
<div className="flex flex-col gap-4 items-center">
{SIDENAV_MENU_ITEMS.map((item) => (
{SIDENAV_MENU_ITEMS.defaultOptions.map((item) => (
<MenuItem
key={item.name}
pathName={selectedPart}
Expand All @@ -58,6 +63,7 @@ const SideBar = ({ children }: { children: React.ReactNode }) => {
metamaskSupport={item.isMetaMaskSupports}
/>
))}
<MoreOptions />
</div>
<div className="flex flex-col gap-4">
<Tooltip title="Report an issue" placement="right">
Expand Down
160 changes: 86 additions & 74 deletions frontend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,80 +119,92 @@ export const txBroadcastTimeoutMs = 60_000;
export const txBroadcastPollIntervalMs = 3_000;
export const TRACK_IBC_TX_TIME_INTERVAL = 15000;

export const SIDENAV_MENU_ITEMS = [
{
name: 'Overview',
icon: '/overview-icon.svg',
activeIcon: '/overview-icon-active.svg',
link: '/',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Transfers',
icon: '/transfers-icon.svg',
activeIcon: '/transfers-icon-active.svg',
link: '/transfers',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Governance',
icon: '/gov-icon.svg',
activeIcon: '/gov-icon-active.svg',
link: '/governance',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Staking',
icon: '/staking-icon.svg',
activeIcon: '/staking-icon-active.svg',
link: '/staking',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Authz',
icon: '/authz-icon.svg',
activeIcon: '/authz-icon-active.svg',
link: '/authz',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'Multisig',
icon: '/multisig-icon.svg',
activeIcon: '/multisig-icon-active.svg',
link: '/multisig',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'Feegrant',
icon: '/feegrant-icon.svg',
activeIcon: '/feegrant-icon-active.svg',
link: '/feegrant',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'Multiops',
icon: '/multiops-icon.svg',
activeIcon: '/multiops-icon-active.svg',
link: '/multiops',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'CosmWasm Contracts',
icon: '/cosmwasm-icon.svg',
activeIcon: '/cosmwasm-icon-active.svg',
link: '/cosmwasm',
authzSupported: false,
isMetaMaskSupports: false,
},
];
export const SIDENAV_MENU_ITEMS = {
defaultOptions: [
{
name: 'Overview',
icon: '/overview-icon.svg',
activeIcon: '/overview-icon-active.svg',
link: '/',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Transfers',
icon: '/transfers-icon.svg',
activeIcon: '/transfers-icon-active.svg',
link: '/transfers',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Governance',
icon: '/gov-icon.svg',
activeIcon: '/gov-icon-active.svg',
link: '/governance',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Staking',
icon: '/staking-icon.svg',
activeIcon: '/staking-icon-active.svg',
link: '/staking',
authzSupported: true,
isMetaMaskSupports: true,
},
{
name: 'Authz',
icon: '/authz-icon.svg',
activeIcon: '/authz-icon-active.svg',
link: '/authz',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'Multisig',
icon: '/multisig-icon.svg',
activeIcon: '/multisig-icon-active.svg',
link: '/multisig',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'Feegrant',
icon: '/feegrant-icon.svg',
activeIcon: '/feegrant-icon-active.svg',
link: '/feegrant',
authzSupported: false,
isMetaMaskSupports: false,
},
],
moreOptions: [
{
name: 'Multiops',
icon: '/multiops-icon.svg',
activeIcon: '/multiops-icon-active.svg',
link: '/multiops',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'CosmWasm',
icon: '/cosmwasm-icon.svg',
activeIcon: '/cosmwasm-icon-active.svg',
link: '/cosmwasm',
authzSupported: false,
isMetaMaskSupports: false,
},
{
name: 'History',
icon: '/history-icon.svg',
activeIcon: '/history-icon.svg',
link: '/history',
authzSupported: true,
isMetaMaskSupports: true,
},
],
};
export const ALL_NETWORKS_ICON = '/all-networks-icon.png';
export const CHANGE_NETWORK_ICON = '/switch-icon.svg';
export const TXN_SUCCESS_ICON = '/transaction-success-icon.svg';
Expand Down

0 comments on commit 4a0af23

Please sign in to comment.