mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-24 19:38:12 -05:00
Move app to apps/web-react in pnpm workspace layout
This commit is contained in:
48
apps/web-react/app/components/fuse/Fuse.tsx
Normal file
48
apps/web-react/app/components/fuse/Fuse.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
fusetag: {
|
||||
que: Array<() => void>;
|
||||
pageInit?: () => void;
|
||||
registerZone?: (id: string) => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function callPageInit() {
|
||||
window.fusetag = window.fusetag || { que: [] };
|
||||
window.fusetag.que.push(() => {
|
||||
window.fusetag.pageInit?.();
|
||||
});
|
||||
}
|
||||
|
||||
export function FusePageInit() {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
callPageInit();
|
||||
}, [pathname]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function FuseZone({
|
||||
id,
|
||||
fuseSlot,
|
||||
className,
|
||||
}: {
|
||||
id: string;
|
||||
fuseSlot: string;
|
||||
className?: string;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
window.fusetag = window.fusetag || { que: [] };
|
||||
window.fusetag.que.push(() => {
|
||||
window.fusetag.registerZone?.(id);
|
||||
});
|
||||
}, [id]);
|
||||
|
||||
return <div id={id} data-fuse={fuseSlot} className={className} />;
|
||||
}
|
||||
Reference in New Issue
Block a user