frontAnswerer/src/widget.tsx

34 lines
770 B
TypeScript
Raw Normal View History

import QuizAnswerer from "@/components/QuizAnswerer";
2024-04-24 15:56:11 +00:00
import { createRoot } from "react-dom/client";
// eslint-disable-next-line react-refresh/only-export-components
export * from "./widgets";
2025-07-01 12:39:54 +00:00
import "./i18n/i18nWidget";
2024-01-20 12:26:28 +00:00
2024-04-24 15:56:11 +00:00
// old widget
2024-01-20 12:26:28 +00:00
const widget = {
2024-05-31 16:41:18 +00:00
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");
2024-01-20 12:26:28 +00:00
2024-05-31 16:41:18 +00:00
const root = createRoot(element);
2024-01-20 12:26:28 +00:00
2025-07-01 12:39:54 +00:00
root.render(
<QuizAnswerer
quizId={quizId}
changeFaviconAndTitle={changeFaviconAndTitle}
disableGlobalCss
/>
);
2024-05-31 16:41:18 +00:00
},
2024-01-20 12:26:28 +00:00
};
export default widget;