-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathPokeDex.js
More file actions
97 lines (92 loc) · 2.87 KB
/
PokeDex.js
File metadata and controls
97 lines (92 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import "./App.css";
import { useState, useEffect } from "react";
import ReactLoading from "react-loading";
import axios from "axios";
import Modal from "react-modal";
function PokeDex() {
const [pokemons, setPokemons] = useState([]);
const [pokemonDetail, setPokemonDetail] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const customStyles = {
content: {
top: "50%",
left: "50%",
right: "auto",
bottom: "auto",
marginRight: "-50%",
transform: "translate(-50%, -50%)",
background: "black",
color: "white",
},
overlay: { backgroundColor: "grey" },
};
if (!isLoading && pokemons.length === 0) {
return (
<div>
<header className="App-header">
<h1>Welcome to pokedex !</h1>
<h2>Requirement:</h2>
<ul>
<li>
Call this api:https://pokeapi.co/api/v2/pokemon to get pokedex, and show a list of pokemon name.
</li>
<li>Implement React Loading and show it during API call</li>
<li>when hover on the list item , change the item color to yellow.</li>
<li>when clicked the list item, show the modal below</li>
<li>
Add a search bar on top of the bar for searching, search will run
on keyup event
</li>
<li>Implement sorting and pagingation</li>
<li>Commit your codes after done</li>
<li>If you do more than expected (E.g redesign the page / create a chat feature at the bottom right). it would be good.</li>
</ul>
</header>
</div>
);
}
return (
<div>
<header className="App-header">
{isLoading ? (
<>
<div className="App">
<header className="App-header">
<b>Implement loader here</b>
</header>
</div>
</>
) : (
<>
<h1>Welcome to pokedex !</h1>
<b>Implement Pokedex list here</b>
</>
)}
</header>
{pokemonDetail && (
<Modal
isOpen={pokemonDetail}
contentLabel={pokemonDetail?.name || ""}
onRequestClose={() => {
setPokemonDetail(null);
}}
style={customStyles}
>
<div>
Requirement:
<ul>
<li>show the sprites front_default as the pokemon image</li>
<li>
Show the stats details - only stat.name and base_stat is
required in tabular format
</li>
<li>Create a bar chart based on the stats above</li>
<li>Create a buttton to download the information generated in this modal as pdf. (images and chart must be included)</li>
</ul>
</div>
</Modal>
)}
</div>
);
}
export default PokeDex;