diff options
Diffstat (limited to 'frontend/src/components/pages/game.js')
| -rw-r--r-- | frontend/src/components/pages/game.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/frontend/src/components/pages/game.js b/frontend/src/components/pages/game.js new file mode 100644 index 0000000..017760b --- /dev/null +++ b/frontend/src/components/pages/game.js | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | import React, { useEffect, useRef, useState } from 'react'; | ||
| 2 | import { useLocation, Link } from "react-router-dom"; | ||
| 3 | |||
| 4 | import "./games.css" | ||
| 5 | |||
| 6 | export default function GameEntry({ gameInfo }) { | ||
| 7 | const [gameEntry, setGameEntry] = React.useState(null); | ||
| 8 | const location = useLocation(); | ||
| 9 | |||
| 10 | const gameInfoCats = gameInfo.category_portals; | ||
| 11 | |||
| 12 | useEffect(() => { | ||
| 13 | gameInfoCats.forEach(catInfo => { | ||
| 14 | const itemBody = document.createElement("div"); | ||
| 15 | const itemTitle = document.createElement("span"); | ||
| 16 | const spacing = document.createElement("br"); | ||
| 17 | const itemNum = document.createElement("span"); | ||
| 18 | |||
| 19 | itemTitle.innerText = catInfo.category.name; | ||
| 20 | itemNum.innerText = catInfo.portal_count; | ||
| 21 | itemTitle.classList.add("games-page-item-body-item-title"); | ||
| 22 | itemNum.classList.add("games-page-item-body-item-num"); | ||
| 23 | itemBody.appendChild(itemTitle); | ||
| 24 | itemBody.appendChild(spacing); | ||
| 25 | itemBody.appendChild(itemNum); | ||
| 26 | itemBody.className = "games-page-item-body-item"; | ||
| 27 | |||
| 28 | // itemBody.innerHTML = ` | ||
| 29 | // <span className='games-page-item-body-item-title'>${catInfo.category.name}</span><br /> | ||
| 30 | // <span className='games-page-item-body-item-num'>${catInfo.portal_count}</span>` | ||
| 31 | |||
| 32 | document.getElementById(`${gameInfo.id}`).appendChild(itemBody); | ||
| 33 | }); | ||
| 34 | }) | ||
| 35 | |||
| 36 | return ( | ||
| 37 | <Link to={"/games/game?game=" + gameInfo.id}><div className='games-page-item'> | ||
| 38 | <div className='games-page-item-header'> | ||
| 39 | <div style={{backgroundImage: `url(${gameInfo.image})`}} className='games-page-item-header-img'></div> | ||
| 40 | <span><b>{gameInfo.name}</b></span> | ||
| 41 | </div> | ||
| 42 | <div id={gameInfo.id} className='games-page-item-body'> | ||
| 43 | </div> | ||
| 44 | </div></Link> | ||
| 45 | ) | ||
| 46 | } | ||