diff --git a/src/App.tsx b/src/App.tsx
index 40406a9..0faef9c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -9,7 +9,7 @@ const AppRoutes = () => {
} />
} />
- } />
+ } />
} />
);
diff --git a/src/components/Gallery/index.module.css b/src/components/Gallery/index.module.css
index b9df346..81a4051 100644
--- a/src/components/Gallery/index.module.css
+++ b/src/components/Gallery/index.module.css
@@ -1,61 +1,62 @@
-h1{
- font-size: 40px;
+h1 {
+ font-size: 40px;
}
-.title{
- position: absolute;
- top: 0;
- left: 0;
- z-index: 1;
- padding: 16px;
- margin: 0;
-}
-.nobori img{
- position: absolute;
- bottom: 0;
- left: -240px;
- height: 80vh;
- aspect-ratio: 1 / 1;
- z-index: -1;
+.title {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 1;
+ padding: 16px;
+ margin: 0;
+ cursor: pointer;
+}
+.nobori img {
+ position: absolute;
+ bottom: 0;
+ left: -240px;
+ height: 80vh;
+ aspect-ratio: 1 / 1;
+ z-index: -1;
}
-.light img{
- position: absolute;
- top: 0;
- left: 0px;
- height: 80vh;
- aspect-ratio: 1 / 1;
- z-index: -1;
+.light img {
+ position: absolute;
+ top: 0;
+ left: 0px;
+ height: 80vh;
+ aspect-ratio: 1 / 1;
+ z-index: -1;
}
.container {
- display: flex;
- align-items: flex-end;
- position: absolute;
- bottom: 16px;
- left: 4vw;
- z-index: 1;
+ display: flex;
+ align-items: flex-end;
+ position: absolute;
+ bottom: 16px;
+ left: 4vw;
+ z-index: 1;
}
.logo img {
- height: 16vh;
- aspect-ratio: 1 / 1;
- margin-right: 2vw;
+ height: 16vh;
+ aspect-ratio: 1 / 1;
+ margin-right: 2vw;
}
.shop {
- color: var(--white);
- font-size: 4vw;
- padding: 16px;
- margin: 0;
+ color: var(--white);
+ font-size: 4vw;
+ padding: 16px;
+ margin: 0;
}
-.light-right img{
- position: absolute;
- top: 0;
- right: 0px;
- height: 80vh;
- aspect-ratio: 1 / 1;
- z-index: -1;
- transform: scale(-1, 1);
-}
\ No newline at end of file
+.light-right img {
+ position: absolute;
+ top: 0;
+ right: 0px;
+ height: 80vh;
+ aspect-ratio: 1 / 1;
+ z-index: -1;
+ transform: scale(-1, 1);
+}
diff --git a/src/components/Gallery/index.tsx b/src/components/Gallery/index.tsx
index af3ee94..1944664 100644
--- a/src/components/Gallery/index.tsx
+++ b/src/components/Gallery/index.tsx
@@ -1,6 +1,20 @@
+import { useNavigate } from "react-router-dom";
+import { useRoomIdStore, useTargetStatusStore } from "../../store";
import styles from "./index.module.css";
function Gallery() {
+ const navigate = useNavigate();
+ const updateUUID = useRoomIdStore((state) => state.updateUUID);
+ const resetTargetStatus = useTargetStatusStore(
+ (state) => state.resetTargetStatus,
+ );
+
+ const handleClick = () => {
+ resetTargetStatus();
+ updateUUID();
+ navigate("/");
+ };
+
return (
{/* biome-ignore lint/a11y/useMediaCaption: 夏祭りの音を再生します。 */}
@@ -10,7 +24,15 @@ function Gallery() {
loop
aria-label="夏祭りの音"
/>
-
VIRTUAL_NATSUMATSURI
+
{
+ handleClick();
+ }}
+ onKeyDown={() => {}}
+ className={styles.title}
+ >
+ VIRTUAL_NATSUMATSURI
+
diff --git a/src/hooks/useSocketSender.ts b/src/hooks/useSocketSender.ts
index ca6eb51..306690b 100644
--- a/src/hooks/useSocketSender.ts
+++ b/src/hooks/useSocketSender.ts
@@ -31,7 +31,6 @@ export const useSocketSender = () => {
message_type: mes_type,
event_type: event_type.shooter,
};
- console.log(data);
socketRef?.current?.send(JSON.stringify(data));
},
[socketRef],
diff --git a/src/pages/result/index.module.css b/src/pages/result/index.module.css
index ce483cf..1a6e17f 100644
--- a/src/pages/result/index.module.css
+++ b/src/pages/result/index.module.css
@@ -1,36 +1,36 @@
.result-text {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- font-size: 40px;
+ position: absolute;
+ left: 50%;
+ transform: translateX(-50%);
+ font-size: 40px;
+ z-index: 1;
}
-.background-logo{
- opacity: 0.6;
- position: absolute;
- top: 40%;
- left: 50%;
- transform: translate(-50%, -50%);
- justify-content: center;
- align-items: center;
-
+.background-logo {
+ opacity: 0.6;
+ position: absolute;
+ top: 40%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ justify-content: center;
+ align-items: center;
}
.get-text {
- position: absolute;
- top: 60%;
- left: 50%;
- transform: translateX(-50%);
- font-size: 40px;
- white-space: nowrap;
+ position: absolute;
+ top: 60%;
+ left: 50%;
+ transform: translateX(-50%);
+ font-size: 40px;
+ white-space: nowrap;
}
-.share-btn{
- position: absolute;
- top: 80%;
- left: 50%;
- transform: translateX(-50%);
- white-space: nowrap;
+.share-btn {
+ position: absolute;
+ top: 80%;
+ left: 50%;
+ transform: translateX(-50%);
+ white-space: nowrap;
}
.replay-text {
@@ -39,30 +39,29 @@
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
- font-family: 'Yuji Syuku', serif, sans-serif;
+ font-family: "Yuji Syuku", serif, sans-serif;
line-height: 1.5;
font-weight: 400;
font-style: normal;
}
@keyframes rotate {
- from {
- transform: translate(-50%, -50%) rotate(0deg);
- }
- to {
- transform: translate(-50%, -50%) rotate(360deg);
- }
+ from {
+ transform: translate(-50%, -50%) rotate(0deg);
+ }
+ to {
+ transform: translate(-50%, -50%) rotate(360deg);
+ }
}
.get-image-container {
- position: absolute;
- top: 40%;
- left: 50%;
- transform: translate(-50%, -50%);
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 1;
- animation: rotate 16s linear infinite;
+ position: absolute;
+ top: 40%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 1;
+ animation: rotate 16s linear infinite;
}
-
diff --git a/src/pages/result/index.tsx b/src/pages/result/index.tsx
index 7c04145..e9e9266 100644
--- a/src/pages/result/index.tsx
+++ b/src/pages/result/index.tsx
@@ -1,12 +1,10 @@
import GetImage from "../../components/GetImage";
import { DefaultButton } from "../../components/ui/Button";
+import { useScoreStore } from "../../store/useScoreStore";
import styles from "./index.module.css";
-type ResultProps = {
- score: number;
-};
-
-const Result = ({ score }: ResultProps) => {
+const Result = () => {
+ const score = useScoreStore((state) => state.score);
const image =
score >= 0 && score <= 3
? `/drink/bottle${score}.webp`
diff --git a/src/pages/shooter/index.tsx b/src/pages/shooter/index.tsx
index 120d442..691a997 100644
--- a/src/pages/shooter/index.tsx
+++ b/src/pages/shooter/index.tsx
@@ -1,29 +1,28 @@
-import { useNavigate } from "react-router-dom";
import {
type KeyboardEventHandler,
useCallback,
useEffect,
useState,
} from "react";
+import { useNavigate } from "react-router-dom";
import { DefaultButton } from "../../components/ui/Button";
import { Modal } from "../../components/ui/Modal";
import { ShooterButton } from "../../components/ui/ShooterButton";
import type { Orientation } from "../../hooks/useOrientation";
+import { useSocketReceiver } from "../../hooks/useSocketReceiver";
import { useSocketSender } from "../../hooks/useSocketSender";
import { useUUIDStore } from "../../store";
import { useScoreStore } from "../../store/useScoreStore";
import { message_type } from "../../type/schema";
-import style from "./index.module.css";
import { MessageType } from "../../type/shooting";
-import { useSocketReceiver } from "../../hooks/useSocketReceiver";
+import styles from "./index.module.css";
const Shooter = () => {
const [isOpen, setIsOpen] = useState(true);
const { sendData } = useSocketSender();
const { onMessage } = useSocketReceiver();
- const addOneScore = useScoreStore((state) => state.addOneScore);
const navigate = useNavigate();
- const score = useScoreStore((state) => state.score);
+ const addOneScore = useScoreStore((state) => state.addOneScore);
const initialImages = [
"/2D_material/cork.webp",
@@ -32,7 +31,6 @@ const Shooter = () => {
];
const [images, setImages] = useState(initialImages);
const uuid = useUUIDStore((state) => state.uuid);
- // const intervalId = useRef
(null);
const [initialOrientation, setInitialOrientation] = useState({
alpha: 0,
beta: 0,
@@ -44,7 +42,6 @@ const Shooter = () => {
if (!event.alpha || !event.beta || !event.gamma) {
return;
}
- console.log(event.alpha, event.beta, event.gamma);
sendData(msg_type, uuid, {
alpha: initialOrientation
? (event.gamma - initialOrientation.gamma) * 2
@@ -72,18 +69,22 @@ const Shooter = () => {
};
}, [send]);
+ // biome-ignore lint/correctness/useExhaustiveDependencies: 初期化処理だけでいいため依存配列は空配列にしている
useEffect(() => {
onMessage((data) => {
if (data.message_type === MessageType.Hit && data.id === uuid) {
addOneScore();
}
});
- }, [onMessage, uuid, addOneScore]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
useEffect(() => {
if (images.length === 0) {
- navigate("/result", { state: { score } });
+ navigate("/result");
}
- }, [images, navigate, score]);
+ }, [images, navigate]);
+
const handleClick = async () => {
window.addEventListener(
"deviceorientation",
@@ -102,7 +103,7 @@ const Shooter = () => {
const handleKeyUp: KeyboardEventHandler = (event) => {
if (event.key === "Enter" || event.key === " ") {
- handleClick();
+ // handleClick();
}
};
@@ -114,10 +115,10 @@ const Shooter = () => {
setInitialOrientation={setInitialOrientation}
/>
-
+
-
+
{images.length > 0 ? (
images.map((src, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey:
@@ -155,21 +156,21 @@ const ModalContent: React.FC = ({
setIsOpen(false);
};
return (
-
+
-
-
+
+
スマホを画面に向かって
垂直に机の上に置いてね
-
+
void;
};
-export const useScoreStore = create((set) => ({
+export const useScoreStore = create()((set) => ({
score: 0,
setScore: (score) => set(() => ({ score: score })),
addOneScore: () => set((state) => ({ score: state.score + 1 })),
diff --git a/src/store/useTargetStatusStore.ts b/src/store/useTargetStatusStore.ts
index dcda4c1..96dc6e9 100644
--- a/src/store/useTargetStatusStore.ts
+++ b/src/store/useTargetStatusStore.ts
@@ -7,6 +7,7 @@ type State = {
type Action = {
updateTargetStatus: (index: number, status: TargetStatus) => void;
+ resetTargetStatus: () => void;
};
export const useTargetStatusStore = create((set) => ({
@@ -18,4 +19,8 @@ export const useTargetStatusStore = create((set) => ({
targetStatus[index] = status;
return { targetStatus };
}),
+ resetTargetStatus: () =>
+ set(() => ({
+ targetStatus: [TargetStatus.Live, TargetStatus.Live, TargetStatus.Live],
+ })),
}));
diff --git a/src/utils/copyClipBoard.ts b/src/utils/copyClipBoard.ts
index 1652119..1a77e0c 100644
--- a/src/utils/copyClipBoard.ts
+++ b/src/utils/copyClipBoard.ts
@@ -1,8 +1,6 @@
export const copyStringToClipboard = (text: string) => {
navigator.clipboard.writeText(text).then(
- () => {
- console.log("Async: Copying to clipboard was successful!");
- },
+ () => {},
(err) => {
console.error("Async: Could not copy text: ", err);
},