Skip to content
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

Project-Labyrinth #12

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb2fe22
post data setting
trista1987 Apr 15, 2024
01187b9
first fetch done
trista1987 Apr 16, 2024
5c6e0f3
added comments
trista1987 Apr 16, 2024
9b9d135
start to fetch second data
trista1987 Apr 16, 2024
d5d4ef3
change
trista1987 Apr 16, 2024
9f7519c
Co-authored-by: Nathalie Tu <[email protected]>
trista1987 Apr 16, 2024
5ad4d8a
updated
trista1987 Apr 16, 2024
4d8e75d
added a notes
trista1987 Apr 16, 2024
97ad0ad
one button works
trista1987 Apr 17, 2024
b956d99
tried and failed
trista1987 Apr 18, 2024
1516f6c
toggle button made
trista1987 Apr 19, 2024
a5f392b
fixed one thing, broke another
ohitsnathalie Apr 19, 2024
f9232e4
change something again. but not working
ohitsnathalie Apr 20, 2024
e923a1a
fixed issue partially with direction buttons
ohitsnathalie Apr 20, 2024
a45480e
Co-authored-by: Trista Shan <[email protected]>
ohitsnathalie Apr 20, 2024
e612a41
fixed issue with fetching
ohitsnathalie Apr 20, 2024
3d497f6
little bit of styling. added favicon and metadata
ohitsnathalie Apr 20, 2024
3c9a998
deleted some unused files, added fonts, changed readme
ohitsnathalie Apr 21, 2024
e428f18
changed one image
ohitsnathalie Apr 21, 2024
05b7366
added loading animation
ohitsnathalie Apr 21, 2024
ceef977
changed images and trying some styling
ohitsnathalie Apr 21, 2024
091e95b
adjusted the homepage
ohitsnathalie Apr 21, 2024
8b0e135
added @media and did some other styling
ohitsnathalie Apr 21, 2024
40407a2
changed opacity
ohitsnathalie Apr 21, 2024
f9578ac
Merge branch 'pland'
ohitsnathalie Apr 21, 2024
de35b04
changed src img link in readme
ohitsnathalie Apr 21, 2024
ece7549
changed some image
ohitsnathalie Apr 21, 2024
577ceca
worked on responsiveness
ohitsnathalie Apr 21, 2024
74a68fa
installed lottie
trista1987 Apr 21, 2024
dd6f3fb
updated readme
trista1987 Apr 21, 2024
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
27 changes: 7 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
<h1 align="center">
<a href="">
<img src="./src/assets/banner.svg" alt="Project Banner Image">
<img src="public/cover-image-github.png" alt="Project preview image">
</a>
</h1>

# Labyrinth - Zustand Project

Replace this readme with your own information about your project.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.

## Getting Started with the Project

### Dependency Installation & Startup Development Server

Once cloned, navigate to the project's root directory and this project uses npm (Node Package Manager) to manage its dependencies.

The command below is a combination of installing dependencies, opening up the project on VS Code and it will run a development server on your terminal.

```bash
npm i && code . && npm run dev
```
This project is a labyrinth game app and is using the zustand library. Fetching from an API to show players where they can navigate.

### The Problem

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
First we tried to layout what we needed and what we wanted to achieve. Next step was to take a look at the API results in Postman. We struggle to fetch 'POST' from two different URLs and connecting them.
Thanks to help from a fellow bootcamp student, the game finally worked. It took longer than we expected and wanted to.

### View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
Here our maze game.

## Instructions

