add side widget class render method
This commit is contained in:
parent
d46163a4ce
commit
82b6d37080
@ -3,25 +3,23 @@ import QuizSideButton from "./QuizSideButton";
|
||||
import { ComponentPropsWithoutRef } from "react";
|
||||
|
||||
|
||||
type Props = ComponentPropsWithoutRef<typeof QuizSideButton>;
|
||||
|
||||
export class SideWidget {
|
||||
root: Root | undefined;
|
||||
element = document.createElement("div");
|
||||
|
||||
constructor({ quizId, position, buttonColor }: ComponentPropsWithoutRef<typeof QuizSideButton> & {
|
||||
buttonColor?: string;
|
||||
}) {
|
||||
constructor(props: Props) {
|
||||
this.element.style.setProperty("display", "none");
|
||||
document.body.appendChild(this.element);
|
||||
|
||||
this.root = createRoot(this.element);
|
||||
|
||||
this.root.render(
|
||||
<QuizSideButton
|
||||
quizId={quizId}
|
||||
position={position}
|
||||
buttonColor={buttonColor}
|
||||
/>
|
||||
);
|
||||
this.render(props);
|
||||
}
|
||||
|
||||
render(props: Props) {
|
||||
this.root?.render(<QuizSideButton {...props} />);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
Loading…
Reference in New Issue
Block a user