-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upto second part (Intermediate Topics)
- Loading branch information
0 parents
commit 313a857
Showing
61 changed files
with
1,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
package-lock.json | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# GameHub | ||
|
||
GameHub is a video game discovery web app that helps you find new and interesting games to play. With GameHub, you can search for games by platform, genre, and more. | ||
|
||
## DEMO URL | ||
|
||
https://game-hub-mocha.vercel.app/ | ||
|
||
## Getting Started | ||
|
||
To get started with GameHub, follow these steps: | ||
|
||
1. Clone this repository to your local machine. | ||
2. Run `npm install` to install the required dependencies. | ||
3. Run `npm run dev` to start the web server. | ||
|
||
## About the Course | ||
|
||
I have learned everything I need to know to become a proficient React developer. I learned how to: | ||
|
||
- Build front-end apps with React and TypeScript | ||
- Build reusable function components | ||
- Style your components using vanilla CSS, CSS modules, and CSS-in-JS | ||
- Manage component state | ||
- Build forms with React Hook Forms | ||
- Implement form validation using Zod | ||
- Connect your React apps to the backend | ||
- Deploy your React apps | ||
- Use VSCode shortcuts to increase your productivity | ||
- Write clean code like a pro | ||
- Apply best practices | ||
|
||
I have now solid understanding of React and be able to build real-world applications with React and TypeScript. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>GameHub</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "game-hub", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@chakra-ui/react": "^2.5.1", | ||
"@emotion/react": "^11.10.6", | ||
"@emotion/styled": "^11.10.6", | ||
"@tanstack/react-query": "4.28", | ||
"@tanstack/react-query-devtools": "4.28", | ||
"axios": "^1.3.4", | ||
"framer-motion": "^10.0.1", | ||
"ms": "^2.1.3", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-icons": "^4.7.1", | ||
"react-infinite-scroll-component": "6.1", | ||
"react-router-dom": "^6.10.0", | ||
"zustand": "^4.3.7" | ||
}, | ||
"devDependencies": { | ||
"@types/ms": "^0.7.31", | ||
"@types/react": "^18.0.27", | ||
"@types/react-dom": "^18.0.10", | ||
"@vitejs/plugin-react": "^3.1.0", | ||
"typescript": "^4.9.3", | ||
"vite": "^4.1.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { HStack, Switch, Text, useColorMode } from '@chakra-ui/react' | ||
|
||
const ColorModeSwitch = () => { | ||
const {toggleColorMode, colorMode} = useColorMode(); | ||
|
||
return ( | ||
<HStack> | ||
<Switch colorScheme='green' isChecked={colorMode === 'dark'} onChange={toggleColorMode} /> | ||
<Text whiteSpace='nowrap'>Dark Mode</Text> | ||
</HStack> | ||
) | ||
} | ||
|
||
export default ColorModeSwitch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Badge } from '@chakra-ui/react'; | ||
|
||
interface Props { | ||
score: number; | ||
} | ||
|
||
const CriticScore = ({ score }: Props) => { | ||
let color = score > 75 ? 'green' : score > 60 ? 'yellow' : ''; | ||
|
||
return ( | ||
<Badge colorScheme={color} fontSize='14px' paddingX={2} borderRadius='4px'>{score}</Badge> | ||
) | ||
} | ||
|
||
export default CriticScore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Box, Heading } from '@chakra-ui/react'; | ||
import React, { ReactNode } from 'react' | ||
|
||
interface Props { | ||
term: string; | ||
children: ReactNode | ReactNode[]; | ||
} | ||
|
||
const DefinitionItem = ({ term, children }: Props) => { | ||
return ( | ||
<Box marginY={5}> | ||
<Heading as='dt' fontSize='md' color='gray.600'> | ||
{term} | ||
</Heading> | ||
<dd> | ||
{children} | ||
</dd> | ||
</Box> | ||
) | ||
} | ||
|
||
export default DefinitionItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import bullsEye from '../assets/bulls-eye.webp'; | ||
import thumbsUp from '../assets/thumbs-up.webp'; | ||
import meh from '../assets/meh.webp'; | ||
import { Image, ImageProps } from '@chakra-ui/react'; | ||
|
||
interface Props { | ||
rating: number; | ||
} | ||
|
||
const Emoji = ({ rating }: Props) => { | ||
if (rating < 3) return null; | ||
|
||
const emojiMap: { [key: number]: ImageProps } = { | ||
3: { src: meh, alt: 'meh', boxSize: '25px' }, | ||
4: { src: thumbsUp, alt: 'recommended', boxSize: '25px' }, | ||
5: { src: bullsEye, alt: 'exceptional', boxSize: '35px' }, | ||
} | ||
|
||
return ( | ||
<Image {...emojiMap[rating]} marginTop={1} /> | ||
) | ||
} | ||
|
||
export default Emoji |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Button, Text } from '@chakra-ui/react'; | ||
import React, { useState } from 'react'; | ||
|
||
interface Props { | ||
children: string; | ||
} | ||
|
||
const ExpandableText = ({ children }: Props) => { | ||
const [expanded, setExpanded] = useState(false); | ||
const limit = 300; | ||
|
||
if (!children) return null; | ||
|
||
if (children.length <= limit) return <Text>{children}</Text>; | ||
|
||
const summary = expanded ? children : children.substring(0, limit) + '...'; | ||
|
||
return ( | ||
<Text> | ||
{summary} | ||
<Button | ||
size="xs" | ||
marginLeft={1} | ||
fontWeight="bold" | ||
colorScheme="yellow" | ||
onClick={() => setExpanded(!expanded)} | ||
> | ||
{expanded ? 'Show Less' : 'Read More'} | ||
</Button> | ||
</Text> | ||
); | ||
}; | ||
|
||
export default ExpandableText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SimpleGrid, Text } from '@chakra-ui/react'; | ||
import Game from '../entities/Game'; | ||
import CriticScore from './CriticScore'; | ||
import DefinitionItem from './DefinitionItem'; | ||
|
||
interface Props { | ||
game: Game; | ||
} | ||
|
||
const GameAttributes = ({ game }: Props) => { | ||
return ( | ||
<SimpleGrid columns={2} as="dl"> | ||
<DefinitionItem term="Platforms"> | ||
{game.parent_platforms?.map(({ platform }) => ( | ||
<Text key={platform.id}>{platform.name}</Text> | ||
))} | ||
</DefinitionItem> | ||
<DefinitionItem term="Metascore"> | ||
<CriticScore score={game.metacritic} /> | ||
</DefinitionItem> | ||
<DefinitionItem term="Genres"> | ||
{game.genres.map((genre) => ( | ||
<Text key={genre.id}>{genre.name}</Text> | ||
))} | ||
</DefinitionItem> | ||
<DefinitionItem term="Publishers"> | ||
{game.publishers?.map((publisher) => ( | ||
<Text key={publisher.id}>{publisher.name}</Text> | ||
))} | ||
</DefinitionItem> | ||
</SimpleGrid> | ||
); | ||
}; | ||
|
||
export default GameAttributes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
Card, | ||
CardBody, | ||
Heading, | ||
HStack, | ||
Image | ||
} from '@chakra-ui/react'; | ||
import { Link } from 'react-router-dom'; | ||
import Game from '../entities/Game'; | ||
import getCroppedImageUrl from '../services/image-url'; | ||
import CriticScore from './CriticScore'; | ||
import Emoji from './Emoji'; | ||
import PlatformIconList from './PlatformIconList'; | ||
|
||
interface Props { | ||
game: Game; | ||
} | ||
|
||
const GameCard = ({ game }: Props) => { | ||
return ( | ||
<Card> | ||
<Image src={getCroppedImageUrl(game.background_image)} /> | ||
<CardBody> | ||
<HStack justifyContent="space-between" marginBottom={3}> | ||
<PlatformIconList | ||
platforms={game.parent_platforms?.map( | ||
(p) => p.platform | ||
)} | ||
/> | ||
<CriticScore score={game.metacritic} /> | ||
</HStack> | ||
<Heading fontSize="2xl"> | ||
<Link to={'/games/' + game.slug}>{game.name}</Link> | ||
<Emoji rating={game.rating_top} /> | ||
</Heading> | ||
</CardBody> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default GameCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Box } from '@chakra-ui/react'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface Props { | ||
children: ReactNode; | ||
} | ||
|
||
const GameCardContainer = ({ children }: Props) => { | ||
return ( | ||
<Box | ||
_hover={{ | ||
transform: 'scale(1.03)', | ||
transition: 'transform .15s ease-in' | ||
}} | ||
borderRadius={10} | ||
overflow="hidden" | ||
> | ||
{children} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default GameCardContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Card, CardBody, Skeleton, SkeletonText } from '@chakra-ui/react' | ||
|
||
const GameCardSkeleton = () => { | ||
return ( | ||
<Card> | ||
<Skeleton height="200px" /> | ||
<CardBody> | ||
<SkeletonText /> | ||
</CardBody> | ||
</Card> | ||
) | ||
} | ||
|
||
export default GameCardSkeleton |
Oops, something went wrong.
313a857
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
game-hub – ./
game-hub-niteshpk.vercel.app
game-hub-git-master-niteshpk.vercel.app
game-hub-mocha.vercel.app