<a href="instructions.md">
See instructions of this project
<a href="https://fun-maze.netlify.app/">
Labyrinth Maze
</a>
27 changes: 23 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Project Labyrinth Zustand</title>
<link
rel="icon"
type="image/png"
href="/maze.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0" />
<meta
property="og:title"
content="The Maze – Trista's & Nathalie's Zustand Project" />
<meta
property="og:type"
content="website" />
<meta
property="og:description"
content="Find your way out through the digital maze" />
<meta
name="description"
content="Find your way out through the digital maze" />
<title>The Maze – Trista's & Nathalie's Zustand Project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<script
type="module"
src="/src/main.jsx"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
"preview": "vite preview"
},
"dependencies": {
"lottie": "^0.0.1",
"lottie-react": "^2.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"zustand": "^4.4.1"
"react-router-dom": "^6.22.3",
"zustand": "^4.5.2"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
Binary file added public/cover-image-github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/maze-entrance.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/maze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

7 changes: 0 additions & 7 deletions pull_request_template.md

This file was deleted.

24 changes: 19 additions & 5 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { Username } from "./components/Username"
import { useStore } from "./store/useStore"
import { StartGame } from "./components/StartGame"
// import { BrowserRouter, Routes} from "react-router-dom";
// import { routes } from "./routes/routes";

export const App = () => {
const { username } = useStore()

return (
<div>
Labyrinth Project
</div>
);
};
<>
{/* <BrowserRouter> */}
<div>
{!username && <Username />}
{username && <StartGame />}
</div>

{/* <Routes>{routes}</Routes>
</BrowserRouter> */}
</>
Comment on lines +11 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused code and the fragment and just wrap everything in a div for cleaner code

)
}
Binary file added src/assets/MAZE_RUNNER.ttf
Binary file not shown.
Binary file added src/assets/Montserrat-VariableFont_wght.ttf
Binary file not shown.
18 changes: 0 additions & 18 deletions src/assets/banner.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/assets/loading.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.1.18","fr":30,"ip":0,"op":120,"w":1080,"h":1080,"nm":"Loader 2","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Outline Sides 4","parent":2,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[102.47,68.411,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[21.675,21.675,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-108.75,-72.625],[-179.313,-141.563],[-297,-19.5],[-158.188,117.188],[-85.25,44]],"o":[[-108.75,-72.625],[-179.313,-141.563],[-297,-19.5],[-158.188,117.188],[-85.25,44]],"v":[[-108.75,-72.625],[-179.313,-141.563],[-297,-19.5],[-158.188,117.188],[-85.25,44]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false,"_render":true},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[109.5,-72.75],[177.438,-141.563],[315.75,-3],[198.25,113.5],[130,45]],"o":[[109.5,-72.75],[177.438,-141.563],[315.75,-3],[198.25,113.5],[130,45]],"v":[[109.5,-72.75],[177.438,-141.563],[315.75,-3],[198.25,113.5],[130,45]],"c":false},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false,"_render":true},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform","_render":true}],"nm":"Shape 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false,"_render":true},{"ty":"tm","s":{"a":0,"k":42,"ix":1},"e":{"a":0,"k":0,"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.447],"y":[0.812]},"o":{"x":[0.546],"y":[0.209]},"n":["0p447_0p812_0p546_0p209"],"t":0,"s":[-76],"e":[644]},{"t":119}],"ix":3},"m":2,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false,"_render":true},{"ty":"gs","o":{"a":0,"k":100,"ix":9},"w":{"a":0,"k":29,"ix":10},"g":{"p":3,"k":{"a":0,"k":[0,0.42,0.42,0.42,0.206,0.7255,0.7255,0.7255,0.77,0.27,0.27,0.27],"ix":8}},"s":{"a":0,"k":[-73,0],"ix":4},"e":{"a":0,"k":[151,0],"ix":5},"t":1,"lc":1,"lj":1,"ml":4,"nm":"Gradient Stroke 2","mn":"ADBE Vector Graphic - G-Stroke","hd":false,"_render":true}],"ip":0,"op":120,"st":-27,"bm":0,"completed":true},{"ddd":0,"ind":2,"ty":4,"nm":"Fill Center","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[520.938,518.938,0],"ix":2},"a":{"a":0,"k":[103.5,66,0],"ix":1},"s":{"a":0,"k":[461.353,461.353,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-19.15,14.9],[-2.15,31.9],[31.85,-2.1],[27.55,-6.4],[-2.15,23.4],[-14.85,10.6],[6.45,-10.7],[2.15,-15],[-19.15,6.4],[-23.45,10.7]],"o":[[-19.15,14.9],[-2.15,31.9],[31.85,-2.1],[27.55,-6.4],[-2.15,23.4],[-14.85,10.6],[6.45,-10.7],[2.15,-15],[-19.15,6.4],[-23.45,10.7]],"v":[[-19.15,14.9],[-2.15,31.9],[31.85,-2.1],[27.55,-6.4],[-2.15,23.4],[-14.85,10.6],[6.45,-10.7],[2.15,-15],[-19.15,6.4],[-23.45,10.7]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false,"_render":true},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[19.15,-14.9],[6.35,-27.6],[2.05,-31.9],[-2.15,-27.6],[-31.85,2.1],[-27.55,6.3],[2.15,-23.4],[14.85,-10.6],[-6.35,10.6],[-2.05,14.9],[19.251,-6.4],[23.55,-10.6]],"o":[[19.15,-14.9],[6.35,-27.6],[2.05,-31.9],[-2.15,-27.6],[-31.85,2.1],[-27.55,6.3],[2.15,-23.4],[14.85,-10.6],[-6.35,10.6],[-2.05,14.9],[19.251,-6.4],[23.55,-10.6]],"v":[[19.15,-14.9],[6.35,-27.6],[2.05,-31.9],[-2.15,-27.6],[-31.85,2.1],[-27.55,6.3],[2.15,-23.4],[14.85,-10.6],[-6.35,10.6],[-2.05,14.9],[19.251,-6.4],[23.55,-10.6]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false,"_render":true},{"ty":"tr","p":{"a":0,"k":[104.954,65.304],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform","_render":true}],"nm":"Group 3","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false,"_render":true},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"g":{"p":3,"k":{"a":0,"k":[0.088,0.42,0.42,0.42,0.374,0.7255,0.7255,0.7255,0.95,0.27,0.27,0.27],"ix":9}},"s":{"a":0,"k":[62,13],"ix":5},"e":{"a":0,"k":[100,0],"ix":6},"t":1,"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill","hd":false,"_render":true}],"ip":0,"op":120,"st":0,"bm":0,"completed":true}],"markers":[],"__complete":true}
51 changes: 51 additions & 0 deletions src/components/StartGame.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Lottie from "lottie-react"
import { useStore } from "../store/useStore"
import "../styles/StartGame.css"
import Loading from "../assets/loading.json"

export const StartGame = () => {
const { gameInfo, setActionData, fetchActionData, loading, actionData } =
useStore()

const handleClick = async (actionDirection) => {
await setActionData(actionDirection)
await fetchActionData()
}

if (loading) {
return (
<Lottie
animationData={Loading}
loop={true}
/>
)
}

return (
<div className='start-game-container'>
<p>{actionData ? actionData.description : gameInfo?.description}</p>
{/* If there is actionData, show the description */}
<div className='direction-container'>
{/* If there is no actionData, show gameinfo */}
{!actionData &&
gameInfo?.actions?.map((action, index) => (
<div key={index}>
<p>{action.description}</p>
<button onClick={() => handleClick(action.direction)}>
Go {action.direction}
</button>
</div>
))}
</div>
{/* Descriptions are now displayed consistently here */}
{actionData?.actions?.map((action, index) => (
<div key={index}>
<p>{action.description}</p>
<button onClick={() => handleClick(action.direction)}>
Go {action.direction}
</button>
</div>
))}
</div>
)
}
49 changes: 49 additions & 0 deletions src/components/Username.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Lottie from "lottie-react"
import { useStore } from "../store/useStore"
import { useState } from "react"
import "../styles/Username.css"
import Loading from "../assets/loading.json"

export const Username = () => {
const [usernameInput, setUsernameInput] = useState("") //this is local value, not the global one. the hook is for updating username
const { setUsername, fetchStartData, loading, error } = useStore() //import variable from globle state

//fetch data by using the fetch funcion from global state
const handleSubmit = async () => {
setUsername(usernameInput)
await fetchStartData(usernameInput)
}

if (loading) {
return (
<Lottie
animationData={Loading}
loop={true}
/>
)
}
Comment on lines +17 to +24

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liking this! Very labyrinthy 😏


if (error) {
return <div>Error: {error}</div>
}

return (
<div className='start-background'>
<div className='main-container'>
<h1>THE MAZE</h1>
<p>Can you find a way out of the maze?</p>
<p>Enter the labyrinth at your own risk.</p>
<br />
</div>
<form onSubmit={handleSubmit}>
<label> Enter your username: </label>
<input
type='text'
value={usernameInput}
onChange={(e) => setUsernameInput(e.target.value)}
/>
Comment on lines +40 to +44

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't want to allow empty inputs

<button type='submit'>Submit</button>
</form>
</div>
)
}
116 changes: 33 additions & 83 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-family: "Montserrat", sans-serif;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
color: #e1e1e1;
}

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
@font-face {
font-family: Maze Runner;
src: url(./assets/MAZE_RUNNER.ttf);
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
@font-face {
font-family: Montserrat;
src: url(./assets/Montserrat-VariableFont_wght.ttf);
}
a:hover {
color: #535bf2;

* {
margin: 0;
padding: 0;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
justify-content: center;
align-items: center;
text-align: center;
background-image: url(/maze-entrance.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
font-family: "Maze Runner", sans-serif;
}

p {
margin: 2rem 1rem 0.5rem;
}

button {
border-radius: 8px;
border: 1px solid transparent;
border: 1px solid #515050;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
background-color: #e1e1e1;
cursor: pointer;
transition: border-color 0.25s;
font-family: "Maze Runner", sans-serif;
}
button:hover {
border-color: #646cff;
Expand All @@ -55,65 +61,9 @@ button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

/* APP Component CSS */
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
@media all and (min-width: 668px) {
p {
font-size: 1.2rem;
margin: 2rem 3rem 0.5rem;
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

/* Bio Comp */
.bioComp {
border: 1px solid red;
margin-bottom: 1em;
}
Loading