Skip to content

UI fixed route added mobile responsive #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
992 changes: 989 additions & 3 deletions frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"axios": "^1.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
"react-router-dom": "^6.23.1"
},
"devDependencies": {
Expand All @@ -21,9 +22,12 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
23 changes: 13 additions & 10 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import './App.css'
// import "./App.css";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { Simulation } from './components/Simulation';
import { Game } from './components/Game';
import { Simulation } from "./pages/Simulation";
import { Game } from "./pages/Game";
import { Footer, Navbar } from "./components";
import { Home } from "./pages/Home";

function App() {
return (
<>
<BrowserRouter>
<BrowserRouter>
<Navbar />
<Routes>
<Route path="simulation" element={<Simulation />} />
<Route path="game" element={<Game />} />
<Route path="/" element={<Home />} />
<Route path="/simulation" element={<Simulation />} />
<Route path="/game" element={<Game />} />
</Routes>
<Footer />
</BrowserRouter>
</>
)
);
}

export default App
export default App;
42 changes: 42 additions & 0 deletions frontend/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { FaGithub, FaTwitter, FaYoutube } from "react-icons/fa";
import { Link } from "react-router-dom";

export const Footer = () => {
return (
<footer className="border-t border-gray-600 py-12 text-white">
<div className="w-[96%] max-w-screen-lg mx-auto flex flex-row justify-between">
<div className="flex items-center">
<Link
to="/"
className="flex items-center space-x-3 rtl:space-x-reverse"
>
{/* <img
src="https://res.cloudinary.com/dcugqfvvg/image/upload/v1713647295/standardboard.1d6f9426_asqzum.png"
className="h-8"
alt="plinkoo Logo"
/> */}
<span className="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
Plinkoo.100x
</span>
</Link>
</div>
<div>
<div className="space-y-2">
<h1 className="text-center text-lg">Follow On</h1>
<div className="flex items-center gap-3">
<a href="https://github.com/hkirat" target="_blank">
<FaGithub size={30} />
</a>
<a href="https://www.youtube.com/@harkirat1" target="_blank">
<FaYoutube size={30} />
</a>
<a href="https://twitter.com/kirat_tw" target="_blank">
<FaTwitter size={30} />
</a>
</div>
</div>
</div>
</div>
</footer>
);
};
36 changes: 36 additions & 0 deletions frontend/src/components/FoundIssue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const FoundIssue = () => {
return (
<div className="mb-24 lg:mb-32 mt-16 lg:mt-0 bg-[#262522] w-[96%] max-w-screen-lg mx-auto px-14 py-14 rounded-[36px]">
<div className="lg:grid grid-cols-[45%,1fr] gap-28">
<div className="rounded-xl">
<img
src="https://res.cloudinary.com/dcugqfvvg/image/upload/v1713657312/undraw_questions_re_1fy7_kqjpu3.svg"
alt="chess-board"
/>
</div>
<div className="mt-16 lg:mt-0">
<h1 className="text-6xl text-white font-bold text-left mt-[-10px]">
Found an Issue!
</h1>
<p className="text-xl mt-6 text-white">
Please create an issue in our github website below. You are also
invited to contribute on the project.
</p>

<a
href="https://github.com/code100x/plinkoo/issues"
target="_blank"
className="mt-10 text-white rounded-2xl px-4 py-4 border border-slate-400 bg-transparent w-full text-2xl flex gap-10 items-center justify-center"
>
<img
className="w-16 h-16"
src="https://res.cloudinary.com/dcugqfvvg/image/upload/v1713657100/github-svgrepo-com_uosbko.svg"
alt="icon"
/>
<p className="text-4xl">Github</p>
</a>
</div>
</div>
</div>
);
};
71 changes: 71 additions & 0 deletions frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { RxHamburgerMenu } from "react-icons/rx";
import { Button } from "./ui";
import { Link, useNavigate } from "react-router-dom";
import { useState } from "react";

