prevent link nav
This commit is contained in:
parent
f5441a682d
commit
62713c7e71
@ -22,6 +22,7 @@ import { setupI18n } from "@gnu-taler/taler-util";
|
|||||||
import { styled } from "@linaria/react";
|
import { styled } from "@linaria/react";
|
||||||
import {
|
import {
|
||||||
ComponentChild,
|
ComponentChild,
|
||||||
|
ComponentChildren,
|
||||||
Fragment,
|
Fragment,
|
||||||
FunctionComponent,
|
FunctionComponent,
|
||||||
h,
|
h,
|
||||||
@ -242,33 +243,63 @@ function ExampleList({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevents the UI from redirecting and inform the dev
|
||||||
|
* where the <a /> should have redirected
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function PreventLinkNavigation({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: ComponentChildren;
|
||||||
|
}): VNode {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={(e) => {
|
||||||
|
let t: any = e.target;
|
||||||
|
do {
|
||||||
|
if (t.localName === "a" && t.getAttribute("href")) {
|
||||||
|
alert(`should navigate to: ${t.attributes.href.value}`);
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while ((t = t.parentNode));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function getWrapperForGroup(group: string): FunctionComponent {
|
function getWrapperForGroup(group: string): FunctionComponent {
|
||||||
switch (group) {
|
switch (group) {
|
||||||
case "popup":
|
case "popup":
|
||||||
return function PopupWrapper({ children }: any) {
|
return function PopupWrapper({ children }: any) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<PreventLinkNavigation>
|
||||||
<PopupNavBar />
|
<PopupNavBar />
|
||||||
<PopupBox>{children}</PopupBox>
|
<PopupBox>{children}</PopupBox>
|
||||||
</Fragment>
|
</PreventLinkNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
case "wallet":
|
case "wallet":
|
||||||
return function WalletWrapper({ children }: any) {
|
return function WalletWrapper({ children }: any) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<PreventLinkNavigation>
|
||||||
<LogoHeader />
|
<LogoHeader />
|
||||||
<WalletNavBar />
|
<WalletNavBar />
|
||||||
<WalletBox>{children}</WalletBox>
|
<WalletBox>{children}</WalletBox>
|
||||||
</Fragment>
|
</PreventLinkNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
case "cta":
|
case "cta":
|
||||||
return function WalletWrapper({ children }: any) {
|
return function WalletWrapper({ children }: any) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<PreventLinkNavigation>
|
||||||
<WalletBox>{children}</WalletBox>
|
<WalletBox>{children}</WalletBox>
|
||||||
</Fragment>
|
</PreventLinkNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user