RiddleScreen and RIDDLESSS improvements

This commit is contained in:
LionTion committed 2026-10-07 21:21:09 +02:00
1 parent 5ac5ba72da
commit bfdb2d01d1
16 files changed
+165 -70

No files matched your search

+44 -16
View File
@@ -2,7 +2,7 @@ import clsx from "clsx";
import styles from "@/css/RiddleScreen.module.css";
import StyledContainer from "./StyledContainer";
import OldButton from "./OldButton";
import { Dispatch, SetStateAction, useState } from "react";
import { ComponentType, Dispatch, SetStateAction, useRef, useState } from "react";
import Riddle_1 from "./riddles/Riddle_1";
import Riddle_2 from "./riddles/Riddle_2";
import Riddle_3 from "./riddles/Riddle_3";
@@ -12,11 +12,17 @@ import Riddle_6 from "./riddles/Riddle_6";
import Riddle_7 from "./riddles/Riddle_7";
import Riddle_8 from "./riddles/Riddle_8";
import Riddle_9 from "./riddles/Riddle_9";
import { useLocalStorage } from "@/hooks/useLocalStorage";
import { PREF } from "@/utils/const";
import { VoiceOverMode } from "@/types/voiceOverMode";
export interface RiddleScreenControls {
riddle: any;
exitFunction: () => void;
showBanner: Dispatch<SetStateAction<boolean>>;
page: number;
setPage: (pageIndex: number) => void;
voiceOverMode: VoiceOverMode;
};
interface RiddleScreenProps {
@@ -25,26 +31,46 @@ interface RiddleScreenProps {
};
export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
const [ page, setPage ] = useState(0);
const [page, setPage ] = useState(0);
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
const [ showBanner, setShowBanner ] = useState(true);
const contentRef = useRef<HTMLDivElement | null>(null);
console.log(riddle);
const exitFunction = () => {
onDismiss();
};
const riddleComponents = {
"riddle_1": <Riddle_1 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_1>,
"riddle_2": <Riddle_2 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_2>,
"riddle_3": <Riddle_3 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_3>,
"riddle_4": <Riddle_4 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_4>,
"riddle_5": <Riddle_5 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_5>,
"riddle_6": <Riddle_6 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_6>,
"riddle_7": <Riddle_7 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_7>,
"riddle_8": <Riddle_8 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_8>,
"riddle_9": <Riddle_9 riddle={riddle} exitFunction={exitFunction} showBanner={setShowBanner}></Riddle_9>
const pageUpdateFunction = (pageIndex: number) => {
setPage(pageIndex);
if (contentRef.current !== null) {
contentRef.current.scrollTop = 0;
}
};
const props: RiddleScreenControls = {
"page": page,
"setPage": pageUpdateFunction,
"riddle": riddle,
"showBanner": setShowBanner,
"exitFunction": exitFunction,
"voiceOverMode": voiceOverState as VoiceOverMode,
};
const riddleComponents: Record<string, ComponentType<RiddleScreenControls>> = {
"riddle_1": Riddle_1,
"riddle_2": Riddle_2,
"riddle_3": Riddle_3,
"riddle_4": Riddle_4,
"riddle_5": Riddle_5,
"riddle_6": Riddle_6,
"riddle_7": Riddle_7,
"riddle_8": Riddle_8,
"riddle_9": Riddle_9
};
const SelectedRiddle = riddleComponents[riddle["id"]];
return (
<div className={clsx("screen-container", styles["container"])}>
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
@@ -58,17 +84,19 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
}} alt="Background" loading="eager"/>
<StyledContainer riddleDesign={true}>
<div className={styles["actions-bookmark"]}>
<img src={"/icons/hinweis.svg"} className={styles["bookmark-icon"]} style={{marginTop: "12px"}} onClick={() => alert("Error: Hinweis-Daten nicht geladen")} />
<img src={"/icons/sprechblase.svg"} className={styles["bookmark-icon"]} style={{marginBottom: "32px"}} onClick={() => alert("Audio einfügen")} />
<img src={"/icons/hinweis.svg"} className={styles["bookmark-icon"]} style={{width: "20px", height: "auto", margin: "12px 24px", marginTop: "12px"}} onClick={() => alert("Error: Hinweis-Daten nicht geladen")} />
<img src={voiceOverState === "off" ? "/icons/Vorlese-Icon.svg" : "/icons/Vorlese-Icon-leise.svg"} className={styles["bookmark-icon"]} style={{width: "28px", height: "24px", margin: "0px 20px 24px"}} onClick={() => {
setVoiceOverState(voiceOverState === "off" ? "on" : "off");
}} />
</div>
<img src="/icons/kreuz.svg" className={styles["close"]} onClick={onDismiss}/>
<div className={styles["content-container"]}>
<div className={styles["content-container"]} ref={contentRef}>
{ showBanner ? <div className={styles["title"]}>
<p className="eisenkraft-regular" style={{fontSize: "1.25rem", color: "var(--blue)"}}>{riddle["station_name"]}</p>
<p className="eisenkraft-regular" style={{fontSize: "1.75rem", color: "var(--blue)"}}>{riddle["station_title"]}</p>
<img src={"/res/tour/" + riddle["id"] + "/story.svg"} width={"75%"}/>
</div> : null }
{riddleComponents[riddle["id"]]}
{ SelectedRiddle ? <SelectedRiddle {...props}></SelectedRiddle> : <p style={{color: "red"}}>Station konnte nicht gefunden werden!</p>}
</div>
</StyledContainer>
</div>