Skip to content

Commit 55ab7c4

Browse files
authored
Merge pull request #1287 from makeabilitylab/1282-mobile-navbar-and-logo-fixes
Fix mobile navbar sizing/wrap and logo overflow (#1281, #1282, #1286)
2 parents 6b41259 + b518cd6 commit 55ab7c4

3 files changed

Lines changed: 116 additions & 9 deletions

File tree

website/static/website/css/top-navbar.css

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,82 @@
219219
}
220220

221221
/* ==========================================================================
222-
Responsive Styles - Mobile (Collapsed Menu)
223-
224-
Bootstrap 3 navbar collapses at 768px by default, but experimentally
225-
this occurs at 789px for this navbar configuration.
226-
222+
Responsive Styles - Mobile / Tablet (Collapsed Menu)
223+
224+
The collapsed (hamburger) menu is used up to 991px. The brand + 8 menu items
225+
don't fit on one horizontal line until ~970px, so collapsing at Bootstrap's
226+
default 768px left the menu wrapping onto a second line between ~768–991px
227+
(issue #1286). The breakpoint override further below re-asserts the collapsed
228+
layout across 768–991px; these rules style that collapsed menu.
229+
227230
Key mobile improvements:
228231
- Minimum 44px touch targets (Apple HIG guideline)
229232
- Larger font size for readability
230233
- Icons visible for quick recognition
231234
- Clear visual separation between items
232235
========================================================================== */
233236

