Table of Contents
Setting up the project
npm create vite@4.1.0
✔ Project name: … game-hub
✔ Select a framework: › React
✔ Select a variant: › TypeScript
Scaffolding project in /Users/shazdeh/Downloads/React-js/game-hub...
Done. Now run:
cd game-hub
npm install
npm run dev
cd game-hub
npm i
added 77 packages, and audited 78 packages in 7s
7 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm run dev
git init
git add .
git commit -m "Initial commit"
Installing Charka UI
- Go to the Chakra UI website,
- Click on the Get Started button.
- Select Vite on the bottom of the page from the Framework Guide section.
- Follow the instructions on the page.
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion
main.tsx
import React from "react";
import ReactDOM from "react-dom/client";
import { ChakraProvider } from "@chakra-ui/react";
import App from "./App";
import "./index.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
);
App.tsx
import { Button, ButtonGroup } from "@chakra-ui/react";
function App() {
return ;
}
export default App;
To remove the ugly border around the button, clear the index.css default contents for Vite

To check the commits use the following command.
git log --oneline
Creating a responsive layout
Using the Grid System of Chakra UI to set the layout of the page
import { Grid, GridItem } from "@chakra-ui/react";
function App() {
return (
{/* to add more than one string we use back ticks */}
Nav
Aside
Main
);
}
export default App;
To make the layout responsive do the following changes in the code:
import { Grid, GridItem, Show } from "@chakra-ui/react";
function App() {
return (
Nav
Aside
Main
);
}
export default App;
Building the navigation bar
App.tsx
import { Grid, GridItem, Show } from "@chakra-ui/react";
import NavBar from "./components/NavBar";
function App() {
return (
Aside
Main
);
}
export default App;
src/components/NavBar.tsx
import { HStack, Image, Text } from "@chakra-ui/react";
import logo from "../assets/logo.webp";
const NavBar = () => {
return (
NavBar
);
};
export default NavBar;
Implementing the dark mode
Follow the Chakra color mode instruction from the following link:
src/theme.ts
import { extendTheme, ThemeConfig } from "@chakra-ui/react";
const config: ThemeConfig = {
initialColorMode: 'dark'
}
const theme = extendTheme({ config });
export default theme;
main.tsx
import React from "react";
import ReactDOM from "react-dom/client";
import { ChakraProvider, ColorModeScript } from "@chakra-ui/react";
import App from "./App";
import theme from "./theme";
import "./index.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
);
Building the color mode switch
components/ColorModeSwitch.tsx
import { HStack, Switch, Text, useColorMode } from "@chakra-ui/react";
const ColorModeSwitch = () => {
const { toggleColorMode, colorMode } = useColorMode();
return (
Dark mode
);
};
export default ColorModeSwitch;
components/NavBar.tsx
import { HStack, Image } from "@chakra-ui/react";
import logo from "../assets/logo.webp";
import ColorModeSwitch from "./ColorModeSwitch";
const NavBar = () => {
return (
);
};
export default NavBar;
Fetching the Games
Go to RAWG website and get your API key after signing up. And copy the provided API key.
import { HStack, Image } from "@chakra-ui/react";
import logo from "../assets/logo.webp";
import ColorModeSwitch from "./ColorModeSwitch";
const NavBar = () => {
return (
);
};
export default NavBar;