Add a dynamic page heading

This commit is contained in:
Mosh Hamedani 2023-03-03 11:31:33 -08:00
parent f002e86214
commit c5dc8367f6
2 changed files with 26 additions and 6 deletions

View file

@ -1,6 +1,7 @@
import { Box, Flex, Grid, GridItem, HStack, Show } from "@chakra-ui/react";
import { useState } from "react";
import GameGrid from "./components/GameGrid";
import GameHeading from "./components/GameHeading";
import GenreList from "./components/GenreList";
import NavBar from "./components/NavBar";
import PlatformSelector from "./components/PlatformSelector";
@ -39,12 +40,15 @@ function App() {
</GridItem>
</Show>
<GridItem area="main">
<Flex paddingLeft={2} marginBottom={5}>
<Box paddingLeft={2}>
<GameHeading gameQuery={gameQuery} />
<Flex marginBottom={5}>
<Box marginRight={5}>
<PlatformSelector selectedPlatform={gameQuery.platform} onSelectPlatform={(platform) => setGameQuery({ ...gameQuery, platform}) } />
</Box>
<SortSelector sortOrder={gameQuery.sortOrder} onSelectSortOrder={(sortOrder) => setGameQuery({ ...gameQuery, sortOrder })} />
</Flex>
</Box>
<GameGrid gameQuery={gameQuery} />
</GridItem>
</Grid>

View file

@ -0,0 +1,16 @@
import { Heading } from '@chakra-ui/react'
import { GameQuery } from '../App'
interface Props {
gameQuery: GameQuery
}
const GameHeading = ({ gameQuery }: Props) => {
const heading = `${gameQuery.platform?.name || ''} ${gameQuery.genre?.name || ''} Games`;
return (
<Heading as='h1' marginY={5} fontSize='5xl'>{heading}</Heading>
)
}
export default GameHeading