add changeFaviconAndTitle param to widget
This commit is contained in:
parent
bea831a060
commit
2ee1a72259
@ -1,13 +0,0 @@
|
|||||||
import QuizAnswerer from "../lib/components/QuizAnswerer";
|
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
quizId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function WidgetApp({ quizId }: Props) {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<QuizAnswerer quizId={quizId} />
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,20 +1,21 @@
|
|||||||
|
import QuizAnswerer from "@/components/QuizAnswerer";
|
||||||
import { Root, createRoot } from "react-dom/client";
|
import { Root, createRoot } from "react-dom/client";
|
||||||
import WidgetApp from "./WidgetApp";
|
|
||||||
|
|
||||||
|
|
||||||
let root: Root | undefined = undefined;
|
let root: Root | undefined = undefined;
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
create({ selector, quizId }: {
|
create({ selector, quizId, changeFaviconAndTitle = true }: {
|
||||||
selector: string;
|
selector: string;
|
||||||
quizId: string;
|
quizId: string;
|
||||||
|
changeFaviconAndTitle: boolean;
|
||||||
}) {
|
}) {
|
||||||
const element = document.getElementById(selector);
|
const element = document.getElementById(selector);
|
||||||
if (!element) throw new Error("Element for widget doesn't exist");
|
if (!element) throw new Error("Element for widget doesn't exist");
|
||||||
|
|
||||||
root = createRoot(element);
|
root = createRoot(element);
|
||||||
|
|
||||||
root.render(<WidgetApp quizId={quizId} />);
|
root.render(<QuizAnswerer quizId={quizId} changeFaviconAndTitle={changeFaviconAndTitle} />);
|
||||||
},
|
},
|
||||||
unmount() {
|
unmount() {
|
||||||
if (root) root.unmount();
|
if (root) root.unmount();
|
||||||
|
Loading…
Reference in New Issue
Block a user