Skip to content

fix(header): fix responsive breakpoints and prevent logo/nav text collision#17

Merged
grunch merged 1 commit intoMostroP2P:mainfrom
codaMW:fix/header-nav-responsive-breakpoint
Mar 18, 2026
Merged

fix(header): fix responsive breakpoints and prevent logo/nav text collision#17
grunch merged 1 commit intoMostroP2P:mainfrom
codaMW:fix/header-nav-responsive-breakpoint

Conversation

@codaMW
Copy link
Contributor

@codaMW codaMW commented Mar 11, 2026

Summary

Fixes a responsive layout bug where the header logo text Mostro.community
collides with the first navigation item (Communities) at viewport widths
between 769px and ~1100px, producing broken text Mostro.communityCommunities.
A secondary issue caused the language switcher to collide with the logo on
narrow phones (320px–405px).

Root Cause

The header's @media (max-width: 768px) breakpoint was set too low. The
navigation contains 8 items (Communities, How it works, Get started,
FAQ, Guide, Join the Program, Mostro Protocol, Language dropdown) requiring
approximately 1100px minimum width to render cleanly. Any viewport
between 769px and ~1100px caused the flex container to crush items together.

Three compounding factors made this worse:

  1. .logo was missing flex-shrink: 0 and white-space: nowrap
  2. .header-inner was missing min-width: 0
  3. Mobile menu JS toggle read nav.style.display (inline style) which
    is always '' on first click CSS-applied display:none does not
    set the inline property causing the menu to fail on first tap

Note: Branch fix/mobile-overflow was reviewed before opening
this PR. Its only Header.astro change removes 'fr' from a JS
locale array unrelated to this CSS layout fix. This breakpoint
regression is unaddressed in any open or merged PR.

Changes: src/components/Header.astro

Change Detail
Breakpoint raised 768px1100px for mobile collapse
Two-tier compression New @media (max-width: 1280px) tightens gap/font before collapse
Logo hardened flex-shrink: 0 + white-space: nowrap added to .logo
Narrow phone fix @media (max-width: 480px) scales logo down for iPhone SE range
Flex container fix min-width: 0 added to .header-inner
JS toggle fixed data-mobile-open attribute replaces unreliable style.display check
Accessibility aria-expanded now correctly toggled on hamburger button

Viewport Coverage

Range Before After
320px–405px ⚠️ Lang button collision ✅ Clean
406px–768px ✅ Hamburger ✅ Hamburger
769px–1100px ❌ Nav overflow/collision ✅ Hamburger
1101px–1280px ❌ Nav overflow ✅ Desktop nav (compressed)
1281px+ ✅ Desktop nav ✅ Desktop nav

Testing

Tested in Chrome DevTools responsive mode at:
320 / 375 / 405 / 480 / 768 / 769 / 900 / 1025 / 1060 / 1100 / 1101 / 1280 / 1440px

All 5 locales verified: EN, ES, FR, IT, PT

Checklist

  • Single file changed (src/components/Header.astro)
  • No new dependencies introduced
  • All locales tested
  • Hamburger open/close works correctly on first and subsequent taps
  • Language dropdown works on mobile
  • aria-expanded correctly toggled
  • No existing functionality broken

Summary by CodeRabbit

  • Bug Fixes
    • Prevented header content from wrapping and ensured proper spacing on narrow screens.
    • Stabilized logo sizing and behavior across small viewports.
    • Improved navigation responsiveness with tighter spacing at medium widths and automatic collapse on small screens.
    • Fixed mobile menu toggle behavior to reliably open/close and preserve layout state.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b8c34fe9-48cb-4d71-b5fc-d78f16c71941

📥 Commits

Reviewing files that changed from the base of the PR and between 483c306 and c5fbb8c.

📒 Files selected for processing (1)
  • src/components/Header.astro
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Header.astro

Walkthrough

Header component changes tighten responsive behavior across two breakpoints (1280px, 1100px), prevent logo/content squeezing via flex adjustments, and refactor mobile menu toggle to use a data-mobile-open attribute with aria-expanded for stateful open/close handling (replacing inline style toggles).

Changes

Cohort / File(s) Summary
Header Component Responsive & Interaction
src/components/Header.astro
Layout: added min-width: 0 to .header-inner, flex-shrink: 0 and white-space: nowrap for logo; responsive adjustments for narrow viewports. Navigation: added breakpoints at 1280px and 1100px to tighten spacing and hide nav/language dropdown at ≤1100px. Mobile menu: refactored toggle to use data-mobile-open and aria-expanded for state, removed inline style-based show/hide, and preserved/cleared styles when closing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A little rabbit hops along the site,
Tuning flex and breakpoints through the night,
Mobile doors now open with a gentle flag,
Logos stay tidy — no squish, no jag,
Hooray for headers that behave just right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: fixing responsive breakpoints and preventing logo/nav text collision, which matches the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/Header.astro (1)

