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
1 change: 1 addition & 0 deletions frontend/app/components/BookCard/BookCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function BookCard({ book, searchListParams }: BookCardProps) {
aria-hidden="true"
className="size-4 fill-amber-400 text-amber-400"
/>
{/* <span> used strictly for inline text styling */}
<span className="font-medium text-foreground">
{book.rating.toFixed(2)}
</span>
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/components/BookRating/BookRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { StarIcon } from "lucide-react";

const MAX_RATING = 5;

// Uses span elements for grouping inline content, styling, and positioning the
// rating stars. No more suitable semantic HTML elements exist for these purposes.
function BookRating({
rating,
numRatings,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { buttonVariants } from "~/components/ui/Button";
function Footer() {
return (
<footer className="border-t-2 border-zinc-800 bg-background text-sm text-muted-foreground">
{/* The div wrapper only controls the footer's responsive layout. */}
<div className="mx-auto flex flex-col text-center max-w-300 flex-wrap items-center gap-x-6 gap-y-8 px-10 py-12 md:flex-row md:justify-between md:text-left">
<p className="flex flex-col gap-1">
<Link to="/" className="text-2xl text-foreground">
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Header() {
<header className="flex items-center justify-between border-b-2 border-zinc-800 not-dark:bg-white px-10 py-3.75">
<section className="flex items-center gap-10">
<Link to="/">
{/* <span> used strictly for inline text styling */}
<span className="text-2xl">Readr</span>
</Link>

Expand All @@ -35,7 +36,7 @@ function Header() {

<MobileHeaderMenu />

<div className="hidden md:flex items-center gap-2">
<nav aria-label="Account" className="hidden md:flex items-center gap-2">
<DarkModeToggle variant="button" />
{!isPending && session ? (
<>
Expand Down Expand Up @@ -65,7 +66,7 @@ function Header() {
Log in
</Link>
)}
</div>
</nav>
</header>
);
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/components/ReviewList/ReviewList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface ReviewListProps {
function ReviewList({ reviews, totalCount, headingId }: ReviewListProps) {
const totalPages = Math.ceil(totalCount / REVIEW_PAGE_LIMIT);

// The div wrapper groups the review list with its pagination controls.
return (
<div className="flex flex-col gap-4">
<ul className="flex flex-col divide-y">
Expand All @@ -38,6 +39,7 @@ function ReviewList({ reviews, totalCount, headingId }: ReviewListProps) {
</Link>
)}
{review.user && (
// <span> used strictly for inline text styling.
<span className="font-medium">{review.user.name}</span>
)}
<StarRating rating={review.rating} />
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/StarRating/StarRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Star({ filled, className }: { filled: boolean; className?: string }) {
}

// Read-only whole star rating, e.g. the rating of a review.
// Spans are used for inline grouping and screen-reader text. No additional semantic elements are needed.
function StarRating({ rating }: { rating: number }) {
return (
<span className="flex items-center gap-0.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function FilterSection({
return (
<AccordionItem value={value}>
<AccordionTrigger className="items-center">
{/* The <span> elements group the inline title and badge while providing separate visual and screen-reader text. */}
<span className="flex items-center gap-2">
{/* The space keeps screen readers from reading "Genres2 selected" */}
{title}{" "}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/components/books/PagesFilter/PagesFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function PagesFilter() {
commit(newMin, newMax);
}}
/>
{/* The div groups the two related numeric inputs for layout purposes. */}
<div className="flex items-center justify-between gap-2">
<PageInput
aria-label="Minimum pages"
Expand All @@ -94,6 +95,7 @@ function PagesFilter() {
}
onCommit={commitInputs}
/>
{/* The span is used for the decorative separator between the inputs. */}
<span aria-hidden="true">-</span>
<PageInput
aria-label="Maximum pages"
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/components/books/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ function SearchBar({ resultCount }: SearchBarProps) {
<SheetContent side="left" className="gap-0">
{/* Names the sheet for screen readers. The filters show their own heading */}
<SheetTitle className="sr-only">Filter books</SheetTitle>
{/* Only the filters scroll, so the "Show books" button below is always visible.
The top padding leaves room for the close (X) button */}
{/* The div wrapper provides an independently scrolling area for the filters,
so the "Show books" button below is always visible while scrolling.
The top padding leaves room for the close (X) button. */}
<div className="flex-1 overflow-y-auto p-4 pt-12">
<BookFilters />
</div>
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/home/HeroSection/HeroSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ function HeroSection({
aria-labelledby="hero-heading"
className="mx-auto grid max-w-300 items-center gap-12 px-10 py-16 md:grid-cols-2"
>
{/* The div wrapper groups the hero text, search form, and navigation for layout purposes. */}
<div className="flex flex-col gap-6 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-4 motion-safe:duration-700">
<h1 id="hero-heading" className="text-5xl tracking-tight">
Discover books{" "}
Discover books {/* <span> used strictly for inline text styling */}
<span className="text-primary dark:text-blue-300">worth reading</span>
</h1>
<p className="text-lg text-muted-foreground">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function HowItWorksSection() {
<li key={title}>
<Card className="h-full p-6 transition-all duration-200 hover:shadow-xl motion-safe:hover:-translate-y-0.5">
<CardHeader className="flex flex-col gap-4 p-0">
{/* The span wraps the decorative step icon for styling and layout purposes. */}
<span className="grid size-12 place-items-center rounded-full bg-accent text-primary dark:text-blue-300">
<Icon aria-hidden="true" />
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ interface StatProps {
function Stat({ label, value, start }: StatProps) {
const count = useCountUp(value, start);

// The div groups the term and its associated value.
return (
<div className="flex flex-col-reverse items-center gap-1">
<dt className="text-muted-foreground">{label}</dt>
<dd className="text-4xl font-bold tracking-tight tabular-nums">
{/* Screen readers get the final number instead of every step */}
{/* The span elements provide inline text wrappers for the animated count and screen-reader text,
so screen readers get the final number instead of every step. */}
<span aria-hidden="true">{count.toLocaleString("en")}</span>
<span className="sr-only">{value.toLocaleString("en")}</span>
</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function BookReviews({
<h2 id="book-reviews-heading" className="text-xl font-bold">
Reviews
</h2>
<div className="max-w-2xl">
<section aria-label="Your review" className="max-w-2xl">
{!session ? (
<p className="text-muted-foreground">
<Link
Expand All @@ -54,7 +54,7 @@ function BookReviews({
review={myReview}
/>
)}
</div>
</section>

<Separator />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function ReviewForm({ bookId, bookTitle, review }: ReviewFormProps) {
</form.AppField>
<FieldError>{serverError}</FieldError>
</FieldGroup>
{/* The div wrapper groups the form action buttons */}
<div className="flex flex-wrap gap-2">
<form.SubmitButton>
{review ? "Update review" : "Post review"}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
Skip to main content
</a>
<Header />
{/* One target for the skip link, since each route uses its own <main> */}
{/* The <div> provides one shared focus target for the skip link, since each route renders its own <main> element. */}
<div
id="main-content"
tabIndex={-1}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/routes/books.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function BooksLayout({
>
<BookFilters />
</aside>
{/* The div wrapper groups the breadcrumb, search bar, and page content into a single layout column. */}
<div className="flex-1 min-w-0">
<BooksBreadcrumb />
<SearchBar resultCount={resultCount} />
Expand Down