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 WidgetApp from "./WidgetApp";
|
||||
|
||||
|
||||
let root: Root | undefined = undefined;
|
||||
|
||||
const widget = {
|
||||
create({ selector, quizId }: {
|
||||
create({ selector, quizId, changeFaviconAndTitle = true }: {
|
||||
selector: string;
|
||||
quizId: string;
|
||||
changeFaviconAndTitle: boolean;
|
||||
}) {
|
||||
const element = document.getElementById(selector);
|
||||
if (!element) throw new Error("Element for widget doesn't exist");
|
||||
|
||||
root = createRoot(element);
|
||||
|
||||
root.render(<WidgetApp quizId={quizId} />);
|
||||
root.render(<QuizAnswerer quizId={quizId} changeFaviconAndTitle={changeFaviconAndTitle} />);
|
||||
},
|
||||
unmount() {
|
||||
if (root) root.unmount();
|
||||
|
Loading…
Reference in New Issue
Block a user