fix widget auto show features
This commit is contained in:
parent
4f86cbe2d1
commit
6fb351759d
@ -6,6 +6,10 @@ export interface BannerWidgetComponentProps {
|
|||||||
quizHeaderText?: string;
|
quizHeaderText?: string;
|
||||||
buttonTextColor?: string;
|
buttonTextColor?: string;
|
||||||
buttonBackgroundColor?: string;
|
buttonBackgroundColor?: string;
|
||||||
|
/**
|
||||||
|
* Показывать виджет через X секунд
|
||||||
|
*/
|
||||||
|
autoShowWidgetTime?: number;
|
||||||
/**
|
/**
|
||||||
* Открыть квиз через X секунд, 0 - сразу
|
* Открыть квиз через X секунд, 0 - сразу
|
||||||
*/
|
*/
|
||||||
|
@ -7,9 +7,9 @@ export interface SideWidgetComponentProps {
|
|||||||
fullScreen?: boolean;
|
fullScreen?: boolean;
|
||||||
buttonFlash?: boolean;
|
buttonFlash?: boolean;
|
||||||
/**
|
/**
|
||||||
* Скрывать виджет первые X секунд
|
* Показывать виджет через X секунд
|
||||||
*/
|
*/
|
||||||
autoOpenTime?: number;
|
autoShowWidgetTime?: number;
|
||||||
/**
|
/**
|
||||||
* Открыть квиз через X секунд, 0 - сразу
|
* Открыть квиз через X секунд, 0 - сразу
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@frontend/squzanswerer",
|
"name": "@frontend/squzanswerer",
|
||||||
"version": "1.0.41",
|
"version": "1.0.42",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist-package/index.js",
|
"main": "./dist-package/index.js",
|
||||||
"module": "./dist-package/index.js",
|
"module": "./dist-package/index.js",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import lightTheme from "@/utils/themes/light";
|
import lightTheme from "@/utils/themes/light";
|
||||||
import { Box, ThemeProvider, Typography } from "@mui/material";
|
import { Box, ThemeProvider, Typography } from "@mui/material";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { ContainerWidget as Widget } from "./widgets";
|
import { BannerWidget as Widget } from "./widgets";
|
||||||
|
|
||||||
|
|
||||||
const widgetProps: ConstructorParameters<typeof Widget>[0] = {
|
const widgetProps: ConstructorParameters<typeof Widget>[0] = {
|
||||||
quizId: "3c49550d-8c77-4788-bc2d-42586a261514",
|
quizId: "3c49550d-8c77-4788-bc2d-42586a261514",
|
||||||
selector: "#widget-container",
|
position: "bottomright",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function WidgetDev() {
|
export default function WidgetDev() {
|
||||||
|
@ -7,6 +7,7 @@ import BannerIcon from "../shared/BannerIcon";
|
|||||||
import QuizDialog from "../shared/QuizDialog";
|
import QuizDialog from "../shared/QuizDialog";
|
||||||
import RunningStripe from "../shared/RunningStripe";
|
import RunningStripe from "../shared/RunningStripe";
|
||||||
import { useQuizCompletionStatus } from "../shared/useQuizCompletionStatus";
|
import { useQuizCompletionStatus } from "../shared/useQuizCompletionStatus";
|
||||||
|
import { useAutoOpenTimer } from "../shared/useAutoOpenTimer";
|
||||||
|
|
||||||
|
|
||||||
const PADDING = 10;
|
const PADDING = 10;
|
||||||
@ -27,10 +28,12 @@ export default function QuizBanner({
|
|||||||
rounded = false,
|
rounded = false,
|
||||||
bannerFullWidth = false,
|
bannerFullWidth = false,
|
||||||
pulsation = false,
|
pulsation = false,
|
||||||
|
autoShowWidgetTime = 0,
|
||||||
}: BannerWidgetComponentProps) {
|
}: BannerWidgetComponentProps) {
|
||||||
const isMobile = useMediaQuery("(max-width: 600px)");
|
const isMobile = useMediaQuery("(max-width: 600px)");
|
||||||
const [isQuizShown, setIsQuizShown] = useState<boolean>(false);
|
const [isQuizShown, setIsQuizShown] = useState<boolean>(false);
|
||||||
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(buttonFlash);
|
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(buttonFlash);
|
||||||
|
const isWidgetHidden = useAutoOpenTimer(autoShowWidgetTime);
|
||||||
const isQuizCompleted = useQuizCompletionStatus(quizId);
|
const isQuizCompleted = useQuizCompletionStatus(quizId);
|
||||||
const preventQuizAutoShowRef = useRef<boolean>(false);
|
const preventQuizAutoShowRef = useRef<boolean>(false);
|
||||||
const preventOpenOnLeaveAttemptRef = useRef<boolean>(false);
|
const preventOpenOnLeaveAttemptRef = useRef<boolean>(false);
|
||||||
@ -74,7 +77,7 @@ export default function QuizBanner({
|
|||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<ThemeProvider theme={lightTheme}>
|
<ThemeProvider theme={lightTheme}>
|
||||||
<Fade in={!isQuizShown}>
|
<Fade in={!isQuizShown && !isWidgetHidden}>
|
||||||
<Box
|
<Box
|
||||||
className="pena-quiz-widget-banner"
|
className="pena-quiz-widget-banner"
|
||||||
sx={[
|
sx={[
|
||||||
|
@ -21,7 +21,7 @@ export default function QuizSideButton({
|
|||||||
dialogDimensions,
|
dialogDimensions,
|
||||||
fullScreen = false,
|
fullScreen = false,
|
||||||
buttonFlash = false,
|
buttonFlash = false,
|
||||||
autoOpenTime = 0,
|
autoShowWidgetTime = 0,
|
||||||
autoShowQuizTime = null,
|
autoShowQuizTime = null,
|
||||||
hideOnMobile = false,
|
hideOnMobile = false,
|
||||||
}: SideWidgetComponentProps) {
|
}: SideWidgetComponentProps) {
|
||||||
@ -29,7 +29,7 @@ export default function QuizSideButton({
|
|||||||
const isMobile = useMediaQuery("(max-width: 600px)");
|
const isMobile = useMediaQuery("(max-width: 600px)");
|
||||||
const isQuizCompleted = useQuizCompletionStatus(quizId);
|
const isQuizCompleted = useQuizCompletionStatus(quizId);
|
||||||
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(buttonFlash);
|
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(buttonFlash);
|
||||||
const isWidgetHidden = useAutoOpenTimer(autoOpenTime);
|
const isWidgetHidden = useAutoOpenTimer(autoShowWidgetTime);
|
||||||
const preventQuizAutoShowRef = useRef<boolean>(false);
|
const preventQuizAutoShowRef = useRef<boolean>(false);
|
||||||
|
|
||||||
useEffect(function setAutoShowQuizTimer() {
|
useEffect(function setAutoShowQuizTimer() {
|
||||||
|
Loading…
Reference in New Issue
Block a user