File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 11import clsx from "clsx" ;
2- import { NavLink } from "react-router-dom" ;
2+ import { NavLink , useLocation } from "react-router-dom" ;
33
44type Props = {
55 url ?: string ;
66 children : React . ReactNode ;
77 shouldHighlight ?: boolean ;
8+ preventNavigationOnSameRoute ?: boolean ;
89} ;
910
1011export const SidebarMenuItem = ( {
1112 url,
1213 children,
1314 shouldHighlight,
15+ preventNavigationOnSameRoute = false ,
1416} : Props ) : JSX . Element => {
17+ const location = useLocation ( ) ;
18+
1519 const className = clsx (
1620 "flex items-center gap-5 text-lg text-white" ,
1721 "transition-colors duration-300 ease-out-quad hover:text-cyan" ,
@@ -24,9 +28,16 @@ export const SidebarMenuItem = ({
2428 return < span className = { className } > { children } </ span > ;
2529 }
2630
31+ const handleClick = ( e : React . MouseEvent ) : void => {
32+ if ( preventNavigationOnSameRoute && location . pathname === url ) {
33+ e . preventDefault ( ) ;
34+ }
35+ } ;
36+
2737 return (
2838 < NavLink
2939 to = { url }
40+ onClick = { handleClick }
3041 className = { ( { isActive } ) =>
3142 clsx ( className , {
3243 "text-yellow font-bold" : isActive || shouldHighlight ,
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ export const Navigation = (): JSX.Element => {
9999 shouldHighlight = {
100100 ! ! highlightTransferItem || ! ! highlightShieldItem
101101 }
102+ preventNavigationOnSameRoute = {
103+ ( item . label === "Shield" && highlightShieldItem ) ||
104+ ( item . label === "Transfer" && highlightTransferItem )
105+ }
102106 >
103107 { item . icon }
104108 { item . label }
Original file line number Diff line number Diff line change @@ -88,8 +88,11 @@ export const TransferSource = ({
8888 return (
8989 < div
9090 className = { clsx (
91- "relative bg-neutral-800 rounded-lg px-4 py-5 border-2" ,
92- selectedTokenType === "shielded" ? "border-yellow-400" : "border-white"
91+ "relative bg-neutral-800 rounded-lg px-4 py-5" ,
92+ asset && "border" ,
93+ asset && selectedTokenType === "shielded" ?
94+ "border-yellow-400"
95+ : asset && "border-white"
9396 ) }
9497 >
9598 < header className = "relative flex justify-between" >
You can’t perform that action at this time.
0 commit comments