-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feedback branch for nowakprojects #68
base: feedback
Are you sure you want to change the base?
Changes from all commits
9c59cad
b6bb88b
323615c
e73fcfb
4966957
7534526
e10f137
8b409ed
63fcd66
e7fe5ca
dc411a7
21ca939
6f9cf69
9826724
104faf8
704ea6a
9fd84b8
d245841
763ca4e
53f8e96
e5d2ea6
a6cd262
57e1640
62b34d4
1eb8841
1352a01
9408f99
a0a5e2a
77265cc
d345f47
a9fe237
aad0552
65f2c88
09e2864
25df380
7c0f0b0
608d268
b7d8530
f9621a6
d239638
76c2514
b39ea76
f14489d
46d82da
99fb725
ded7e4a
bb1f254
2b90ff3
143b625
7c9b0e1
ba4f133
3893744
3c2a31c
bbb2ff7
750741a
1df77c5
f0d5fdc
98485ef
13ec5ec
8f07feb
83c48e2
a6e8bc7
361dd2d
7530a03
bf4365d
20f977e
5ae6adb
bf479a3
99374ae
4d6de37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
POKEMON_API_BASE_URL = | ||
POKEMON_API_BASE_URL = "https://pokeapi.co/api/v2" | ||
QUIZ_MAX_TIME_SECONDS = 120 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ dist | |
.cache | ||
node_modules | ||
coverage | ||
.vscode |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,170 @@ | ||
<!DOCTYPE html> | ||
<html lang="pl"> | ||
|
||
<head> | ||
<meta charset="UTF-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"/> | ||
<title>CodersCamp2020 | Star Wars API QUIZ</title> | ||
<title>CodersCamp2020 | Pokemon Quiz</title> | ||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"> | ||
<link rel="stylesheet" href="styles/App.css"/> | ||
|
||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" | ||
rel="stylesheet"> | ||
<link rel="icon" href="./static/assets/ui/lightning.svg"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="pokequiz-app"> | ||
Łukasz Dutka | ||
</div> | ||
<div id="pokequiz-app"> | ||
Łukasz Dutka | ||
daria305 | ||
memeraki / Gosia Dziewit | ||
Aleksandra Cypko / AleksandraCyp | ||
mariusz-sm / Mariusz Smarz | ||
Agata Ludwiczyńska/ AgataLudwiczynska | ||
arendarczyk / Kamil Arendarczyk | ||
</div> | ||
|
||
<template id="starting-page-template"> | ||
|
||
<div id="headerWithLogo" class="firstColumn spanInPortrait disableWithPopUpScreen"> | ||
<img src="./static/assets/ui/logo.png" alt='Pokemon' id='pokemonLogo'/> | ||
<p id='quizLogo' class='fancyFontStyle'>Quiz</p> | ||
</div> | ||
|
||
<ul id="selectModeMenu" class="firstColumn spanInPortrait disableWithPopUpScreen"> | ||
<li id='whoIsThatPokemonOption' class="buttonWithText">Who's that pokemon?</li> | ||
<li id='whatItLooksLikeOption' class="buttonWithText">What it looks like?</li> | ||
<li id='whoIsThatPokemonHardModeOption' class="buttonWithText">Who's that pokemon? (hard mode)</li> | ||
</ul> | ||
|
||
<div id='enterNameAndPlayMenu' class="secondColumn spanInPortrait disableWithPopUpScreen"> | ||
<p id='enterYourName' class='fancyFontStyle'>ENTER YOUR NAME</p> | ||
<div id='enterYourNameArea'> | ||
<img src='./static/assets/ui/user.svg' alt='playerIcon' id='playerIcon'/> | ||
<input type='text' id='enterYourNameInput' maxlength="8"> | ||
</div> | ||
</div> | ||
|
||
<div id='startGame' class="secondColumn spanInPortrait disableWithPopUpScreen"> | ||
<input type='button' id='startGameButton' class="buttonWithText" value='PLAY' autocomplete='off'> | ||
</div> | ||
|
||
<ul class='bottomOfThePageOptions firstColumn disableWithPopUpScreen'> | ||
<li id='helpOption'>?</li> | ||
<li id='leaderboard'><img src="./static/assets/ui/crown.svg" alt="crown"></li> | ||
</ul> | ||
|
||
<svg class="replaceMe secondColumn disableWithPopUpScreen" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
viewBox="75 -10 690 610"></svg> | ||
|
||
</template> | ||
|
||
<template id="help-modal-template"> | ||
|
||
<div class='popUpScreen' id='helpScreen'> | ||
|
||
<div class='popUpTitleArea' id='popUpTitleAreaHelp'> | ||
<h1 class='popUpTitle' id='popUpTitleHelp'>HELP</h1> | ||
<p class='exitPopUpScreen' id='exitPopUpScreenHelp'>✕</p> | ||
</div> | ||
|
||
<ul class='mainHelpTextSection'> | ||
<li><span class='helpTitle'>Who's that pokemon?</span> During the quiz, you will have to guess the name of the pokemon displayed in the picture. The game ends after 2 minutes or after you answer 30 questions.</li> | ||
<li><span class='helpTitle'>What it looks like?</span> During the quiz, you will have to select the correct picture of the pokemon whose name is displayed on the screen. The game ends after 2 minutes or after you answer 30 questions.</li> | ||
<li><span class='helpTitle'>Who's that pokemon? (hard mode)</span> During the quiz, you will have to guess the name of the pokemon shadow displayed in the picture. The game ends after 2 minutes or after you answer 30 questions.</li> | ||
</ul> | ||
|
||
<div class='popUpImgArea'> | ||
<img src='./static/assets/ui/pikachu2.png' alt='Pikachu' id='littlePikachu' class='popUpImg'/> | ||
</div> | ||
|
||
</div> | ||
|
||
</template> | ||
|
||
<template id="leaderboard-modal-template"> | ||
|
||
<div class='popUpScreen' id='leaderboardScreen'> | ||
|
||
<div class='popUpTitleArea' id='popUpTitleAreaLeaderBoard'> | ||
|
||
<h1 class='popUpTitle' id='popUpTitleLeaderboard'>LEADERBOARD</h1> | ||
<p class='exitPopUpScreen' id='exitPopUpScreenLeaderboard'>✕</p> | ||
|
||
<script src="src/index.js"></script> | ||
</div> | ||
|
||
<div id='chooseModeLeaderboardArea'> | ||
|
||
<label id='chooseModeLeaderboardLabel' for='chooseModeLeaderboard'>Points per game in</label> | ||
<select id='chooseModeLeaderboard'> | ||
<option value='whoIsThatPokemon'>Who's that pokemon?</option> | ||
<option value='whatItLooksLike'>What it looks like?</option> | ||
<option value='whoIsThatPokemonHardMode'>Who's that pokemon (hard mode)</option> | ||
</select> | ||
|
||
</div> | ||
|
||
<ul id='leaderboardResults'></ul> | ||
|
||
</div> | ||
|
||
</template> | ||
|
||
<template id="quiz-template"> | ||
<div class="quiz-top-bar progress-bar"> | ||
<div id="timer"></div> | ||
<div id="timerLabel"></div> | ||
<div class="mode-title"> | ||
<div></div> | ||
</div> | ||
<div id="question-counter"></div> | ||
</div> | ||
<div id="quiz-body"> | ||
<div class="quiz-question"></div> | ||
<ul class="quiz-answers-list"></ul> | ||
</div> | ||
</template> | ||
|
||
<template id="quiz-li"> | ||
<li class="quiz-answer"> | ||
<div class="unchecked"></div> | ||
</li> | ||
</template> | ||
|
||
<template id="results-modal-template"> | ||
|
||
<div class='popUpScreen' id='resultsScreen'> | ||
|
||
<div class='popUpTitleResultsArea' id='popUpTitleAreaResults'> | ||
<h1 class='popUpTitle' id='popUpTitleResults'>GAME OVER</h1> | ||
</div> | ||
|
||
<div class='resultsDescriptionArea'> | ||
<p id='resultsDescription'></p> | ||
</div> | ||
|
||
<div id='tableWithResultsArea'> | ||
<img src='./static/assets/ui/pikach1.png' alt='Pikachu' id='nextToTableImg'> | ||
<div id='tableWithResults'> | ||
<table> | ||
<tr> | ||
<th colspan='2'>Correct</th> | ||
<th>You</th> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
|
||
<div id='backToStartingPageButtonArea'> | ||
<input type='button' value="Gotta catch 'em all!" id='backToStartingPageButton'/> | ||
</div> | ||
|
||
</div> | ||
|
||
</template> | ||
|
||
<script src="src/index.js"></script> | ||
</body> | ||
</html> | ||
|
||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
getPokemonById, | ||
getTypeById | ||
} from "./pokemons.js"; | ||
|
||
describe('Test pokemon API to get pokemon', () => { | ||
|
||
it("Given pokemon id is 1 when asking for data, should get id, photoUrl, types, name of the pokemon", async () => { | ||
//given | ||
const pokemonId = 1; | ||
|
||
//when | ||
const pokeData = await getPokemonById(pokemonId) | ||
|
||
//then | ||
expect(pokeData).toEqual({ | ||
id: 1, | ||
name: "bulbasaur", | ||
photoUrl: "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/1.png", | ||
types: [{ | ||
id: 12, | ||
type: "grass" | ||
}, | ||
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. Kurde, tyle razy grałem w Pokemony, a jakoś nie zwróciłem uwagi, że Bulbasaur jest też typu Poison! Fajną wiedzę domenową można wyczytać z testu :) |
||
{ | ||
id: 4, | ||
type: "poison" | ||
} | ||
] | ||
}); | ||
}) | ||
}); | ||
|
||
|
||
describe("Test pokemon API to get pokemon types", () => { | ||
|
||
it("Given the type id is 12 when asking for pokemon data, should return id and name of the type", async () => { | ||
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. Bardzo ładny opis testów. Normalnie jakby widział swoje :) |
||
//given | ||
const typeId = 12; | ||
|
||
//when | ||
const typeData = await getTypeById(typeId) | ||
|
||
//then | ||
expect(typeData).toEqual({ | ||
id: 12, | ||
name: "grass" | ||
} | ||
); | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import fetch from "cross-fetch" | ||
|
||
const POKEMON_API_BASE_URL = process.env.POKEMON_API_BASE_URL || "https://pokeapi.co/api/v2"; | ||
|
||
export async function getPokemonById(id) { | ||
const getTypeIdFromUrl = (url) => { | ||
const regex = /\/type\/(\d+)\/$/; | ||
return Number(regex.exec(url)[1]) | ||
}; | ||
|
||
const parseType = (type) => { | ||
return { | ||
id: getTypeIdFromUrl(type.type.url), | ||
type: type.type.name | ||
} | ||
}; | ||
|
||
const res = await fetch(`${POKEMON_API_BASE_URL}/pokemon/${id}`); | ||
const jsonRes = await res.json(); | ||
|
||
return { | ||
id: jsonRes.id, | ||
name: jsonRes.name, | ||
types: jsonRes.types.map(parseType), | ||
photoUrl: jsonRes.sprites.other["official-artwork"].front_default | ||
} | ||
}; | ||
|
||
export async function getTypeById(id) { | ||
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. Super, że radzicie sobie z Promisami i zapisem async/await, co tutaj widać! :) |
||
const res = await fetch(`${POKEMON_API_BASE_URL}/type/${id}`); | ||
const jsonRes = await res.json(); | ||
const { | ||
id: typeId, | ||
name: typeName | ||
} = jsonRes; | ||
return { | ||
id: typeId, | ||
name: typeName | ||
} | ||
} |
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.
Plus za użycie zmiennej środowiskowej.