Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions data/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
let mysql = require(‘mysql’);
let con = mysql = mysql.createConnection({
host: “localhost”,
user: “root”,
password: Jordan2017,
database: “Pokemon”
});
con.connect(err => {
if (err) {
throw err;
}
con.query(“SELECT * FROM pokemon”, (err, result, fields) => {
if (err) {
throw err;
}
console.log(result);
});
});
let pokemon_id = 1;
let name = “Bulbasaur”;
let color = “Green”;
//console.log(`INSERT into pokemon (pokemon_id, name, color) VALUES (${pokemon_id}, ${name}, ${color});`);
con.query(`INSERT into pokemon (pokemon_id, name, color) VALUES (${pokemon_id}, ${name}, ${color});`, (err, result, fields) => {
if (err) {
throw err;
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You want to stick this logic in a javascript file. Your sql to create your database and tables should go here

-- 9:00
-- ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
-- 9:00
-- FLUSH PRIVILEGES;
11 changes: 0 additions & 11 deletions index.js

This file was deleted.

28 changes: 21 additions & 7 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"homepage": "https://github.com/code-differently/Pokedex-App#readme",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1"
}
}
58 changes: 58 additions & 0 deletions rest/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
res.send('Hello World!')
})

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
console.log(hello);

let pokedex = document.getElementById("pokedex");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file is generating an express app running on node. The document object is only available in the browser. The DOM and fetch logic should all be in web/index.html. The code in that file will be used by web/index.html in the browser

console.log(pokedex);
let url = "https://pokeapi.co/api/v2/pokemon/";
let fetchPokemon = () => {
const promises = [];
for (let i = 1; i <= 139; i++, status == 200) {
// console.log(url + i);

promises.push(fetch(url + i).then((res) => {
return res.json();

}));
}

Promise.all(promises).then(results => {
const pokemon = results.map((data) => ({
name: data.name,
id: data.id,
image: data.sprites['front_shiny'],
type: data.types[0].type.name
}));
displayPokemon(pokemon);
});
};
let thisPokemon;
let displayPokemon = (pokemon) => {
// console.log(pokemon.type);
const pokemonHTMLString = pokemon.map(
(pokeman) => `
<div class = "card ${pokeman.type}">
<img src= "${pokeman.image}" />
<h2> ${pokeman.id}. ${pokeman.name}</h2>
<p>Type: ${pokeman.type}</p>
</div>
`).join('');
pokedex.innerHTML = pokemonHTMLString;
// return cardColor();
};
// card.classList.add('card', `${​​​​​pokeman.types[0].type.name}​​​​​`, 'font-weight-bold');
function cardColor() {
if (pokeman.type === 'grass') {
document.getElementsByClassName("card")[0].style.backgroundColor = "blue";
}
};
fetchPokemon();
11 changes: 0 additions & 11 deletions rest/index.js

This file was deleted.

Binary file added web/.DS_Store
Binary file not shown.
20 changes: 16 additions & 4 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- <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>JAF's Pokedex</title>
<link rel="stylesheet" href="styles.css" />
<!-- <link href="https://fonts.googleapis.com/css?family=Rubik&display=swap" rel="stylesheet" /> -->
</head>

<body>
<p>Hello Pokemon!</p>
<div class="container">
<h1>JAF's Pokedex</h1>
<h2>Gotta catch'em all!</h2>
<ol id="pokedex"> </ol>

</div>
<script src="../rest/app.js"></script>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once you move the code above to web/index.js you can update this import statement

</body>

</html>
135 changes: 135 additions & 0 deletions web/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*PokedexJAF.css*/
/* testiing testing testing */
body {
background-color: orangered;
color: white;
margin: 0;
font-family: rubik;
}

.container {
padding: 40px;
margin: 0 auto;
}

h1 {
text-transform: uppercase;
text-align: center;
font-size: 20px;
font-style: pokemon;
}
h2{
font-style: andybold;
text-align: center;
}

/* pokedex {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
grid-gap: 20px;
padding-inline-start: 0;
} */

.card {
height: 200px;
width: 180px;
list-style: none;
padding: 40px;
background-color: #f4f4f4;
color: #222;
text-align: center;
display: inline-block;
margin: 1%;
}

.card:hover {
animation: bounce 0.5s linear;
}

.card-title {
text-transform: capitalize;
margin-bottom: 0px;
font-size: 32px;
font-weight: normal;
}
.card-subtitle {
margin-top: 5px;
color: #666;
font-weight: lighter;
}

.card-image {
height: 180px;
}
/* text wrap */
.fire {
background-color: firebrick;
}

.bug {
background-color: greenyellow;
}

.grass {
background-color: green;
}

.water {
background-color: aqua;
}

.normal {
background-color: burlywood;
}

.electric {
background-color: yellow;
}

.poison {
background-color: slateblue;
}

.ground {
background-color: chocolate;
}

.fairy {
background-color: pink;
}

.psychic {
background-color: rebeccapurple;
}

.rock {
background-color: grey;
}

.fighting {
background-color: crimson;
}

.ghost {
background-color: darkmagenta;
}

.ice {
background-color: darkturquoise;
}

.dragon {
background-color: olive;
}

.steel {
background-color: steelblue;
}

.dark {
background-color: darkslategrey;
}

.flying {
background-color: lightskyblue;
}