193-219: Comments don't match actual breakpoint values.

  • Line 194: Comment says "1025px–1200px" but the media query at line 198 is max-width: 1280px
  • Line 214: Comment says "≤1024px" but the media query at line 219 is max-width: 1100px
  • Line 216: Comment says "Raised from 768px → 1024px" but actual breakpoint is 1100px

Consider updating comments to match the actual breakpoint values to avoid confusion.

📝 Proposed comment corrections
   /*
-   * Tier 1 — Graceful compression (1025px–1200px)
+   * Tier 1 — Graceful compression (1101px–1280px)
    * The nav has 8 items. This tier tightens spacing to keep all
    * links visible on large tablets / small laptops before collapsing.
    */
   `@media` (max-width: 1280px) {
     ...
   }

   /*
-   * Tier 2 — Mobile / tablet collapse (≤1024px)
-   * Raised from 768px → 1024px. With 8 nav items the minimum
-   * comfortable desktop width is ~1100px. 1024px is the nearest
-   * industry-standard breakpoint (Tailwind lg, iPad landscape).
+   * Tier 2 — Mobile / tablet collapse (≤1100px)
+   * Raised from 768px → 1100px. With 8 nav items the minimum
+   * comfortable desktop width is ~1100px.
    */
   `@media` (max-width: 1100px) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Header.astro` around lines 193 - 219, The comments above the
media query blocks are out of sync with the actual breakpoints; update the
comment texts to match the CSS values used (e.g., change the "1025px–1200px"
description to reflect `@media` (max-width: 1280px) and change "≤1024px" and
"Raised from 768px → 1024px" to reference `@media` (max-width: 1100px) or reword
to "Raised from 768px → 1100px"); locate the blocks by the unique
selectors/media queries `@media` (max-width: 1280px) and `@media` (max-width:
1100px) in Header.astro and edit the human-readable ranges/descriptions so they
accurately describe the implemented breakpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Header.astro`:
- Around line 83-92: The standalone `.logo-icon` rule currently follows the
media query and thus overrides its `font-size` due to the same specificity; move
the `.logo-icon { font-size: 1.6rem; }` rule so it appears before the `@media
(max-width: 480px)` block (near the `.logo` rule) so the media query's
`.logo-icon { font-size: 1.35rem; }` can correctly override on small viewports,
leaving the rest of the selectors unchanged.

---

Nitpick comments:
In `@src/components/Header.astro`:
- Around line 193-219: The comments above the media query blocks are out of sync
with the actual breakpoints; update the comment texts to match the CSS values
used (e.g., change the "1025px–1200px" description to reflect `@media` (max-width:
1280px) and change "≤1024px" and "Raised from 768px → 1024px" to reference
`@media` (max-width: 1100px) or reword to "Raised from 768px → 1100px"); locate
the blocks by the unique selectors/media queries `@media` (max-width: 1280px) and
`@media` (max-width: 1100px) in Header.astro and edit the human-readable
ranges/descriptions so they accurately describe the implemented breakpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64650e7d-c81e-460b-b9cf-af915595bf1d

📥 Commits

Reviewing files that changed from the base of the PR and between fb47be9 and 483c306.

📒 Files selected for processing (1)
  • src/components/Header.astro

…lision

The header navigation was visually broken across two viewport ranges:

1. Tablets / small laptops (769px-1100px): The desktop nav was visible
   but the 8 navigation items overflowed, causing the logo text
   'Mostro.community' to collide directly with 'Communities', rendering
   as 'Mostro.communityCommunities' with no space between them.

2. Narrow phones (320px-405px): The language switcher button was being
   squeezed against the logo due to missing flex constraints.

Root causes and fixes applied to src/components/Header.astro:

- Raise mobile collapse breakpoint 768px to 1100px
- Add two-tier responsive strategy with @media (max-width: 1280px)
  graceful compression tier before full mobile collapse
- Harden .logo with flex-shrink: 0 and white-space: nowrap
- Add @media (max-width: 480px) logo scaling for narrow phones
- Add min-width: 0 to .header-inner for correct flex child behaviour
- Fix mobile menu JS toggle to use data-mobile-open attribute
- Improve aria-expanded management on hamburger button

Tested at: 320px, 375px, 405px, 480px, 768px, 769px, 900px,
           1025px, 1060px, 1100px, 1101px, 1280px, 1440px
All 5 locales verified (EN, ES, FR, IT, PT).
@codaMW codaMW force-pushed the fix/header-nav-responsive-breakpoint branch from 483c306 to c5fbb8c Compare March 11, 2026 13:48
@codaMW
Copy link
Contributor Author

codaMW commented Mar 11, 2026

Fixed in the amended commit. Moved .logo-icon and .logo-accent base
rules to before the @media (max-width: 480px) block so the cascade
correctly applies the font-size: 1.35rem override on narrow viewports.
Thank you for catching this.

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@grunch
Copy link
Member

grunch commented Mar 18, 2026

@codaMW thank you for your contribution!!

@grunch grunch merged commit af72423 into MostroP2P:main Mar 18, 2026
1 check passed
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.

2 participants