2024-04-24 15:56:11 +00:00
|
|
|
import { Root, createRoot } from "react-dom/client";
|
2024-05-04 16:18:56 +00:00
|
|
|
import QuizDialog from "../shared/QuizDialog";
|
2024-04-24 15:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
export class PopupWidget {
|
|
|
|
root: Root | undefined;
|
|
|
|
element: HTMLDivElement;
|
|
|
|
|
|
|
|
constructor({ quizId }: {
|
|
|
|
quizId: string;
|
|
|
|
}) {
|
|
|
|
this.element = document.createElement("div");
|
|
|
|
this.element.style.setProperty("display", "none");
|
|
|
|
document.body.appendChild(this.element);
|
|
|
|
|
|
|
|
this.root = createRoot(this.element);
|
|
|
|
|
|
|
|
this.root.render(
|
|
|
|
<QuizDialog
|
|
|
|
quizId={quizId}
|
|
|
|
onClose={() => this.destroy()}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
if (this.root) this.root.unmount();
|
|
|
|
this.element.remove();
|
|
|
|
}
|
|
|
|
}
|