From 5262140c5f82c2e183ec67d2dc3d9e4d53b45402 Mon Sep 17 00:00:00 2001 From: zakie khan <121384625+zakie2003@users.noreply.github.com> Date: Mon, 29 Dec 2025 21:30:29 +0530 Subject: [PATCH] More Cleaning --- frontend/src/Components/ClueInput.jsx | 1 + frontend/src/Components/PlayerList.jsx | 2 +- frontend/src/Components/Teams.jsx | 2 +- frontend/src/Components/ThemeToggle.jsx | 4 +++- frontend/src/constants/floating_words.js | 12 ++++++++++++ frontend/src/context/JoinContext.js | 3 +++ frontend/src/pages/Error.jsx | 2 +- frontend/src/pages/Home.jsx | 14 +------------- 8 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 frontend/src/constants/floating_words.js create mode 100644 frontend/src/context/JoinContext.js diff --git a/frontend/src/Components/ClueInput.jsx b/frontend/src/Components/ClueInput.jsx index 52c9fa1..35d0efe 100644 --- a/frontend/src/Components/ClueInput.jsx +++ b/frontend/src/Components/ClueInput.jsx @@ -35,6 +35,7 @@ const ClueInput = ({ onClueSubmit }) => { } } catch (e) { // ignore + console.error(e); } const onClueReceived = (clueData) => { diff --git a/frontend/src/Components/PlayerList.jsx b/frontend/src/Components/PlayerList.jsx index 49b3df0..6c1c159 100644 --- a/frontend/src/Components/PlayerList.jsx +++ b/frontend/src/Components/PlayerList.jsx @@ -1,4 +1,4 @@ -import { JoinContext } from "./Teams"; +import { JoinContext } from "../context/JoinContext"; import { useContext } from "react"; const PlayerList = ({ team, title, players, colorClasses }) => { diff --git a/frontend/src/Components/Teams.jsx b/frontend/src/Components/Teams.jsx index 0c62e52..257d923 100644 --- a/frontend/src/Components/Teams.jsx +++ b/frontend/src/Components/Teams.jsx @@ -7,7 +7,7 @@ import axios from "axios"; import API_URL from '../apiConfig'; -export const JoinContext = createContext(); +import { JoinContext } from "../context/JoinContext"; const Teams = ({ onDataReceived }) => { const { gameId } = useParams(); // <-- GET GAME ID FROM URL diff --git a/frontend/src/Components/ThemeToggle.jsx b/frontend/src/Components/ThemeToggle.jsx index 7aff1c6..486a94c 100644 --- a/frontend/src/Components/ThemeToggle.jsx +++ b/frontend/src/Components/ThemeToggle.jsx @@ -20,7 +20,9 @@ export default function ThemeToggle() { document.documentElement.classList.remove('dark') localStorage.setItem('theme', 'light') } - } catch {} + } catch (e){ + console.error(e); + } }, [dark]) return ( diff --git a/frontend/src/constants/floating_words.js b/frontend/src/constants/floating_words.js new file mode 100644 index 0000000..92898e9 --- /dev/null +++ b/frontend/src/constants/floating_words.js @@ -0,0 +1,12 @@ +export const FLOATING_WORDS = [ + 'AGENT', 'CLUE', 'CONTACT', 'DECRYPT', 'ENCODE', 'MISSION', + 'REVEALER', 'CONCEALER', 'INTEL', 'ASSASSIN', 'RED', 'BLUE', + 'FIELD', 'CODE', 'TARGET', 'WILD', 'DANGER', 'SECRET', 'PUZZLE', + 'SPY', 'CARD', 'GUESS', 'TURN', 'SCORE', 'TEAM', 'COVER', 'TRAITOR', // New words + 'HIDDEN', 'KEY', 'WORD', 'CYPHER', 'LOCATE', 'VECTOR', 'CONFIRM', 'PASS', // More new words + + // Doubling the list for higher density + 'CLUE', 'AGENT', 'ENCODE', 'MISSION', 'REVEALER', 'INTEL', + 'RED', 'BLUE', 'FIELD', 'CODE', 'TARGET', 'DANGER', 'SECRET', 'PUZZLE', + 'SPY', 'CARD', 'GUESS', 'SCORE', 'TEAM', 'HIDDEN', 'KEY', 'WORD' // Doubled new words +]; \ No newline at end of file diff --git a/frontend/src/context/JoinContext.js b/frontend/src/context/JoinContext.js new file mode 100644 index 0000000..4d3cdd6 --- /dev/null +++ b/frontend/src/context/JoinContext.js @@ -0,0 +1,3 @@ +import { createContext } from "react"; + +export const JoinContext = createContext(); \ No newline at end of file diff --git a/frontend/src/pages/Error.jsx b/frontend/src/pages/Error.jsx index 63e58db..b5c03bc 100644 --- a/frontend/src/pages/Error.jsx +++ b/frontend/src/pages/Error.jsx @@ -3,7 +3,7 @@ import { useNavigate, Link } from "react-router-dom"; import ThemeToggle from "../Components/ThemeToggle"; // Floating words used on the Home page — keep consistent here -import {FLOATING_WORDS} from "./Home"; +import { FLOATING_WORDS } from "../constants/floating_words"; // const FLOATING_WORDS = [ // 'AGENT', 'CLUE', 'MISSION', 'INTEL', 'SECRET', 'SPY', 'CARD', 'GUESS', 'TEAM', 'CODE', // 'RED', 'BLUE', 'HIDDEN', 'KEY', 'WORD' diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 3813efd..999e301 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -4,19 +4,7 @@ import axios from "axios"; import ThemeToggle from '../Components/ThemeToggle'; import API_URL from '../apiConfig'; -// List of words for the animated background (Increased density) -export const FLOATING_WORDS = [ - 'AGENT', 'CLUE', 'CONTACT', 'DECRYPT', 'ENCODE', 'MISSION', - 'REVEALER', 'CONCEALER', 'INTEL', 'ASSASSIN', 'RED', 'BLUE', - 'FIELD', 'CODE', 'TARGET', 'WILD', 'DANGER', 'SECRET', 'PUZZLE', - 'SPY', 'CARD', 'GUESS', 'TURN', 'SCORE', 'TEAM', 'COVER', 'TRAITOR', // New words - 'HIDDEN', 'KEY', 'WORD', 'CYPHER', 'LOCATE', 'VECTOR', 'CONFIRM', 'PASS', // More new words - - // Doubling the list for higher density - 'CLUE', 'AGENT', 'ENCODE', 'MISSION', 'REVEALER', 'INTEL', - 'RED', 'BLUE', 'FIELD', 'CODE', 'TARGET', 'DANGER', 'SECRET', 'PUZZLE', - 'SPY', 'CARD', 'GUESS', 'SCORE', 'TEAM', 'HIDDEN', 'KEY', 'WORD' // Doubled new words -]; +import { FLOATING_WORDS } from '../constants/floating_words'; // Reusable component for a single floating word (for clarity) const FloatingWord = ({ word, x, y, size, delay, duration }) => (