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

Feedback branch for nowakprojects #68

Open
wants to merge 70 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9c59cad
MNG-5 Add my name to div swquiz-app
daria305 Dec 30, 2020
b6bb88b
MNG-1 Add my name to div pokequiz-app (#3)
memeraki Dec 31, 2020
323615c
Add Aleksandra Cypko to the poekquiz-app div
AleksandraCyp Jan 1, 2021
e73fcfb
MNG-8 Add "Zespół projektowy" section to Readme.md
memeraki Jan 1, 2021
4966957
Add github/real name to div swquiz-app
mariusz-sm Jan 1, 2021
7534526
prepare case for rebasing problem;
lukaszdutka Jan 2, 2021
e10f137
Update App.css
lukaszdutka Jan 2, 2021
8b409ed
Update App.css
lukaszdutka Jan 2, 2021
63fcd66
Merge branch 'MNG-TEST-rebasing-tutorial' into dev
lukaszdutka Jan 2, 2021
e7fe5ca
cleanup after tutorial
lukaszdutka Jan 2, 2021
dc411a7
Update App.css
lukaszdutka Jan 2, 2021
21ca939
MNG-test change margin
lukaszdutka Jan 2, 2021
6f9cf69
Mng 10 starting page html template (#7)
AleksandraCyp Jan 2, 2021
9826724
MNG-2 add my name to project
AgataLudwiczynska Jan 2, 2021
104faf8
MNG-15 Add API urls, start tests and function for pokemons.js (#10)
daria305 Jan 3, 2021
704ea6a
Kamil - Update index.html (#11)
arendarczyk Jan 4, 2021
9fd84b8
Bump node-notifier from 8.0.0 to 8.0.1 (#9)
dependabot[bot] Jan 4, 2021
d245841
MNG-22 Update img and my name (#13)
arendarczyk Jan 4, 2021
763ca4e
MNG-22
arendarczyk Jan 4, 2021
53f8e96
MNG-12 style out starting page (initially) (#14)
AgataLudwiczynska Jan 5, 2021
e5d2ea6
MNG-16 Add a help screen, style it (has to be polished, the scrollbar…
AleksandraCyp Jan 5, 2021
a6cd262
MNG-16 create pokemon service js (#12)
mariusz-sm Jan 5, 2021
57e1640
MNG-25 make every button on main page clickable (#20)
lukaszdutka Jan 6, 2021
62b34d4
MNG-26 MNG-38 MNG-39 MNG-40 Add a randomNumberInRange function and te…
AleksandraCyp Jan 7, 2021
1eb8841
MNG-28 Add instructions (#21)
AleksandraCyp Jan 7, 2021
1352a01
MNG-11 html quiz template (#19)
daria305 Jan 7, 2021
9408f99
MNG-27_question_generator (#22)
mariusz-sm Jan 8, 2021
a0a5e2a
MNG-41 shuffle answers (#23)
AleksandraCyp Jan 8, 2021
77265cc
MNG-46 Remove page templates form js, put them in HTML templates inde…
AleksandraCyp Jan 8, 2021
d345f47
MNG-36 MNG-31 Design and style leaderboard modal (#26)
AleksandraCyp Jan 9, 2021
a9fe237
MNG-44 game handler (#25)
AgataLudwiczynska Jan 9, 2021
aad0552
MNG-47 Getting name from input (#28)
AgataLudwiczynska Jan 9, 2021
65f2c88
MNG-13 style out quiz page (initially) (#27)
AgataLudwiczynska Jan 9, 2021
09e2864
MNG-9 Replace Pikachu Image (#30)
memeraki Jan 11, 2021
25df380
MNG-33 MNG-37 Design and style results modal (#29)
AleksandraCyp Jan 11, 2021
7c0f0b0
MNG-50 add questions to game handler (#32)
daria305 Jan 13, 2021
608d268
MNG-23 Style out finally (#35)
AgataLudwiczynska Jan 14, 2021
b7d8530
MNG-49 fill results modal (#34)
AleksandraCyp Jan 14, 2021
f9621a6
MNG-19 Create rankingService.js (#33)
memeraki Jan 14, 2021
d239638
MNG-20-AddProgressBarAndTimer (#37)
mariusz-sm Jan 15, 2021
76c2514
MNG-54 Add background for all pages (#40)
memeraki Jan 15, 2021
b39ea76
MNG-52 Create fillLeaderboard.js and implement it in showStartingPage…
AleksandraCyp Jan 15, 2021
f14489d
MNG-55 Bugs fixed (#39)
AgataLudwiczynska Jan 15, 2021
46d82da
MNG-53 Autocompletion off + button "Play" (#38)
AgataLudwiczynska Jan 15, 2021
99fb725
MNG-48-Style-out-QuizePage for What does that pokemon looks like (#43)
memeraki Jan 15, 2021
ded7e4a
Sort time from small to big (#46)
memeraki Jan 16, 2021
bb1f254
Little change (#45)
memeraki Jan 16, 2021
2b90ff3
MNG-56-StyleTimer (#44)
mariusz-sm Jan 16, 2021
143b625
MNG-57 Change bottom of the main page button on hover, change some fo…
AleksandraCyp Jan 16, 2021
7c9b0e1
MNG-35 style out quiz page mode1 (#48)
daria305 Jan 16, 2021
ba4f133
MNG-51 add indicators (#49)
arendarczyk Jan 16, 2021
3893744
MNG-62 Remove timeout after answer selection (#50)
daria305 Jan 16, 2021
3c2a31c
MNG-X-hardmode - Add Who's that pokemon (hard mode) (#42)
memeraki Jan 16, 2021
bbb2ff7
MNG-63 MNG-64 MNG-24 on hover buttons&console logs&finally style help…
AleksandraCyp Jan 17, 2021
750741a
MNG-34 MNG-67 style results modal&add cursor on dropdown (#52)
AleksandraCyp Jan 17, 2021
1df77c5
MNG-65 quiz page improvements (#53)
daria305 Jan 17, 2021
f0d5fdc
MNG-X Pikachu animation (#56)
memeraki Jan 17, 2021
98485ef
MNG-68-FixForFirstModeIndicator (#55)
mariusz-sm Jan 17, 2021
13ec5ec
MNG-69 additions (#54)
daria305 Jan 17, 2021
8f07feb
MNG-68 Update README.md file (#57)
memeraki Jan 17, 2021
83c48e2
MNG-66 image mode 1 and 3 (#58)
lukaszdutka Jan 17, 2021
a6e8bc7
MNG-70 fix responsiveness (#59)
AleksandraCyp Jan 18, 2021
361dd2d
MNG-71 + readme update (#61)
memeraki Jan 18, 2021
7530a03
Photos update (#60)
memeraki Jan 18, 2021
bf4365d
quickfix - Update node.js config
lukaszdutka Jan 18, 2021
20f977e
BUGFIX Set leaderBoardItem opacity (#63)
mariusz-sm Jan 18, 2021
5ae6adb
BUGFIX Pikachu no animation - fixed (#65)
memeraki Jan 18, 2021
bf479a3
BUGFIX input name required info (#67)
memeraki Jan 18, 2021
99374ae
BUGFIX Fix randomNrInRange, fix leaderboard, change background into b…
AleksandraCyp Jan 18, 2021
4d6de37
Re-update node.js.yml
lukaszdutka Jan 18, 2021
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
2 changes: 1 addition & 1 deletion .env
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"
Copy link

@MateuszNaKodach MateuszNaKodach Jan 21, 2021

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.

QUIZ_MAX_TIME_SECONDS = 120
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build:
name: "Build Star Wars Quiz application"
name: "Build Pokemon Quiz application"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -25,7 +25,7 @@ jobs:
name: Upload build as artifact
if: always()
with:
name: swquiz-dist
name: pokequiz-dist
path: ./dist
deploy-on-github-pages:
name: "Deploy app to GitHub Pages from main branch source code"
Expand All @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/download-artifact@v2
with:
name: swquiz-dist
name: pokequiz-dist
path: ./dist
- name: Deploy app as GitHub Pages
uses: peaceiris/actions-gh-pages@v3.7.0-6
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
.cache
node_modules
coverage
.vscode
327 changes: 65 additions & 262 deletions README.md

Large diffs are not rendered by default.

163 changes: 156 additions & 7 deletions index.html
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'>&#10005;</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'>&#10005;</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>
34 changes: 27 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions src/api/pokemon.spec.js
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"
},

Choose a reason for hiding this comment

The 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 () => {

Choose a reason for hiding this comment

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

Bardzo ładny opis testów. Normalnie jakby widział swoje :)
Plus za podział na sekcje Given-When-Then.

//given
const typeId = 12;

//when
const typeData = await getTypeById(typeId)

//then
expect(typeData).toEqual({
id: 12,
name: "grass"
}
);
})
})
40 changes: 40 additions & 0 deletions src/api/pokemons.js
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) {

Choose a reason for hiding this comment

The 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
}
}
Loading