Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8ccfaa8
created store, provider, reducers wip
Apr 25, 2023
b2d989a
base works
Apr 25, 2023
3cb5001
eslint fixed
Apr 25, 2023
4867072
Merge pull request #1 from SaraBat/master
SaraBat Apr 25, 2023
33e7ab8
add loading component and font
AntoniaGranit Apr 26, 2023
6b8eb2b
add loading feature
AntoniaGranit Apr 26, 2023
f049f15
ternary operator for start page
Apr 26, 2023
212c912
add restartgame reducer and component
AntoniaGranit Apr 26, 2023
54e4384
add restart game button
AntoniaGranit Apr 26, 2023
209052e
uninstall styled components
AntoniaGranit Apr 27, 2023
c156b67
reinstall styled components in correct folder
AntoniaGranit Apr 27, 2023
ccb4fc5
game page & end page styling
Apr 27, 2023
32205d0
start page styled
Apr 27, 2023
387bbab
image not working
Apr 27, 2023
6de1348
all works except back img
Apr 27, 2023
5c21e40
all good but no image working
Apr 27, 2023
5f2bb53
added start bg and loading animation
AjmalZ Apr 27, 2023
c4134f5
added animated loading text and background for different sections
AjmalZ Apr 27, 2023
589cae6
changed path of background img
AjmalZ Apr 28, 2023
6ac2bab
start screen bg adjustment
AjmalZ Apr 28, 2023
b0ec04d
green background deleted
Apr 28, 2023
10446bd
deleted green background from loading
Apr 28, 2023
0c8090c
fixing loading that I broke
Apr 28, 2023
ab83a70
changed start bg
AjmalZ Apr 28, 2023
dbe82a8
Merge branch 'master' of https://github.com/AntoniaGranit/project-lab…
AjmalZ Apr 28, 2023
52d2478
changed start bg
AjmalZ Apr 28, 2023
b7469b0
changed title of webpage
AjmalZ Apr 28, 2023
5eaf34b
change of bg
AjmalZ Apr 28, 2023
02ef752
added media quaries
AjmalZ Apr 28, 2023
eec0f5f
testing viewport
AjmalZ Apr 28, 2023
6cd99d0
testing responsiveness
AjmalZ Apr 28, 2023
b48ae85
testing responsiveness
AjmalZ Apr 28, 2023
bc411df
testing
AjmalZ Apr 28, 2023
e5c497c
testing
AjmalZ Apr 28, 2023
8cf2337
test
AjmalZ Apr 28, 2023
7da19f3
testing
AjmalZ Apr 28, 2023
b327a70
test
AjmalZ Apr 28, 2023
08aa2d5
testing
AjmalZ Apr 28, 2023
64630e7
test
AjmalZ Apr 28, 2023
cbeda81
test
AjmalZ Apr 28, 2023
30b8e3f
test
AjmalZ Apr 28, 2023
29f3ea5
test
AjmalZ Apr 28, 2023
a685718
test
AjmalZ Apr 28, 2023
016f8b0
test
AjmalZ Apr 28, 2023
06cd10c
test
AjmalZ Apr 28, 2023
1f1d75f
changed font size
AjmalZ Apr 28, 2023
4a84920
test
AjmalZ Apr 28, 2023
22c03ff
test
AjmalZ Apr 28, 2023
6fc6237
fix font size
AntoniaGranit Apr 29, 2023
d9aa4f4
added og tags
AjmalZ May 2, 2023
a3d243b
added og tag
AjmalZ May 2, 2023
4438732
added meta tag
AjmalZ May 2, 2023
ef39431
updated og tags
AjmalZ May 2, 2023
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
18,219 changes: 18,219 additions & 0 deletions code/package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
"private": true,
"dependencies": {
"@babel/eslint-parser": "^7.18.9",
"@reduxjs/toolkit": "^1.9.5",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"redux": "^4.2.1",
"styled-components": "^5.3.10"
},
"scripts": {
"start": "react-scripts start",
Expand Down
19 changes: 9 additions & 10 deletions code/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
<html lang="en">

<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cutive+Mono&family=Press+Start+2P&display=swap" rel="stylesheet">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Technigo React App</title>
<meta property="og:title" content="The Maze">
<meta property="og:description" content="Labyrinth Project by Ajmal, Sara and Antonia">
<meta property="og:image" content="https://i.postimg.cc/kMw1Fpqc/startBg.png">

<title>The Maze</title>
</head>

<body>
Expand Down
20 changes: 16 additions & 4 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import React from 'react'
import React from 'react';
import { Provider } from 'react-redux';
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import { Game } from 'reducers/Game';
import { AppStart } from 'components/AppStart';

export const App = () => {
const reducer = combineReducers(
{ game: Game.reducer }
)

const store = configureStore({ reducer });
return (
<div>
Find me in src/app.js!
</div>
<Provider store={store}>
<div>
<AppStart />
</div>
</Provider>
)
}

14 changes: 14 additions & 0 deletions code/src/components/AppStart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { StartGame } from 'components/StartGame';
import { GameScreen } from 'components/GameScreen';

export const AppStart = () => {
const username = useSelector((store) => store.game.username);

return (
<div>
{username === '' ? <StartGame /> : <GameScreen />}
</div>
);
};
22 changes: 22 additions & 0 deletions code/src/components/EndGame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Game } from 'reducers/Game';
import { Button } from '../styles/Button';
import { GameScreenSection, GameSection } from '../styles/Sections';

