Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "bootstrap/dist/css/bootstrap.min.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import GamesGrid from "./pages/GamesGrid/GamesGrid";
import GamesGrid from "./pages/GamesGrid";
import GameDetails from "./pages/GameDetails";
import MyRatings from "./pages/MyRatings";

Expand Down
44 changes: 44 additions & 0 deletions frontend/src/components/GameListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Image } from "react-bootstrap";
import { Link } from "react-router-dom";
import StarRating from "./StarRating";

interface GameListItemProps {
id: string;
title: string;
year: number | null;
tags: string;
rating: number | null;
image: string;
striped: boolean;
}

export default function GameListItem({
id,
title,
year,
tags,
rating,
image,
striped,
}: GameListItemProps) {
return (
<Link
to={`/project2/games/${id}`}
className={`d-flex gap-4 px-4 align-items-center text-reset text-decoration-none`}
style={{ minHeight: "var(--row-min-height)", flex: "1 1 0", backgroundColor: `${striped ? "var(--color-stripe-odd)" : "var(--color-stripe-even)"}`}}
>
<Image className="object-fit-cover flex-shrink-0"
style={{ width: "95px", height: "95px", backgroundColor: "#ddd" }}
src={image}
alt={title}
loading="lazy"
/>
<div>
<h3 className="mb-1 fw-bold" style={{ fontSize: "1.1rem" }}>{title}</h3>
<p className="m-0">{year ?? "—"}</p>
<p className="m-0">{tags || "—"}</p>
<StarRating score={rating} size={5} scorePosition="right"/>
</div>
</Link>
);
}
36 changes: 0 additions & 36 deletions frontend/src/components/GameListItem/GameListItem.module.css

This file was deleted.

40 changes: 0 additions & 40 deletions frontend/src/components/GameListItem/GameListItem.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {
useNavigate,
useSearchParams,
} from "react-router-dom";
import { GRID_QUERY_STORAGE_KEY } from "../../constants/storageKeys";
import styles from "./Header.module.css";
import { useIsMobile } from "../../constants/global";
import { GRID_QUERY_STORAGE_KEY } from "../constants/storageKeys";
import { useIsMobile } from "../constants/global";

export default function Header() {
const navigate = useNavigate();
Expand Down Expand Up @@ -54,14 +53,17 @@ export default function Header() {
}

return (
<header className={styles.header}>
<Link className={styles.brand} to={homeHref}>
{ isMobile ? <House size={25}/> : "Working Title" }
<header className="d-flex align-items-center justify-content-between gap-2 px-3"
style={{ backgroundColor: "var(--color-brand)", height: "var(--header-height)" }}
>
<Link className="text-decoration-none text-nowrap text-dark fw-bold" to={homeHref}>
{ isMobile ? <House size={25} aria-label="Home"/> : "Working Title" }
</Link>

<Form className={styles.search} role="search" onSubmit={handleSubmit}>
<InputGroup>
<Form className="flex-grow-1" style={{ maxWidth: "420px"}} role="search" onSubmit={handleSubmit}>
<InputGroup className="overflow-hidden rounded-pill">
<Form.Control
className="shadow-none border-0"
placeholder="Search games..."
aria-label="Search games"
value={value}
Expand All @@ -81,8 +83,8 @@ export default function Header() {
</InputGroup>
</Form>

<Link className={styles.link} to="/project2/my-ratings">
{ isMobile ? <Person size={25}/> :"My Ratings" }
<Link className="text-decoration-none text-nowrap text-dark fw-bold" to="/project2/my-ratings">
{ isMobile ? <Person size={25} aria-label="My Ratings"/> :"My Ratings" }
</Link>
</header>
);
Expand Down
39 changes: 0 additions & 39 deletions frontend/src/components/Header/Header.module.css

This file was deleted.

7 changes: 7 additions & 0 deletions frontend/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ReactNode } from "react";

export default function Layout({ children }: { children: ReactNode }) {
return <div className="mx-auto my-0 w-100" style={{ maxWidth: "var(--content-width)" }}>
{children}
</div>;
}
5 changes: 0 additions & 5 deletions frontend/src/components/Layout/Layout.module.css

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/src/components/Layout/Layout.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions frontend/src/components/Toolbar/Toolbar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
white-space: nowrap;
}