export const Navbar = () => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const navigate = useNavigate();
return (
<nav className="bg-white z-50 border-gray-200 dark:bg-[#262522] borbder-b shadow-lg">
<div className="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
<Link
to="/"
className="flex items-center space-x-3 rtl:space-x-reverse"
>
{/* <img
src="https://res.cloudinary.com/dcugqfvvg/image/upload/v1713647295/standardboard.1d6f9426_asqzum.png"
className="h-8"
alt="plinkoo Logo"
/> */}
<span className="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
Plinkoo.100x
</span>
</Link>
<Button
data-collapse-toggle="navbar-default"
className="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg md:hidden focus:outline-none focus:ring-2 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600 bg-transparent"
onClick={() => {
setIsMenuOpen(!isMenuOpen);
}}
>
<span className="sr-only">Open main menu</span>
<RxHamburgerMenu size={30} />
</Button>{" "}
<div
className={`w-full lg:hidden flex flex-col md:w-auto items-center ${
isMenuOpen ? "" : "hidden"
}`}
id="navbar-default"
>
<Button
className="bg-transparent mx-4 hover:bg-black w-[50%]"
onClick={() => navigate("/simulation")}
>
Simulation
</Button>
<Button
className="bg-transparent mx-4 hover:bg-black w-[50%]"
onClick={() => navigate("/game")}
>
Game
</Button>
</div>
<div className="hidden w-full md:block md:w-auto" id="navbar-default">
<Button
className="bg-transparent mx-4 hover:bg-black"
onClick={() => navigate("/simulation")}
>
Simulation
</Button>
<Button
className="bg-transparent mx-4 hover:bg-black"
onClick={() => navigate("/game")}
>
Game
</Button>
</div>
</div>
</nav>
);
};
22 changes: 22 additions & 0 deletions frontend/src/components/Quotes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useNavigate } from "react-router-dom";
import { Button } from "./ui/Button";

export const Quotes = () => {
const navigate = useNavigate();
return (
<div className="flex mx-16 flex-col justify-center pb-10 ">
<h1 className="text-6xl font-bold">Play Plinko, Earn More!</h1>
<h3 className="mt-4 text-xl mb-4">
Plinko lets players drop a ball from the top of our triangular pin
pyramid to find the winning route down to a corresponding multiplier.
Inspired by the Japanese mechanical game known as Pachinko, Plinko
provides players with the ability to customise your risk factor and
multipliers ensuring this Stake Original game is suited for everyone at
our online casino !
</h3>
<Button className="hover:bg-green-600" onClick={() => navigate("/game")}>
Play Plinko
</Button>
</div>
);
};
68 changes: 68 additions & 0 deletions frontend/src/components/Simulate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { useEffect, useRef, useState } from "react";

import { useNavigate } from "react-router-dom";
import { BallManager } from "../game/classes/BallManager";
import { pad } from "../game/padding";
import { WIDTH } from "../game/constants";

export const Simulate = () => {
const navigate = useNavigate();

const canvasRef = useRef<any>();
let [outputs, setOutputs] = useState<{ [key: number]: number[] }>({
0: [],
1: [],
2: [],
3: [],
4: [],
5: [],
6: [],
7: [],
8: [],
9: [],
10: [],
11: [],
12: [],
13: [],
14: [],
15: [],
16: [],
17: [],
});

async function simulate(ballManager: BallManager) {
let i = 0;
while (1) {
i++;
ballManager.addBall(pad(WIDTH / 2 + 20 * (Math.random() - 0.5)));
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}

useEffect(() => {
if (canvasRef.current) {
const ballManager = new BallManager(
canvasRef.current as unknown as HTMLCanvasElement,
(index: number, startX?: number) => {
setOutputs((outputs: any) => {
return {
...outputs,
[index]: [...(outputs[index] as number[]), startX],
};
});
}
);
simulate(ballManager);

return () => {
ballManager.stop();
};
}
}, [canvasRef]);

return (
<div className="flex flex-col items-center justify-center">
<canvas ref={canvasRef} width="800" height="800"></canvas>
</div>
);
};
5 changes: 5 additions & 0 deletions frontend/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./Navbar";
export * from "./Quotes";
export * from "./Simulate";
export * from "./Footer";
export * from "./FoundIssue";
18 changes: 18 additions & 0 deletions frontend/src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const Button = ({
onClick,
children,
className,
}: {
onClick: () => void;
children: React.ReactNode;
className?: string;
}) => {
return (
<button
onClick={onClick}
className={`px-2 py-2 text-2xl bg-green-500 text-white font-bold rounded ${className}`}
>
{children}
</button>
);
};
1 change: 1 addition & 0 deletions frontend/src/components/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Button";
2 changes: 1 addition & 1 deletion frontend/src/game/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const horizontalFriction = 0.4;
export const verticalFriction = 0.8;

export const sinkWidth = 36;
export const NUM_SINKS = 17
export const NUM_SINKS = 17;
13 changes: 9 additions & 4 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #0e212e;

/* background-color: #213743; */
background-color: #302e2b;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: "Times New Roman", Times, serif;
}

/*
a {
font-weight: 500;
color: #646cff;
Expand Down Expand Up @@ -65,4 +70,4 @@ button:focus-visible {
button {
background-color: #f9f9f9;
}
}
} */
Loading