export const EndGame = () => {
const gameStep = useSelector((store) => store.game.response);
const dispatch = useDispatch();
const onRestartGame = () => {
dispatch(Game.actions.restartGame())
};

return (
<GameScreenSection>
<GameSection>
<p> {gameStep.description} </p>
<Button type="button" onClick={onRestartGame}>Restart Game!</Button>
</GameSection>
</GameScreenSection>
)
}
16 changes: 16 additions & 0 deletions code/src/components/GameScreen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
p {
text-align: center;
}
h2 {
text-align: center;
}


@media (max-width : 428px) {
p {
font-size: 8px;
}
h2 {
font-size: 8px;
}
}
49 changes: 49 additions & 0 deletions code/src/components/GameScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { getStory } from 'reducers/Game';
import { Loading } from './Loading';
import { EndGame } from './EndGame';
import { DirectionButton } from '../styles/Button';
import './GameScreen.css';
import { GameScreenSection, GameSection } from '../styles/Sections';

export const GameScreen = () => {
const dispatch = useDispatch();
const gameStep = useSelector((store) => store.game.response);
const loading = useSelector((store) => store.game.loading);
const actions = useSelector((store) => store.game.response.actions);

const onClickNextStep = (direction) => {
dispatch(getStory(direction))
};

if (loading) {
return <Loading />
}

if (actions && actions.length === 0) {
return <EndGame />
}

return (
<GameScreenSection>
<GameSection>
<p> {gameStep.description} </p>
</GameSection>
<section>
{gameStep.actions.map((singleStep) => {
return (
<GameSection key={singleStep.direction}>
<h2> {singleStep.description} </h2>
<DirectionButton
type="button"
onClick={() => onClickNextStep(singleStep.direction)}>
{singleStep.direction}
</DirectionButton>
</GameSection>
)
})}
</section>
</GameScreenSection>
)
}
20 changes: 20 additions & 0 deletions code/src/components/Loading.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.loadingScreen {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
width: 100%;
background-image: url(../components/img/forest.gif);
background-size: cover;
}

.runner {
scale: 70%;
}

@media (max-width : 428px) {
.loadingText {
scale: 45%;
}
}

29 changes: 29 additions & 0 deletions code/src/components/Loading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import styled from 'styled-components';
import running from './img/running.gif';
import loader from './img/loader.gif';
import './Loading.css';

const LoadingSection = styled.section`
display: flex;
height: 100vh;
background-color: none;
`

const LoadingText = styled.h1`


@media (min-width: 770px) {
font-size: 80px;
}`

export const Loading = () => {
return (
<LoadingSection>
<div className="loadingScreen">
<LoadingText className="loadingText"><img className="loader" src={loader} alt="loader" /></LoadingText>
<img className="runner" src={running} alt="running" />
</div>
</LoadingSection>
)
}
15 changes: 15 additions & 0 deletions code/src/components/StartGame.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#usernameForm {
font-family: "Press Start 2P";
text-align: center;
font-size: 16px;
}

@media (max-width : 428px) {
.usernameForm {
scale: 55%;
}
#usernameForm {
font-size: 16px;
}

}
70 changes: 70 additions & 0 deletions code/src/components/StartGame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Game, startGame } from 'reducers/Game';
import { Loading } from './Loading';
import { Button } from '../styles/Button';
import { StartScreenSection, GameSection, Form } from '../styles/Sections';
import './StartGame.css';

export const StartGame = () => {
const [inputValue, setInputValue] = useState('');
const dispatch = useDispatch();
const loading = useSelector((store) => store.game.loading);

const onAddUsername = (event) => {
event.preventDefault();
dispatch(Game.actions.setUsername(inputValue));
dispatch(startGame());
};

if (loading) {
return <Loading />
}
return (
<StartScreenSection>
<GameSection>
<p>From right to left, and to and fro,
Caught in a labyrinth you go,
And turn, and turn, and turn again,
To solve the mystery, but in vain;
</p>
<p>
Stand still, and breathe, and take from me
A clue, that soon shall set you free!
Not Ariadne, if you met her,
Herself could serve you with a better.
</p>
<p>
You enter d easily--find where--
And make with ease your exit there!
<br />
by William Cowper
</p>
<Form
className="UsernameForm"
onSubmit={onAddUsername}>
<label htmlFor="usernameForm" className="usernameForm">
<input
id="usernameForm"
value={inputValue}
onChange={(event) => setInputValue(event.target.value)}
type="text"
required
placeholder="READY PLAYER 1"
style={{
background: 'transparent',
padding: '20px 30px 20px 30px',
font: 'Press Start 2P',
border: '2px solid black',
margin: '5px'
}} />
</label>
<Button
type="submit">
Start Game!
</Button>
</Form>
</GameSection>
</StartScreenSection>
)
}
Binary file added code/src/components/img/cave.gif
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 code/src/components/img/forest.gif
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 code/src/components/img/loader.gif
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 code/src/components/img/mario.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 code/src/components/img/maze.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 code/src/components/img/running.gif
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 code/src/components/img/startBg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion code/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ body {
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
}
1 change: 1 addition & 0 deletions code/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import './reset.css';
import { App } from './App';

const container = document.getElementById('root');
Expand Down
Loading