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
21 changes: 20 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@ https://reactjs.org/docs/lists-and-keys.html
Feel free to create more components, such as header/footer,
or why not include some more data from the array? */

import { Pokemon } from "./components/Pokemon"
import data from "./data.json"

export const App = () => {
const { pokemons } = data
const renderPokemons = pokemons.map(({id, name, category, height, types}) => (
<Pokemon
name={name}
category={category}
height={height}
types={types}
key={id}
/>
)
)

return (
<div className="App">
<p>Pokemon goes here</p>
<p>Catch them all</p>
<section className="pokemonList">{renderPokemons}
</section>
</div>
);
};

export default App
6 changes: 6 additions & 0 deletions src/components/Pokemon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.pokemon {
border: solid white 1px;
padding: 1em;
margin-bottom: 1em;
border-radius: 4px;
}
57 changes: 54 additions & 3 deletions src/components/Pokemon.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
// Destructure pokemon props here :)
export const Pokemon = () => {
return <div>Pokemon</div>;
};
// we have to pass the information into the property
import PropTypes from "prop-types"
import { Type } from "./Type"
import "./Pokemon.css"

export const Pokemon = ({
//we write what we want to diplay
name, category, height, types }) => {
return (
<div className="pokemon">
<p>
<span>Name: {name}</span>
</p>
<p>
<span>Category: {category}</span>
</p>
<p>
<span>Height: {height}</span>
</p>
<Type types={types} />
</div>
)
}

Pokemon.propTypes = {
name: PropTypes.string.isRequired,
category: PropTypes.string.isRequired,
height: PropTypes.number.isRequired,
types: PropTypes.array.isRequired,
}
























27 changes: 24 additions & 3 deletions src/components/Type.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
// Destructure pokemon types props here :)
export const Type = () => {
return <div>Type</div>;
};
import PropTypes from "prop-types"

export const Type = ({ types }) => {
return (
<div>
<span>Types:</span>
{types.map((type, key) => (
<ul key={key}>
{" "}
<li key={key}>{type}</li>
</ul>
))}
</div>
)
}


Type.propTypes = {
types: PropTypes.array.isRequired,
}

Type.defaultProps = {
components: "Components are missing",
}
2 changes: 1 addition & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App.jsx";
import App from "./App.jsx"; // idk if was a mistake but there were curly brackets around App and i was having a error so I removed it
import "./styles.css";

ReactDOM.createRoot(document.getElementById("root")).render(
Expand Down
44 changes: 44 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
body {
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: black;
color: white;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

span {
font-weight: bold;
display: block;
}

.App {
font-family: sans-serif;
padding: 20px;
font-size: large;
}

.pokemonOuter {
flex: 1;
margin: 10px;
padding: 20px;
display: grid;
grid-template-columns: 1fr;
grid-gap: 25px;
}

/* Media query for tablet (768px)*/
@media (min-width: 768px) {
.pokemonOuter {
flex: 1;
margin: 10px;
padding: 20px;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 25px;
}
}