mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
Icons to categories added. Categories section done
This commit is contained in:
@@ -5,6 +5,8 @@ import { AlmacenateLanguage } from "../Scripts/AlmacenateLanguage"
|
||||
import Bring_All_Categories from "./Firebase Querys/Bring All Categories"
|
||||
import Bring_All_Languages from "./Firebase Querys/Bring All Languages"
|
||||
|
||||
import images from "./Images"
|
||||
|
||||
|
||||
const Categories = ({language, displayCategories, category, setCategory, currentScore, setLanguage}) => {
|
||||
|
||||
@@ -70,13 +72,41 @@ const Categories = ({language, displayCategories, category, setCategory, current
|
||||
|
||||
categories.map((categorie) => {
|
||||
|
||||
return <button className={ categorie } key={categorie} onClick={() => changeCategory(categorie)}> { categorie.toUpperCase() } </button>
|
||||
const normalizatedCategorie = categorie[0].toLowerCase()
|
||||
|
||||
return <button
|
||||
className={ categorie[0] }
|
||||
key={categorie[0]}
|
||||
onClick={() => changeCategory(categorie[0])}
|
||||
>
|
||||
|
||||
<img src={images[normalizatedCategorie]} alt={normalizatedCategorie}/>
|
||||
|
||||
<span className="text">
|
||||
{ categorie[0].toUpperCase() }
|
||||
</span>
|
||||
|
||||
<div className="blank-space"></div>
|
||||
|
||||
</button>
|
||||
})
|
||||
|
||||
: null
|
||||
}
|
||||
|
||||
<button className='Random' key='Random' onClick={() => changeCategory('')}>{'Random'.toUpperCase()}</button>
|
||||
<button
|
||||
className='Random'
|
||||
key='Random'
|
||||
onClick={() => changeCategory('')}
|
||||
>
|
||||
|
||||
<img src={images['random']} alt="random-icon" />
|
||||
<span className="text">
|
||||
{'Random'.toUpperCase()}
|
||||
</span>
|
||||
|
||||
<div className="blank-space"></div>
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ const Bring_All_Categories = async (setCategories, setStrech, language) => {
|
||||
|
||||
if (language === 'english') {
|
||||
|
||||
categories = result.docs.map(doc => doc.data().english)
|
||||
categories = result.docs.map(doc => [doc.data().english, doc.data().iconRoute])
|
||||
}
|
||||
|
||||
if (language === 'spanish') {
|
||||
categories = result.docs.map(doc => doc.data().spanish)
|
||||
categories = result.docs.map(doc => [doc.data().spanish, doc.data().iconRoute])
|
||||
|
||||
}
|
||||
|
||||
categories = categories.map(word => capitalize(word, true))
|
||||
categories = categories.map(doc => [capitalize(doc[0], true), doc[1]])
|
||||
|
||||
console.log(categories)
|
||||
setCategories(await categories)
|
||||
|
||||
26
src/components/Categories/Images.js
Normal file
26
src/components/Categories/Images.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import animals from './img/categories-icons/animals.png'
|
||||
import cities from './img/categories-icons/cities.png'
|
||||
import countries from './img/categories-icons/countries.png'
|
||||
import pokemon from './img/categories-icons/pokemon.png'
|
||||
import programmingLanguage from './img/categories-icons/programming language.png'
|
||||
import random from './img/categories-icons/random.png'
|
||||
|
||||
const images = {
|
||||
animals: animals,
|
||||
animales: animals,
|
||||
|
||||
cities: cities,
|
||||
ciudades: cities,
|
||||
|
||||
countries: countries,
|
||||
países: countries,
|
||||
|
||||
pokemon: pokemon,
|
||||
|
||||
'programming languages': programmingLanguage,
|
||||
'lenguajes de programación': programmingLanguage,
|
||||
|
||||
random: random
|
||||
}
|
||||
|
||||
export default images
|
||||
BIN
src/components/Categories/img/categories-icons/animals.png
Normal file
BIN
src/components/Categories/img/categories-icons/animals.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
BIN
src/components/Categories/img/categories-icons/cities.png
Normal file
BIN
src/components/Categories/img/categories-icons/cities.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
src/components/Categories/img/categories-icons/countries.png
Normal file
BIN
src/components/Categories/img/categories-icons/countries.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
src/components/Categories/img/categories-icons/pokemon.png
Normal file
BIN
src/components/Categories/img/categories-icons/pokemon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/components/Categories/img/categories-icons/random.png
Normal file
BIN
src/components/Categories/img/categories-icons/random.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Reference in New Issue
Block a user