Skip to content

Related-books section: responsive columns, no more enormous covers on large screens#278

Merged
fabiodalez-dev merged 3 commits into
mainfrom
fix/related-books-responsive-columns
Jul 21, 2026
Merged

Related-books section: responsive columns, no more enormous covers on large screens#278
fabiodalez-dev merged 3 commits into
mainfrom
fix/related-books-responsive-columns

Conversation

@fabiodalez-dev

Copy link
Copy Markdown
Owner

The "Potrebbero interessarti" section on the frontend book page looked terrible on large screens — the book covers were enormous.

Cause

It used Bootstrap col-lg-4 col-md-6 with no cap beyond lg, inside the theme's ultra-wide .container (~2355px on a 2560px monitor). With at most 3 related books that meant 3 columns of ~440px+, and since each cover is padding-top: 140% of the card width, the covers ballooned to ~615px tall on large displays.

Fix

  • Cap the card (.related-book-card) to a book-sane 280px (matching the catalog card size), centred in its column — the cover can no longer balloon.
  • Responsive column count by screen size: col-12 col-sm-6 col-lg-41 / 2 / 3 columns as the screen grows, with justify-content-center.
  • Group the cards: constrain the row (.related-books-row, max-width 960px, centred) so the three cards sit together in the middle instead of spreading across the wide container.

Verified live

At 375 / 768 / 1024 / 1440 / 1920 / 2560px: cards stay book-sized (280px on desktop, ≤400px on mobile via the existing mobile rule), columns scale 1→2→3, covers no longer enormous. PHPStan clean.

Note: the section shows up to 3 related books (getRelatedBooks limit). If you'd like more columns to be meaningful on very wide screens, that would mean raising that limit — happy to do it if you want.

…olumns)

The "Potrebbero interessarti" section on the frontend book page used Bootstrap
`col-lg-4 col-md-6` with no cap beyond `lg`, inside the theme's ultra-wide
`.container` (~2355px on a 2560px screen). With max 3 related books that meant
3 columns of ~440px+, and since each cover is 140% of the card width, the
covers ballooned (~615px tall) on large monitors.

- Cap `.related-book-card` to a book-sane 280px (matching the catalog card
  size), centred in its column, so the cover never balloons.
- Responsive column count by screen size: `col-12 col-sm-6 col-lg-4`
  (1 / 2 / 3 columns), with `justify-content-center`.
- Constrain the row (`.related-books-row`, max-width 960px, centred) so the
  three cards group together in the middle instead of spreading across the
  wide container.

Verified live at 375 / 768 / 1024 / 1440 / 1920 / 2560px: cards stay
book-sized (280px on desktop, ≤400px on mobile), columns scale 1→2→3, covers
no longer enormous.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@fabiodalez-dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e430e625-4cfe-41e1-92ca-3113540b6981

📥 Commits

Reviewing files that changed from the base of the PR and between 10adad2 and a32bf11.

📒 Files selected for processing (2)
  • app/Views/frontend/book-detail.php
  • tests/related-books-responsive-278.spec.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/related-books-responsive-columns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fabiodalez-dev

Copy link
Copy Markdown
Owner Author

🔎 Adams Review — PR #278 (related-books responsive)

Adversarial pass (structural + UX). The fix does solve the reported problem — covers no longer balloon on large screens (verified 375→2560px). Three minor, non-blocking polish items surfaced; none regress the fix.

ℹ️ UX — size inversion at the 768px breakpoint (confirmed by measurement)

The pre-existing @media (max-width:768px) rule caps the card at 400px, but the new base rule caps it at 280px. So the card is allowed to be wider on mobile than on desktop: measured 760px → 310px card, 780px → 280px card. Widening the window just past 768px visibly shrinks the card ~30px instead of growing it. Small, but it reads as a glitch to a sharp eye. Aligning the two caps (e.g. drop the 400px mobile rule, or scale both from one scheme) removes it. book-detail.php:1499 vs :1622-1627.

ℹ️ UX — "matches the catalog card size (~280px)" is imprecise

The catalog grid uses repeat(auto-fill, minmax(280px, 1fr)) — there 280px is a floor that stretches to fill the track, so real catalog cards are usually wider than 280px. This PR's hard max-width:280px makes the related cards read narrower than catalog cards on the same site. Cosmetic (different pages, rarely side-by-side), but the code comment overstates the parity. book-detail.php:1499.

ℹ️ Structural — !important margins fight Bootstrap's row gutters

.related-books-row { margin-left/right:auto !important } sits on the same element as Bootstrap's .row, overriding its negative gutter margins (calc(-.5 * var(--bs-gutter-x))), so the outer columns gain a ~0.75rem inset within the 960px cap. The measured result still looks right (3× 280px cards, 40px gaps, centred), so it's harmless — but the clean approach is a wrapper div carrying the max-width/centering, leaving .row untouched. book-detail.php:1480-1484.

✅ Clean

  • Bundled CSS is Bootstrap 5.3.8; col-12/col-sm-6/col-lg-4/justify-content-center all exist. Base 280px cap and the mobile 400px rule compose without a specificity fight (media query wins ≤768px). .related-books-row is used only here, on the correct element; section guarded by if (!empty($related_books)).
  • Responsive column count 1→2→3 verified live at 375/768/1024/1440/1920/2560px.

Verdict: ship-ready — the covers-are-enormous bug is fixed. The three items above are optional refinements; the 768px inversion is the one most worth a follow-up. Want me to apply the wrapper-div + single-cap cleanup?

Lenses: L2 structural, L5 UX. Findings verified against live rendering, not just flagged.

…r override

Adams-review follow-ups on the related-books responsive fix:

- 768px inversion: a pre-existing @media(max-width:768px) rule capped the card
  at 400px while the new base cap was 280px, so the card was allowed wider on
  mobile than on desktop — widening the window past 768px visibly *shrank* it
  (measured 760px→310px, 780px→280px). Removed the mobile override; the uniform
  280px cap now keeps the transition monotonic (760px→280, 780px→280).

- !important gutter override: `.related-books-row` set margin:auto !important on
  the same element as Bootstrap's .row, clobbering its negative gutter margins.
  Replaced with a plain `.related-books-wrap` div carrying the 960px cap +
  centering, leaving .row untouched — no !important needed.

- Corrected the card comment: 280px is the catalog grid's minmax() *floor*
  (which stretches), used here as a hard cap; the "matches catalog size" claim
  overstated the parity.

Verified live at 375/600/760/780/1024/1920/2560px: card width monotonic
(280px cap, column-constrained below), wrap centred at 960px on wide screens,
no inversion. DOM balanced.
… 768px inversion, 1→2→3 columns, centred wrap)
@fabiodalez-dev
fabiodalez-dev merged commit 5c5e444 into main Jul 21, 2026
5 of 6 checks passed
@fabiodalez-dev
fabiodalez-dev deleted the fix/related-books-responsive-columns branch July 21, 2026 21:35
fabiodalez-dev added a commit that referenced this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant