-
Notifications
You must be signed in to change notification settings - Fork 39
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-zustand-vite #18
Open
kathinka
wants to merge
14
commits into
Technigo:main
Choose a base branch
from
kathinka:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
be3afcd
first commit
kathinka dd7b296
added images for the different options - no styles
kathinka 04cb4c3
Add @lottiefiles/react-lottie-player dependency and create Lottie com…
kathinka 7940b18
Refactor component structure and fix image paths
kathinka c877d29
cleanup
kathinka df5d5d1
Update pull_request_template and README.md
kathinka a808a98
Remove unused CSS styles and import statement in main.jsx
kathinka eb67461
Fix casing of User.css import statement in User.jsx
kathinka 1446538
build
kathinka 4388b5d
Update README.md and pull_request_template.md with link
kathinka 3bc010f
Refactor User component and add Lottie overlay styling- compressed im…
kathinka 95a80b0
Refactor User component and add view option button in User.jsx and us…
kathinka c12bd3d
update styling in user.css
kathinka 37a110a
cartoon makeover
kathinka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
## Netlify link | ||
Add your Netlify link here. | ||
PS. Don't forget to add it in your readme as well. | ||
View it live: <a href="https://maze-mania.netlify.app/"> Are you the hero of the maze? </a> | ||
|
||
## Collaborators | ||
Add your collaborators here. Write their GitHub usernames in square brackets. If there's more than one, separate them with a comma, like this: | ||
[github-username-1, github-username-2] | ||
solo - no one was up for playing this week. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
|
||
import { User } from "./components/User"; | ||
export const App = () => { | ||
return ( | ||
<div> | ||
Labyrinth Project | ||
</div> | ||
<> | ||
<User /> | ||
</> | ||
); | ||
}; |
Diff not rendered.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting seems off (indentation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { useLabyrint } from "../stores/useLabyrint.jsx"; | ||
import { images } from "./images"; | ||
import { useState, useEffect } from "react"; | ||
import { Lottie } from "./lottie"; | ||
import "./user.css"; | ||
|
||
export const User = () => { | ||
const { loading, username, setUsername, fetchLabyrint, labyrint, fetchDirectionLabyrint, setDirection, setType, setRoom, setLabyrint } = useLabyrint(); | ||
const [isSubmitted, setIsSubmitted] = useState(false); | ||
const [currentImageDirection, setCurrentImageDirection] = useState(''); | ||
const [showViewOption, setShowViewOption] = useState(null); | ||
|
||
const random = Math.floor(Math.random() * 10000000); | ||
const currentImage = images[labyrint.coordinates]; | ||
|
||
const handleInputChange = (event) => { | ||
setUsername(event.target.value); | ||
}; | ||
|
||
const handleButtonClick = async () => { | ||
const username2 = username + random; | ||
setUsername(username2); | ||
event.preventDefault(); | ||
setIsSubmitted(true); | ||
await fetchLabyrint(username2); | ||
}; | ||
|
||
useEffect(() => { | ||
if (labyrint.actions && labyrint.actions.length > 0) { | ||
setCurrentImageDirection(images[labyrint.coordinates + labyrint.actions.direction]); | ||
setShowViewOption(null); | ||
} | ||
}, [labyrint]); | ||
|
||
|
||
const handleDirection = async (direction) => { | ||
try { | ||
setDirection(direction); | ||
setType(labyrint.actions.type); | ||
setRoom(labyrint.description); | ||
const newLabyrint = await fetchDirectionLabyrint( | ||
username, | ||
labyrint.actions[0].type, | ||
direction, | ||
labyrint.coordinates, | ||
labyrint.description, | ||
); | ||
if (newLabyrint) { | ||
setLabyrint(newLabyrint); | ||
} | ||
} catch (error) { | ||
console.error('Failed to fetch new labyrinth:', error); | ||
} | ||
}; | ||
return ( | ||
!username || !isSubmitted ? ( | ||
<section className="hero"> | ||
<div className="form"> | ||
<form onSubmit={handleButtonClick}> | ||
<h1>To enter the maze, we need a hero's name</h1> | ||
<label name="username" htmlFor="username">I am Legend, I am.. </label> | ||
<input | ||
value={username} | ||
type="text" | ||
onChange={handleInputChange} | ||
name="username" | ||
id="username" | ||
autoComplete="given-name" | ||
/> | ||
<button onClick={handleButtonClick}>Enter the maze</button> | ||
</form> | ||
</div> | ||
</section> | ||
) | ||
: ( | ||
<div className="game-stage" style={{ backgroundImage: `url(${currentImage})` }}> | ||
{loading ? <Lottie /> : null} | ||
{labyrint && labyrint.actions && ( | ||
<> | ||
<h2>{labyrint.description}</h2> | ||
<section className="options-container"> | ||
{labyrint.actions.map((action, index) => ( | ||
<div className="option" key={index}> | ||
<button className="view" onClick={() => setShowViewOption(showViewOption === index ? null : index)(!showViewOption)}>Look {action.direction}</button> | ||
{showViewOption === index && | ||
<div className="option view-option"> | ||
<div className="option-image" style={{ | ||
backgroundImage: `url(${images[labyrint.coordinates + action.direction]})` | ||
}}></div> | ||
<div className="option-text-btn-container"> | ||
<p>{action.description}</p> | ||
</div> | ||
<button className="button-direction" onClick={() => handleDirection(action.direction)}> Go {action.direction}</button> | ||
</div>} | ||
</div> | ||
))} | ||
</section> | ||
|
||
</> | ||
) | ||
}</div> | ||
) | ||
) | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
|
||
export const images = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be an array? 👀 |
||
"0,0": "/assets/cartoon/0x0.jpg", | ||
"0,0East": "/assets/cartoon/0x0e2-v.jpg", | ||
"0,1": "/assets/cartoon/0x1.jpg", | ||
"0,1East": "/assets/cartoon/0x1e.jpg", | ||
"0,1North": "/assets/cartoon/0x1n.jpg", | ||
"0,2": "/assets/cartoon/0x2.jpg", | ||
"0,2North": "/assets/cartoon/0x2n.jpg", | ||
"0,2South": "/assets/cartoon/0x2s.jpg", | ||
"1,0": "/assets/cartoon/1x0.jpg", | ||
"1,0North": "/assets/cartoon/1x0n.jpg", | ||
"1,0West": "/assets/cartoon/1x0w.jpg", | ||
"1,1": "/assets/cartoon/1x1.jpg", | ||
"1,1South": "/assets/cartoon/1x1s.jpg", | ||
"1,1West": "/assets/cartoon//0x1e.jpg", | ||
"0,3": "/assets/cartoon/0x3.jpg", | ||
"0,3East": "/assets/cartoon/0x3e.jpg", | ||
"0,3South": "/assets/cartoon/0x3s.jpg", | ||
"1,3": "/assets/cartoon/1x3.jpg", | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Player } from '@lottiefiles/react-lottie-player'; | ||
|
||
export const Lottie = () => { | ||
|
||
return ( | ||
<div className="lottie-overlay"> | ||
<Player | ||
src='https://lottie.host/6483601a-d5be-4f51-8822-9a5f375d00f9/bGyHW0SHFM.json' | ||
className="player" | ||
loop | ||
autoplay | ||
/> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary fragment