add side widget class render method

This commit is contained in:
nflnkr 2024-05-03 21:46:14 +03:00
parent d46163a4ce
commit 82b6d37080

@ -3,25 +3,23 @@ import QuizSideButton from "./QuizSideButton";
import { ComponentPropsWithoutRef } from "react"; import { ComponentPropsWithoutRef } from "react";
type Props = ComponentPropsWithoutRef<typeof QuizSideButton>;
export class SideWidget { export class SideWidget {
root: Root | undefined; root: Root | undefined;
element = document.createElement("div"); element = document.createElement("div");
constructor({ quizId, position, buttonColor }: ComponentPropsWithoutRef<typeof QuizSideButton> & { constructor(props: Props) {
buttonColor?: string;
}) {
this.element.style.setProperty("display", "none"); this.element.style.setProperty("display", "none");
document.body.appendChild(this.element); document.body.appendChild(this.element);
this.root = createRoot(this.element); this.root = createRoot(this.element);
this.root.render( this.render(props);
<QuizSideButton }
quizId={quizId}
position={position} render(props: Props) {
buttonColor={buttonColor} this.root?.render(<QuizSideButton {...props} />);
/>
);
} }
destroy() { destroy() {