Skip to content

Commit

Permalink
feat: open wallet urls on a popup window (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifaouibadi committed Feb 27, 2024
1 parent a849455 commit b132baa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/context/SuperheroProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ export const SuperheroProvider = ({ children, config }: any): any => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

/**
* Handles the click event on an element.
* If the target element's host is 'wallet.superhero.com', it prevents the default behavior and opens the target URL in a new window with specific dimensions.
* @param e - The MouseEvent object representing the click event.
*/
function onElementClick(e: MouseEvent): void {
const target = e.target as HTMLAnchorElement;
if (target?.host === "wallet.superhero.com") {
e.preventDefault();
window.open(target.href, "superhero_wallet", "width=360,height=600");
}
}

useEffect(() => {
document.addEventListener("click", onElementClick);
return () => document.removeEventListener("click", onElementClick);
}, []);

// Load minimum token threshold
useMinimumTokenThreshold(config);

Expand Down

0 comments on commit b132baa

Please sign in to comment.