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: 2 additions & 0 deletions docs/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

- **Communicating state.** The favorite button uses `aria-pressed`, the "Read more" button on the book page uses `aria-expanded`, and disabled pagination links use `aria-disabled` and are skipped when tabbing. Loading and empty search results are announced with `role="status"`.

- **A sticky header that does not hide the focus.** The header stays at the top of the screen while scrolling, so the navigation is always within reach, also on mobile (#165). A sticky header can cover the element that has keyboard focus, so we set `scroll-padding-top` to the height of the header. The browser then scrolls a focused element, and the target of the skip link, to below the header instead of behind it.

- **Responsive layout.** The book grid goes from four columns to one as the screen gets narrower, and the book page stacks vertically on small screens, so the app can be used on phones.

## Pointer cursor on interactive elements
Expand Down
4 changes: 3 additions & 1 deletion frontend/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function Header() {
const { data: session, isPending } = authClient.useSession();

return (
<header className="flex items-center justify-between border-b-2 border-zinc-800 not-dark:bg-white px-10 py-3.75">
// The header stays at the top while scrolling, so the navigation is always
// within reach. Its height is a CSS variable, see index.css
<header className="sticky top-0 z-40 flex h-(--header-height) items-center justify-between border-b-2 border-zinc-800 bg-white px-10 dark:bg-background">
<section className="flex items-center gap-10">
<Link to="/">
{/* <span> used strictly for inline text styling */}
Expand Down
5 changes: 5 additions & 0 deletions frontend/app/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
}
html {
@apply font-sans;
/* The header is sticky, so anchors and elements that get keyboard focus
must be scrolled to below it instead of behind it */
scroll-padding-top: var(--header-height);
}

body {
Expand Down Expand Up @@ -88,6 +91,8 @@
}

:root {
/* The height of the sticky header. Other sticky elements are placed below it */
--header-height: 4rem;
color-scheme: light;
--background: oklch(0.9659 0.0042 56.37);
--foreground: oklch(0.145 0 0);
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/book/selectedBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default function SelectedBookPage({ params }: Route.ComponentProps) {
</Button>

<section className="grid grid-cols-1 gap-2 lg:items-stretch lg:grid-cols-[2fr_3fr]">
<Card className="relative min-h-96 items-center justify-center p-7.5 lg:sticky lg:top-4 lg:h-160 lg:self-start [&>figure]:w-76 [&>figure]:max-w-full [&>p]:w-80 [&>p]:max-w-full">
<Card className="relative min-h-96 items-center justify-center p-7.5 lg:sticky lg:top-[calc(var(--header-height)+1rem)] lg:h-160 lg:self-start [&>figure]:w-76 [&>figure]:max-w-full [&>p]:w-80 [&>p]:max-w-full">
<FavoriteButton book={book} />
<BookCover book={book} loading="eager" />
<BookRating rating={book.rating} numRatings={book.numRatings} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/books.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function BooksLayout({
<main className="flex gap-2 w-full mx-auto max-w-360 lg:px-10">
<aside
aria-label="Book filters"
className="hidden sticky top-6 self-start shrink-0 w-72 max-h-[calc(100svh-3rem)] mt-40 mb-13 p-4 overflow-y-auto rounded-xl border bg-card lg:block"
className="hidden sticky top-[calc(var(--header-height)+1.5rem)] self-start shrink-0 w-72 max-h-[calc(100svh-var(--header-height)-3rem)] mt-40 mb-13 p-4 overflow-y-auto rounded-xl border bg-card lg:block"
>
<BookFilters />
</aside>
Expand Down