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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-challenge-2-template-forked",
"name": "mike-react-challenge",
"version": "1.0.0",
"description": "",
"keywords": [],
Expand Down
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";
import PokeCard from "./components/PokeCard";
import { mockPokemonData as charizardData } from "./mock/pokeData";
import "./styles.css";

export default function App() {
return (
<div className="App">
<h1>Welcome to your second mini challenge!</h1>
<PokeCard {...charizardData} />
</div>
);
}
25 changes: 25 additions & 0 deletions src/components/PokeCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useState } from "react";
const SHINY_LABEL = "shiny";
const DEFAULT_LABEL = "default";

const PokeCard = ({ name, sprites, video }) => {
const [isShiny, setIsShiny] = useState(false);

const getPokemonImage = () =>
isShiny ? sprites.front_shiny : sprites.front_default;

return (
<div className="card">
<h1>{name}</h1>
<div className="button-row">
<button onClick={() => setIsShiny(false)}>{DEFAULT_LABEL}</button>
<button onClick={() => setIsShiny(true)}>{SHINY_LABEL}</button>
</div>
<a href={video}>
<img className="card-img" src={getPokemonImage()} alt="default" />
</a>
</div>
);
};

export default PokeCard;
43 changes: 43 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,46 @@
font-family: sans-serif;
text-align: center;
}

h1 {
margin: 0px;
}

.card {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
width: 160px;
border: 2px solid black;
border-radius: 8px;
padding: 8px;
user-select: none;
}

.card-img {
height: 96px;
width: 96px;
}

.button-row {
display: flex;
width: 100%;
margin: 8px 0px;
justify-content: space-evenly;
}

.button-row > button {
outline: none;
cursor: pointer;
border: 1px solid black;
border-radius: 16px;
background-color: white;
width: 40%;
transition: 0.6s ease;
}

.button-row > button:hover {
background-color: black;
color: white;
}