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
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
},
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/Pokebola-Pokémon-PNG.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>pokedex</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "bruno-moura-projeto-pokedex",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@chakra-ui/react": "^2.6.1",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"axios": "^1.4.0",
"framer-motion": "^10.12.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.8.0",
"react-router-dom": "^6.11.1",
"styled-components": "^6.0.0-rc.1"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"vite": "^4.3.2"
}
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ChakraProvider } from "@chakra-ui/react";
import Router from "./routes/router";
import { useEffect, useState } from "react";
import axios from "axios";
import { GlobalStyled } from "./constants/constants";
import GlobalState from "./context/GlobalState";
function App() {

return (
<GlobalState>
<GlobalStyled />
<ChakraProvider>
<Router/>
</ChakraProvider>
</GlobalState>
);
}

export default App;
Binary file added src/assets/AddPokemon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/Pokebola-Pokémon-PNG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/deletPokemon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pngwing 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/dragon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/electric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/fairy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/fighting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/fire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/flying.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/ghost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/ground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/ice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/poison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/psychic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/rock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/steel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/pokemon-types/water.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions src/components/DetailPokemon/DetailPokemon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import axios from "axios";
import { useContext, useEffect, useState } from "react";
import {
BaseStats,
BoxImageMiniPoke,
ContainerCard,
DetailPage,
Id,
InfoAndMoves,
MoviesPokemon,
Pokeball,
Pokemon,
PokemonType,
ProgressBar,
ProgressBarContainer,
TypeMoves,
TypesContainer,
H1,
} from "./styled";
import pokeball from "../../assets/pngwing 2.png";
import GlobalContext from "../../context/GlobalContext";

export const DetailPokemon = () => {

const context = useContext(GlobalContext)
const { type1,
type2,
setType1,
setType2,
detail,
getColors,
getTypes,
colorProgress,
abbreviate,
ModifayFirstLetter
} = context

const [image, setImage] = useState("");
const [imageBack, setImageBack] = useState("");
const [imageFront, setImageFront] = useState("");
const [name,setName] =useState('')
const [id, setId] = useState("")
const [stats, setStats] = useState([]);
const [moves, setMoves] = useState([]);
const statName = stats.map((stat) => stat.stat.name);

const getPokemonData = async () => {
try {
const res = await axios.get(detail?.url);
setImage(res.data.sprites.other["official-artwork"].front_default);
setImageBack(res.data.sprites.back_default);
setImageFront(res.data.sprites.front_default);
setType1(res.data.types[0]?.type.name);
setType2(res.data.types[1]?.type.name);
setStats(res.data.stats);
setMoves(res.data.moves);
setName(res.data.name);
setId(res.data.id)
} catch (error) {
console.log(error);
}
};

useEffect(() => {
getPokemonData();
}, [detail]);

const typ2Detail = () => {
if (type2) {
return <PokemonType src={getTypes(type2)} />;
} else {
return null;
}
};
return (
<DetailPage>
<div>
<H1>Detalhes</H1>
</div>
<ContainerCard color={getColors(type1)}>
<BoxImageMiniPoke>
<div>
<img src={imageFront} alt="pokemon image" />
</div>
<div>
<img src={imageBack} alt="pokemon image" />
</div>
</BoxImageMiniPoke>
<BaseStats>
<h2>Base stats:</h2>
{stats.map((stat, index) => (
<div key={index}>
<h5>
{abbreviate(ModifayFirstLetter(stat.stat.name))}{" "}
{stat.base_stat}
</h5>
<ProgressBarContainer>
<ProgressBar
color={colorProgress(statName[index])}
progress={stat.base_stat}
>
.
</ProgressBar>
</ProgressBarContainer>
</div>
))}
<div>
<p>
Total:{""}
{stats.length > 0
? stats.reduce(
(allPower, valueStat) => allPower + valueStat.base_stat,
0
)
: 0}
</p>
</div>
</BaseStats>
<InfoAndMoves>
<div>
{id?<Id>#0{id}</Id>:<Id>#{id}</Id>}
<h1>{name}</h1>
</div>
<TypesContainer>
<PokemonType src={getTypes(type1)} />
{typ2Detail()}
</TypesContainer>

</InfoAndMoves>
<MoviesPokemon>
<h2>Moves:</h2>
<div>
{moves?.filter((move, index) => index < 4).map((move, index) => {
return (
<div key={index}>
<TypeMoves>{ModifayFirstLetter(move.move.name)}</TypeMoves>
</div>
);
})}
</div>
</MoviesPokemon>
<Pokemon src={image} alt="pokemon image" />
<Pokeball src={pokeball} alt="pokeball" />
</ContainerCard>
</DetailPage>
);
};

Loading