Initial commit
Some checks failed
Publish Docker image / Push Docker image to Docker Hub (push) Failing after 4m2s

This commit is contained in:
2025-02-27 19:24:14 +01:00
parent 9318052560
commit 62acb290fe
27 changed files with 4873 additions and 0 deletions

15
client/src/App.jsx Normal file
View File

@@ -0,0 +1,15 @@
import Home from "./pages/Home";
import {useContext} from "react";
import {StateContext} from "@/common/contexts/StateContext";
const App = () => {
const {currentState} = useContext(StateContext);
return (
<>
{currentState === "Home" && <Home />}
</>
)
}
export default App

View File

@@ -0,0 +1,30 @@
import {createContext} from "react";
import {io} from "socket.io-client";
export const SocketContext = createContext({});
export const SocketProvider = ({ children }) => {
const socket = io("/", {autoConnect: false});
const connect = () => {
socket.connect();
}
const send = (event, data) => {
socket.emit(event, data);
}
const disconnect = () => {
socket.disconnect();
}
const addListener = (event, callback) => {
socket.on(event, callback);
}
return (
<SocketContext.Provider value={{connect, disconnect, send, addListener}}>
{children}
</SocketContext.Provider>
)
}

View File

@@ -0,0 +1 @@
export * from "./SocketContext";

View File

@@ -0,0 +1,13 @@
import {createContext, useState} from "react";
export const StateContext = createContext({});
export const StateProvider = ({ children }) => {
const [currentState, setCurrentState] = useState("Home");
return (
<StateContext.Provider value={{currentState, setCurrentState}}>
{children}
</StateContext.Provider>
)
}

View File

@@ -0,0 +1 @@
export * from "./StateContext";

View File

View File

@@ -0,0 +1,17 @@
@use "@/common/styles/colors" as *
*
box-sizing: border-box
body, html
margin: 0
padding: 0
background-color: #232529
letter-spacing: 0.2rem
color: #E0E0E0
height: 100%
font-family: 'Bangers', sans-serif
::-webkit-scrollbar
width: 10px

21
client/src/main.jsx Normal file
View File

@@ -0,0 +1,21 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "@fontsource/bangers";
import "@/common/styles/main.sass";
import {StateProvider} from "@/common/contexts/StateContext";
import {SocketProvider} from "@/common/contexts/SocketContext";
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<div className="app">
<StateProvider>
<SocketProvider>
<App/>
</SocketProvider>
</StateProvider>
</div>
</React.StrictMode>,
);

View File

@@ -0,0 +1,13 @@
import "./styles.sass";
import {StateContext} from "@/common/contexts/StateContext";
import {useContext} from "react";
export const Home = () => {
const {setCurrentState} = useContext(StateContext);
return (
<div className="home-page">
<h2>ToneGuessr</h2>
</div>
);
}

View File

@@ -0,0 +1 @@
export {Home as default} from "./Home";

View File

@@ -0,0 +1,8 @@
.home-page
display: flex
align-items: center
justify-content: center
height: 100vh
h2
font-size: 48pt