.checkOption :global(.form-check-input:not(:checked)) {
border-color: grey;
}

.panelRow {
display: flex;
flex-wrap: wrap;
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/pages/GameDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useParams } from "react-router-dom";
import { gql } from "@apollo/client";
import { useMutation, useQuery } from "@apollo/client/react";
import { uri as graphqlUri } from "../apolloClient";
import Header from "../components/Header/Header";
import Layout from "../components/Layout/Layout";
import Header from "../components/Header";
import Layout from "../components/Layout";
import StarRating from "../components/StarRating";
import { getUserId } from "../utils/userId";
import { useIsMobile } from "../constants/global";
Expand Down Expand Up @@ -116,6 +116,7 @@ export default function GameDetails() {
const { id } = useParams<{ id: string }>();
const isMobile = useIsMobile();
const userId = useMemo(() => getUserId(), []);
const imageSize: number = isMobile ? 150 : 220;

const { data, loading, error } = useQuery<GameData>(GET_GAME, {
variables: { id },
Expand Down Expand Up @@ -207,21 +208,22 @@ export default function GameDetails() {
</p>
<h1 className="ms-1 me-1 mt-2 mb-2">{game.name}</h1>

<Stack direction="horizontal" className="mb-3" gap={ isMobile ? 1 : 4}>
<Stack direction="horizontal" className="mb-3" gap={4}>
<Image
className="flex-shrink-0 object-fit-cover"
style={{ width: 220, height: 220, backgroundColor: `var(--color-stripe-odd)` }}
style={{ width: ` ${imageSize}px`, height: ` ${imageSize}px`, backgroundColor: `var(--color-stripe-odd)` }}
src={game.imageUrl ?? ""}
alt={game.name}
loading="lazy"
/>
<Stack gap={2}>
<div>
<p className="m-0 fw-bold">NTNU Rating</p>
<StarRating score={game.averageScore} />
<StarRating score={game.averageScore} size={isMobile ? 1 : 2} />
</div>
<div>
<p className="m-0 fw-bold">Your Rating</p>
<StarRating score={draftScore} onChange={handleRate} />
<StarRating score={draftScore} onChange={handleRate} size={isMobile ? 1 : 2}/>
</div>
</Stack>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client/react";
import { useSearchParams } from "react-router-dom";
import Header from "../../components/Header/Header";
import Layout from "../../components/Layout/Layout";
import Toolbar from "../../components/Toolbar/Toolbar";
import GameListItem from "../../components/GameListItem/GameListItem";
import Header from "../components/Header";
import Layout from "../components/Layout";
import Toolbar from "../components/Toolbar/Toolbar";
import GameListItem from "../components/GameListItem";
import {
GRID_PAGE_STORAGE_KEY,
GRID_QUERY_STORAGE_KEY,
} from "../../constants/storageKeys";
} from "../constants/storageKeys";
import {
DEFAULT_SORT,
hasActiveFilters,
type GameFilters,
type SortField,
type SortState,
} from "../../types/gameQuery";
import styles from "./GamesGrid.module.css";
} from "../types/gameQuery";

const GET_GAMES = gql`
query GetGames(
Expand Down Expand Up @@ -255,7 +254,10 @@ export default function GamesGrid() {
sort={sort}
onSortChange={updateSort}
/>
<div className={styles.list} ref={listRef}>
<div className="d-flex flex-column overflow-hidden"
style={{ height: "calc(100vh - var(--header-height) - var(--toolbar-height))" }}
ref={listRef}
>
<p className="visually-hidden" aria-live="polite">
{!loading && `${totalCount} game${totalCount === 1 ? "" : "s"} found`}
</p>
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/pages/GamesGrid/GamesGrid.module.css

This file was deleted.

Loading