diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-03 00:08:53 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-03 00:08:53 +0300 |
| commit | a65d6d9127c3fa7f6a8ecaec5d1ffd1f47c2bc98 (patch) | |
| tree | edf8630e9d6426124dd49854af0cb703ebc5b710 /frontend/src/components/GameEntry.tsx | |
| parent | fix: revert to static homepage (#195) (diff) | |
| download | lphub-a65d6d9127c3fa7f6a8ecaec5d1ffd1f47c2bc98.tar.gz lphub-a65d6d9127c3fa7f6a8ecaec5d1ffd1f47c2bc98.tar.bz2 lphub-a65d6d9127c3fa7f6a8ecaec5d1ffd1f47c2bc98.zip | |
refactor: port to typescript
Diffstat (limited to 'frontend/src/components/GameEntry.tsx')
| -rw-r--r-- | frontend/src/components/GameEntry.tsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/frontend/src/components/GameEntry.tsx b/frontend/src/components/GameEntry.tsx new file mode 100644 index 0000000..8e58ce9 --- /dev/null +++ b/frontend/src/components/GameEntry.tsx | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | import React from 'react'; | ||
| 2 | import { Link } from "react-router-dom"; | ||
| 3 | |||
| 4 | import { Game } from '../types/Game'; | ||
| 5 | import "../css/Games.css" | ||
| 6 | |||
| 7 | interface GameEntryProps { | ||
| 8 | game: Game; | ||
| 9 | } | ||
| 10 | |||
| 11 | const GameEntry: React.FC<GameEntryProps> = ({ game }) => { | ||
| 12 | |||
| 13 | React.useEffect(() => { | ||
| 14 | game.category_portals.forEach(catInfo => { | ||
| 15 | const itemBody = document.createElement("div"); | ||
| 16 | const itemTitle = document.createElement("span"); | ||
| 17 | const spacing = document.createElement("br"); | ||
| 18 | const itemNum = document.createElement("span"); | ||
| 19 | |||
| 20 | itemTitle.innerText = catInfo.category.name; | ||
| 21 | itemNum.innerText = catInfo.portal_count as any as string; | ||
| 22 | itemTitle.classList.add("games-page-item-body-item-title"); | ||
| 23 | itemNum.classList.add("games-page-item-body-item-num"); | ||
| 24 | itemBody.appendChild(itemTitle); | ||
| 25 | itemBody.appendChild(spacing); | ||
| 26 | itemBody.appendChild(itemNum); | ||
| 27 | itemBody.className = "games-page-item-body-item"; | ||
| 28 | |||
| 29 | // itemBody.innerHTML = ` | ||
| 30 | // <span className='games-page-item-body-item-title'>${catInfo.category.name}</span><br /> | ||
| 31 | // <span className='games-page-item-body-item-num'>${catInfo.portal_count}</span>` | ||
| 32 | |||
| 33 | document.getElementById(`${game.id}`)!.appendChild(itemBody); | ||
| 34 | }); | ||
| 35 | }, []); | ||
| 36 | |||
| 37 | return ( | ||
| 38 | <Link to={"/games/" + game.id}><div className='games-page-item'> | ||
| 39 | <div className='games-page-item-header'> | ||
| 40 | <div style={{ backgroundImage: `url(${game.image})` }} className='games-page-item-header-img'></div> | ||
| 41 | <span><b>{game.name}</b></span> | ||
| 42 | </div> | ||
| 43 | <div id={game.id as any as string} className='games-page-item-body'> | ||
| 44 | </div> | ||
| 45 | </div></Link> | ||
| 46 | ); | ||
| 47 | }; | ||
| 48 | |||
| 49 | export default GameEntry; | ||