234-
@media only screen and (max-width: 789px) {
237+
@media only screen and (max-width: 991px) {
238+
/*
239+
* Taller navbar on mobile. The default 40px height left the hamburger button
240+
* small and hard to tap, and felt disproportionately short next to the
241+
* enlarged collapsed menu items. See issue #1282.
242+
*/
243+
.navbar-custom {
244+
height: 56px;
245+
padding-top: 0;
246+
}
247+
248+
/* Vertically center the brand (logo + text) within the taller navbar. The
249+
float (set by Bootstrap) still positions it on the left. */
250+
.navbar-custom .navbar-brand {
251+
display: flex;
252+
align-items: center;
253+
height: 56px;
254+
}
255+
256+
/* Scale the logo mark up to suit the taller navbar (the 20px default looked
257+
undersized and top-light in a 56px bar). Width stays auto to keep ratio. */
258+
.navbar-custom .navbar-brand > img {
259+
height: 32px;
260+
}
261+
262+
/* Logo-only brand on mobile. The wordmark looked tiny and cramped next to the
263+
enlarged logo, so we hide it here. The brand link keeps an accessible name
264+
via the aria-label on the <a> in base.html. See issue #1282 discussion. */
265+
.navbar-custom .makeabilitylab-text {
266+
display: none;
267+
}
268+
269+
/* Larger hamburger button: ≥44px touch target (Apple HIG) with a bigger icon,
270+
vertically centered within the navbar. Float keeps it on the right. */
271+
.navbar-custom .navbar-toggle {
272+
display: flex;
273+
align-items: center;
274+
justify-content: center;
275+
height: 56px;
276+
min-width: 48px;
277+
padding: 0 14px;
278+
margin: 0;
279+
}
280+
281+
.navbar-custom .navbar-toggle .fa-bars {
282+
font-size: 26px;
283+
}
284+
235285
/* Collapsed menu background */
236286
.navbar-collapse ul {
237287
background-color: var(--navbar-bg-color);
238288
}
239289

290+
/* Make the dropdown sit flush against the navbar. Bootstrap's default 7.5px
291+
top margin on .navbar-nav left a gap where the page showed through between
292+
the navbar and the menu panel. See issue #1282 discussion. */
293+
.navbar-custom .navbar-nav {
294+
margin-top: 0;
295+
margin-bottom: 0;
296+
}
297+
240298
/*
241299
* Mobile navigation links
242300
* Touch target sizing follows Apple HIG (44pt minimum) and
@@ -257,6 +315,13 @@
257315
font-size: 18px;
258316
}
259317

318+
/* Stack menu items vertically. Bootstrap floats them left ≥768px; the
319+
breakpoint override below keeps the menu collapsed up to 991px, so the
320+
items must not float there. (No-op below 768px.) */
321+
.navbar-custom .navbar-nav > li {
322+
float: none;
323+
}
324+
260325
/* Add subtle separator between menu items */
261326
.navbar-custom .navbar-nav > li {
262327
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
@@ -286,11 +351,39 @@
286351
}
287352
}
288353

354+
/* ==========================================================================
355+
Raise the navbar collapse breakpoint to 992px
356+
357+
Bootstrap 3.3.6 switches the navbar to its horizontal layout at 768px, but
358+
the brand + 8 menu items don't fit on one line until ~970px — so between
359+
768–991px the menu wrapped onto a second line (issue #1286). These rules
360+
re-assert Bootstrap's collapsed (hamburger) layout across 768–991px, so the
361+
horizontal menu only appears once it actually fits (≥992px). The collapsed
362+
styling itself comes from the max-width: 991px block above.
363+
========================================================================== */
364+
365+
@media (min-width: 768px) and (max-width: 991px) {
366+
/* Don't float the header into a horizontal row */
367+
.navbar-custom .navbar-header {
368+
float: none;
369+
}
370+
371+
/* Keep the dropdown hidden until toggled (Bootstrap forces it open ≥768px) */
372+
.navbar-custom .navbar-collapse.collapse {
373+
display: none !important;
374+
}
375+
376+
.navbar-custom .navbar-collapse.collapse.in {
377+
display: block !important;
378+
overflow-y: auto !important;
379+
}
380+
}
381+
289382
/* ==========================================================================
290383
Light Theme Mobile Adjustments
291384
========================================================================== */
292385

293-
@media only screen and (max-width: 789px) {
386+
@media only screen and (max-width: 991px) {
294387
.light-navbar-theme .navbar-nav > li {
295388
border-bottom-color: rgba(0, 0, 0, 0.1);
296389
}

website/static/website/js/makelab-logo.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636

3737
import {
38+
MakeabilityLabLogo,
3839
MakeabilityLabLogoMorpher,
3940
TriangleArt,
4041
} from 'https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.logo.js';
@@ -45,6 +46,9 @@ import {
4546

4647
const MAX_HEIGHT = 600;
4748
const TRIANGLE_SIZE = 70;
49+
// Keep the assembled logo within this fraction of the canvas width so it never
50+
// runs off-screen on narrow (mobile) viewports. See issue #1281.
51+
const LOGO_WIDTH_FRACTION = 0.9;
4852
const SCROLL_DISTANCE = 300;
4953
const DPR = window.devicePixelRatio || 1;
5054
const BG_FILL_COLOR = "rgba(255, 255, 255, 1)"; // Solid white for website clean look
@@ -113,6 +117,15 @@ async function initOrResize() {
113117
morpher = new MakeabilityLabLogoMorpher(0, 0, TRIANGLE_SIZE, START_FILL_COLOR);
114118
}
115119

120+
// Size the assembled logo so it always fits within the canvas width. On wide
121+
// (desktop) canvases this caps at the natural size (TRIANGLE_SIZE per cell);
122+
// on narrow (mobile) canvases it shrinks the logo so the final, unexploded
123+
// state stays fully on-screen. Must run before reset()/resetFromArt() below,
124+
// which read the logo's cell size to compute the morph end state. See #1281.
125+
const naturalLogoWidth = MakeabilityLabLogo.numCols * TRIANGLE_SIZE;
126+
const maxLogoWidth = logicalWidth * LOGO_WIDTH_FRACTION;
127+
morpher.setLogoSize(Math.min(naturalLogoWidth, maxLogoWidth));
128+
116129
// Ensure the destination logo is centered in the final state
117130
morpher.centerLogo(logicalWidth, logicalHeight);
118131

website/templates/website/base.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@
162162
<span class="sr-only">Menu</span>
163163
</button>
164164

165-
<a class="navbar-brand page-scroll" href="{% url 'website:index' %}">
166-
<img src="{% static 'website/img/logos/makelab_logo_white_no_text_100x67.png' %}"
165+
<a class="navbar-brand page-scroll" href="{% url 'website:index' %}"
166+
aria-label="Makeability Lab home">
167+
<img src="{% static 'website/img/logos/makelab_logo_white_no_text_100x67.png' %}"
167168
alt=""
168169
height="20"
169170
aria-hidden="true">

0 commit comments

Comments
 (0)