diff options
| author | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2024-12-11 09:41:13 +0100 |
|---|---|---|
| committer | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2024-12-11 09:41:13 +0100 |
| commit | d19aebd898af77dbc65fabfc4fe905f72769ccc7 (patch) | |
| tree | 28121000fd821b01d8662f238ea2d0a6e10ec1b5 /frontend/src | |
| parent | fix/frontent: fix category parameter not working (diff) | |
| download | lphub-d19aebd898af77dbc65fabfc4fe905f72769ccc7.tar.gz lphub-d19aebd898af77dbc65fabfc4fe905f72769ccc7.tar.bz2 lphub-d19aebd898af77dbc65fabfc4fe905f72769ccc7.zip | |
fix/frontend: games page css rehaul, small maplist fixes
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/components/GameCategory.tsx | 8 | ||||
| -rw-r--r-- | frontend/src/components/GameEntry.tsx | 9 | ||||
| -rw-r--r-- | frontend/src/css/Games.module.css | 61 | ||||
| -rw-r--r-- | frontend/src/css/Info.module.css | 21 | ||||
| -rw-r--r-- | frontend/src/pages/Games.tsx | 26 | ||||
| -rw-r--r-- | frontend/src/pages/Maplist.tsx | 6 |
6 files changed, 101 insertions, 30 deletions
diff --git a/frontend/src/components/GameCategory.tsx b/frontend/src/components/GameCategory.tsx index d8879ef..80ee416 100644 --- a/frontend/src/components/GameCategory.tsx +++ b/frontend/src/components/GameCategory.tsx | |||
| @@ -3,6 +3,8 @@ import { Link } from "react-router-dom"; | |||
| 3 | 3 | ||
| 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; | 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; |
| 5 | import "@css/Games.css" | 5 | import "@css/Games.css" |
| 6 | import games from "@css/Games.module.css"; | ||
| 7 | import info from "@css/Info.module.css"; | ||
| 6 | 8 | ||
| 7 | interface GameCategoryProps { | 9 | interface GameCategoryProps { |
| 8 | game: Game; | 10 | game: Game; |
| @@ -11,11 +13,11 @@ interface GameCategoryProps { | |||
| 11 | 13 | ||
| 12 | const GameCategory: React.FC<GameCategoryProps> = ({cat, game}) => { | 14 | const GameCategory: React.FC<GameCategoryProps> = ({cat, game}) => { |
| 13 | return ( | 15 | return ( |
| 14 | <Link className="games-page-item-body-item" to={"/games/" + game.id + "?cat=" + cat.category.id}> | 16 | <Link className={info.infoBlock} to={"/games/" + game.id + "?cat=" + cat.category.id}> |
| 15 | <div> | 17 | <div> |
| 16 | <span className='games-page-item-body-item-title'>{cat.category.name}</span> | 18 | <span>{cat.category.name}</span> |
| 17 | <br /> | 19 | <br /> |
| 18 | <span className='games-page-item-body-item-num'>{cat.portal_count}</span> | 20 | <span>{cat.portal_count}</span> |
| 19 | </div> | 21 | </div> |
| 20 | </Link> | 22 | </Link> |
| 21 | ) | 23 | ) |
diff --git a/frontend/src/components/GameEntry.tsx b/frontend/src/components/GameEntry.tsx index 3bd2842..ebba419 100644 --- a/frontend/src/components/GameEntry.tsx +++ b/frontend/src/components/GameEntry.tsx | |||
| @@ -3,6 +3,7 @@ import { Link } from "react-router-dom"; | |||
| 3 | 3 | ||
| 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; | 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; |
| 5 | import "@css/Games.css" | 5 | import "@css/Games.css" |
| 6 | import games from "@css/Games.module.css"; | ||
| 6 | 7 | ||
| 7 | import GameCategory from '@components/GameCategory'; | 8 | import GameCategory from '@components/GameCategory'; |
| 8 | 9 | ||
| @@ -18,12 +19,12 @@ const GameEntry: React.FC<GameEntryProps> = ({ game }) => { | |||
| 18 | }, [game.category_portals]); | 19 | }, [game.category_portals]); |
| 19 | 20 | ||
| 20 | return ( | 21 | return ( |
| 21 | <Link to={"/games/" + game.id}><div className='games-page-item'> | 22 | <Link to={"/games/" + game.id}><div className={games.game}> |
| 22 | <div className='games-page-item-header'> | 23 | <div className={games.header}> |
| 23 | <div style={{ backgroundImage: `url(${game.image})` }} className='games-page-item-header-img'></div> | 24 | <div style={{ backgroundImage: `url(${game.image})` }}></div> |
| 24 | <span><b>{game.name}</b></span> | 25 | <span><b>{game.name}</b></span> |
| 25 | </div> | 26 | </div> |
| 26 | <div id={game.id as any as string} className='games-page-item-body'> | 27 | <div id={game.id as any as string} className={games.infoBlockContainer}> |
| 27 | {catInfo.map((cat, index) => { | 28 | {catInfo.map((cat, index) => { |
| 28 | return <GameCategory cat={cat} game={game} key={index}></GameCategory> | 29 | return <GameCategory cat={cat} game={game} key={index}></GameCategory> |
| 29 | })} | 30 | })} |
diff --git a/frontend/src/css/Games.module.css b/frontend/src/css/Games.module.css new file mode 100644 index 0000000..4c598cd --- /dev/null +++ b/frontend/src/css/Games.module.css | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | .content { | ||
| 2 | position: relative; | ||
| 3 | display: flex; | ||
| 4 | flex-direction: column; | ||
| 5 | width: 100%; | ||
| 6 | gap: 24px; | ||
| 7 | margin-top: 24px; | ||
| 8 | } | ||
| 9 | |||
| 10 | .content a { | ||
| 11 | position: relative; | ||
| 12 | width: 100%; | ||
| 13 | } | ||
| 14 | |||
| 15 | .game { | ||
| 16 | display: flex; | ||
| 17 | width: 100%; | ||
| 18 | flex-direction: column; | ||
| 19 | overflow: hidden; | ||
| 20 | border-radius: 24px; | ||
| 21 | background-color: var(--primary-dark); | ||
| 22 | } | ||
| 23 | |||
| 24 | .header { | ||
| 25 | display: flex; | ||
| 26 | overflow: hidden; | ||
| 27 | position: relative; | ||
| 28 | flex: 1; | ||
| 29 | } | ||
| 30 | |||
| 31 | .header span { | ||
| 32 | position: relative; | ||
| 33 | z-index: 2; | ||
| 34 | display: flex; | ||
| 35 | text-align: center; | ||
| 36 | justify-content: center; | ||
| 37 | width: 100%; | ||
| 38 | padding: 24px 0px; | ||
| 39 | text-wrap: nowrap; | ||
| 40 | } | ||
| 41 | |||
| 42 | .header div { | ||
| 43 | position: absolute; | ||
| 44 | top: 0; | ||
| 45 | left: 0; | ||
| 46 | width: 100%; | ||
| 47 | height: 100%; | ||
| 48 | z-index: 1; | ||
| 49 | background-size: cover; | ||
| 50 | filter: blur(4px); | ||
| 51 | } | ||
| 52 | |||
| 53 | .infoBlockContainer { | ||
| 54 | flex: 1; | ||
| 55 | display: flex; | ||
| 56 | gap: 12px; | ||
| 57 | margin: 12px; | ||
| 58 | align-items: center; | ||
| 59 | justify-content: center; | ||
| 60 | height: 50%; | ||
| 61 | } | ||
diff --git a/frontend/src/css/Info.module.css b/frontend/src/css/Info.module.css new file mode 100644 index 0000000..144346e --- /dev/null +++ b/frontend/src/css/Info.module.css | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | .infoBlock { | ||
| 2 | background-color: var(--primary); | ||
| 3 | display: flex; | ||
| 4 | width: 100%; | ||
| 5 | border-radius: 18px; | ||
| 6 | text-align: center; | ||
| 7 | justify-content: center; | ||
| 8 | padding: 4px 0px; | ||
| 9 | text-wrap: nowrap; | ||
| 10 | } | ||
| 11 | |||
| 12 | .infoBlock > div > span:nth-child(1) { | ||
| 13 | margin-top: 0px; | ||
| 14 | font-size: 26px; | ||
| 15 | } | ||
| 16 | |||
| 17 | .infoBlock > div > span:nth-child(3) { | ||
| 18 | font-size: 50px; | ||
| 19 | font-family: BarlowCondensed-Bold; | ||
| 20 | } | ||
| 21 | |||
diff --git a/frontend/src/pages/Games.tsx b/frontend/src/pages/Games.tsx index e7e031e..45dd170 100644 --- a/frontend/src/pages/Games.tsx +++ b/frontend/src/pages/Games.tsx | |||
| @@ -3,36 +3,20 @@ import React from 'react'; | |||
| 3 | import GameEntry from '@components/GameEntry'; | 3 | import GameEntry from '@components/GameEntry'; |
| 4 | import { Game } from '@customTypes/Game'; | 4 | import { Game } from '@customTypes/Game'; |
| 5 | import "@css/Maps.css" | 5 | import "@css/Maps.css" |
| 6 | import gamesCSS from "@css/Games.module.css"; | ||
| 6 | 7 | ||
| 7 | interface GamesProps { | 8 | interface GamesProps { |
| 8 | games: Game[]; | 9 | games: Game[]; |
| 9 | } | 10 | } |
| 10 | 11 | ||
| 11 | const Games: React.FC<GamesProps> = ({ games }) => { | 12 | const Games: React.FC<GamesProps> = ({ games }) => { |
| 12 | |||
| 13 | const _page_load = () => { | ||
| 14 | const loaders = document.querySelectorAll(".loader"); | ||
| 15 | loaders.forEach((loader) => { | ||
| 16 | (loader as HTMLElement).style.display = "none"; | ||
| 17 | }); | ||
| 18 | } | ||
| 19 | |||
| 20 | React.useEffect(() => { | ||
| 21 | document.querySelectorAll(".games-page-item-body").forEach((game, index) => { | ||
| 22 | game.innerHTML = ""; | ||
| 23 | }); | ||
| 24 | _page_load(); | ||
| 25 | }, []); | ||
| 26 | |||
| 27 | return ( | 13 | return ( |
| 28 | <main> | 14 | <main> |
| 29 | <section> | 15 | <section> |
| 30 | <div className='games-page-content'> | 16 | <div className={gamesCSS.content}> |
| 31 | <div className='games-page-item-content'> | 17 | {games.map((game, index) => ( |
| 32 | {games.map((game, index) => ( | 18 | <GameEntry game={game} key={index} /> |
| 33 | <GameEntry game={game} key={index} /> | 19 | ))} |
| 34 | ))} | ||
| 35 | </div> | ||
| 36 | </div> | 20 | </div> |
| 37 | </section> | 21 | </section> |
| 38 | </main> | 22 | </main> |
diff --git a/frontend/src/pages/Maplist.tsx b/frontend/src/pages/Maplist.tsx index 7b4ce06..ecea3e1 100644 --- a/frontend/src/pages/Maplist.tsx +++ b/frontend/src/pages/Maplist.tsx | |||
| @@ -123,7 +123,9 @@ const Maplist: React.FC = () => { | |||
| 123 | )?.portal_count | 123 | )?.portal_count |
| 124 | } | 124 | } |
| 125 | </h2> | 125 | </h2> |
| 126 | <h3>portals</h3> | 126 | <h3>{game?.category_portals.find( |
| 127 | (obj) => obj.category.id === catNum + 1)!.portal_count == 1 ? "portal" : "portals" | ||
| 128 | }</h3> | ||
| 127 | </div> | 129 | </div> |
| 128 | <div className="game-header-categories"> | 130 | <div className="game-header-categories"> |
| 129 | {game?.category_portals.map((cat, index) => ( | 131 | {game?.category_portals.map((cat, index) => ( |
| @@ -162,7 +164,7 @@ const Maplist: React.FC = () => { | |||
| 162 | <span>{map.is_disabled ? map.category_portals[0].portal_count : map.category_portals.find( | 164 | <span>{map.is_disabled ? map.category_portals[0].portal_count : map.category_portals.find( |
| 163 | (obj) => obj.category.id === catNum + 1 | 165 | (obj) => obj.category.id === catNum + 1 |
| 164 | )?.portal_count}</span> | 166 | )?.portal_count}</span> |
| 165 | <span>portals</span> | 167 | <span>{map.category_portals.find((obj) => obj.category.id === catNum + 1)?.portal_count == 1 ? "portal" : "portals"}</span> |
| 166 | </div> | 168 | </div> |
| 167 | </div> | 169 | </div> |
| 168 | <div className="difficulty-bar"> | 170 | <div className="difficulty-bar"> |