Skip to content

Commit 0bf970b

Browse files
committed
Add prev/next pagination and tighten mobile UX
## Pagination `partials/pagination.hbs` used to be gated on an opt-in `:pagination:` page attribute that nothing set, so prev/next never rendered. Rewrite it as a plain `page.previous`/`page.next` check so every page that is listed in `nav.adoc` now gets a Prev/Next block at the bottom. Antora skips same-page anchor entries automatically, so a page like `phoenix/index.adoc` advances to LiveView rather than to one of its own sub-sections. The new markup is a two-card `<nav class="pagination">` — each card has a small uppercase "Previous" / "Next" overline and the destination page's title, so readers see *where* they're going before tapping. On mobile the two cards stack (single-column grid); on `sm+` they sit side by side. Cards have a subtle border, a 4rem minimum height, and a tactile hover state so they read as links rather than inline text. ## Mobile UX iPhone-width audit surfaced four real problems; fixed each: - **Page overflowed horizontally.** AsciiDoc emits a `<div class="title">` above every listing block containing the file path (e.g. `lib/demo_web/controllers/product_html/show.html.heex`). In mono + 0.15em tracking that string is ~430px wide and would not wrap, pushing the whole document past the viewport. Added `overflow-wrap: anywhere` to `.title` so it breaks on mobile. - **Nav overlay had no escape.** `.nav-container.is-active` covers the whole viewport at z-20, which hid the hamburger toggle underneath it with no way to close. The toggle is now promoted to `position: fixed; z-index: 30` when `is-active` and switches to an X icon, so it always floats in the top-right corner of the overlay. - **Hamburger tap target was 32×32 with a hard-coded dark icon.** Upped the button to 44×44 (Apple HIG), replaced the `<img src>` with a CSS mask so the icon inherits `currentColor` and stays visible in both light and dark mode, and added `aria-label`/`aria-expanded` to the partial. - **Padding and type felt cramped.** Trimmed body gutters from `px-6` to `px-4` on mobile (keeps `sm:px-8` at 640px+), dropped the 17px pad on the content wrapper, shrunk code blocks from 14px @ p-5 to 13px @ p-4 on mobile (restored at sm+), and narrowed the admonition icon column from `w-28` to `w-20` on mobile. Wide tables now scroll horizontally via a `.tableblock { overflow-x: auto }` wrapper instead of shoving the layout sideways. Verified at 390×844 by loading each page into a 390px-wide iframe: no horizontal scroll, pagination stacks, overlay opens and closes cleanly.
1 parent 9cdf8d9 commit 0bf970b

4 files changed

Lines changed: 82 additions & 27 deletions

File tree

ui-bundle/src/css/site.css

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ body.article {
7777
}
7878

7979
body.article > .body {
80-
@apply mx-auto flex w-full max-w-[88rem] flex-1 gap-8 px-6 sm:px-8 lg:gap-12 lg:px-10;
80+
@apply mx-auto flex w-full max-w-[88rem] flex-1 gap-8 px-4 sm:px-8 lg:gap-12 lg:px-10;
8181
}
8282

8383
/* ---------------------------------------------------------------------------
@@ -170,10 +170,42 @@ body.article > .body {
170170
}
171171

172172
.nav-toggle {
173-
@apply h-8 w-8 shrink-0 cursor-pointer border-0 bg-neutral-100 bg-center bg-no-repeat lg:hidden dark:bg-neutral-900;
174-
background-image: url("../img/menu.svg");
175-
background-size: 1rem;
176-
border-radius: 4px;
173+
@apply relative h-11 w-11 shrink-0 cursor-pointer rounded border-0 bg-neutral-100 text-neutral-900 lg:hidden dark:bg-neutral-900 dark:text-neutral-100;
174+
}
175+
176+
.nav-toggle::before {
177+
content: "";
178+
position: absolute;
179+
inset: 0;
180+
margin: auto;
181+
width: 1.125rem;
182+
height: 1.125rem;
183+
background-color: currentColor;
184+
mask: url("../img/menu.svg") center / contain no-repeat;
185+
-webkit-mask: url("../img/menu.svg") center / contain no-repeat;
186+
}
187+
188+
/* When the nav overlay is open on mobile, the toggle floats above the
189+
overlay so the user can always reach it to close. */
190+
.nav-toggle.is-active {
191+
position: fixed;
192+
top: 0.75rem;
193+
right: 0.75rem;
194+
z-index: 30;
195+
background-color: #fafafa;
196+
box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08);
197+
}
198+
199+
.nav-toggle.is-active::before {
200+
mask: url("../img/close.svg") center / contain no-repeat;
201+
-webkit-mask: url("../img/close.svg") center / contain no-repeat;
202+
}
203+
204+
@media (prefers-color-scheme: dark) {
205+
.nav-toggle.is-active {
206+
background-color: #131313;
207+
box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08);
208+
}
177209
}
178210

179211
/* ---------------------------------------------------------------------------
@@ -185,7 +217,7 @@ main.article {
185217
}
186218

187219
main.article > .content {
188-
@apply flex min-w-0 flex-1 flex-col gap-10 px-4 pt-8 sm:px-6 lg:flex-row lg:items-start lg:px-2;
220+
@apply flex min-w-0 flex-1 flex-col gap-10 px-0 pt-6 sm:px-6 sm:pt-8 lg:flex-row lg:items-start lg:px-2;
189221
}
190222

191223
.doc {
@@ -265,6 +297,17 @@ main.article > .content {
265297
@apply my-6;
266298
}
267299

300+
/* AsciiDoc wraps every table in `<div class="tableblock">`; let wide
301+
tables scroll horizontally instead of breaking the page layout on
302+
narrow screens. */
303+
.doc .tableblock {
304+
@apply -mx-4 overflow-x-auto px-4 sm:mx-0 sm:px-0;
305+
}
306+
307+
.doc .tableblock > table {
308+
@apply min-w-full;
309+
}
310+
268311
.doc th {
269312
@apply border-b-2 border-neutral-300 px-3 py-2 text-left font-mono text-[11px] tracking-[0.15em] text-neutral-600 uppercase dark:border-neutral-700 dark:text-neutral-400;
270313
font-weight: 500;
@@ -286,7 +329,7 @@ main.article > .content {
286329
}
287330

288331
.doc pre {
289-
@apply my-6 overflow-x-auto rounded-sm bg-neutral-900 p-5 font-mono text-[14px] leading-[1.6] text-neutral-100 ring-1 ring-neutral-200 dark:bg-[#131313] dark:ring-neutral-800;
332+
@apply my-6 overflow-x-auto rounded-sm bg-neutral-900 p-4 font-mono text-[13px] leading-[1.6] text-neutral-100 ring-1 ring-neutral-200 sm:p-5 sm:text-[14px] dark:bg-[#131313] dark:ring-neutral-800;
290333
}
291334

292335
.doc pre code {
@@ -302,6 +345,7 @@ main.article > .content {
302345
.doc .imageblock > .title,
303346
.doc .tableblock > caption {
304347
@apply mb-2 font-mono text-[11px] tracking-[0.15em] text-neutral-500 uppercase dark:text-neutral-400;
348+
overflow-wrap: anywhere;
305349
}
306350

307351
.doc .source-toolbox {
@@ -347,7 +391,7 @@ main.article > .content {
347391
}
348392

349393
.doc .admonitionblock .icon {
350-
@apply w-28 pt-5 pl-5 align-top;
394+
@apply w-20 pt-5 pl-4 align-top sm:w-28 sm:pl-5;
351395
}
352396

353397
.doc .admonitionblock .icon i {
@@ -374,7 +418,7 @@ main.article > .content {
374418
.doc .admonitionblock.important .icon i::before { @apply text-rose-600 dark:text-rose-400; }
375419

376420
.doc .admonitionblock td.content {
377-
@apply pt-4 pr-5 pb-4 pl-0;
421+
@apply pt-4 pr-4 pb-4 pl-0 sm:pr-5;
378422
}
379423

380424
.doc .admonitionblock td.content > .title {
@@ -451,26 +495,36 @@ main.article > .content {
451495

452496
/* ---------------------------------------------------------------------------
453497
Pagination (prev/next at the bottom of each page).
498+
499+
Mobile-first: two stacked full-width cards. From sm up they sit
500+
side-by-side. Each card has a muted overline ("Previous"/"Next") and
501+
the page title below it, so the reader sees *where* each link goes
502+
before tapping.
454503
--------------------------------------------------------------------------- */
455504

456505
.pagination {
457-
@apply mx-auto mt-14 flex max-w-[78ch] justify-between gap-4 border-t border-neutral-200 pt-6 font-mono text-[12px] tracking-[0.15em] uppercase dark:border-neutral-800;
506+
@apply mt-14 grid gap-3 border-t border-neutral-200 pt-6 sm:grid-cols-2 dark:border-neutral-800;
458507
}
459508

460-
.pagination .prev::before {
461-
content: "← ";
509+
.pagination a {
510+
@apply flex min-h-[4rem] flex-col justify-center rounded-sm border border-neutral-200 px-4 py-3 text-neutral-700 no-underline transition hover:border-[#65a30d] hover:text-[#65a30d] dark:border-neutral-800 dark:text-neutral-300 dark:hover:border-[#c8f55a] dark:hover:text-[#c8f55a];
462511
}
463512

464513
.pagination .next {
465-
@apply ml-auto;
514+
@apply sm:col-start-2 sm:text-right;
466515
}
467516

468-
.pagination .next::after {
469-
content: " →";
517+
/* First page has no previous — push the next link into its column. */
518+
.pagination:not(:has(.prev)) .next {
519+
@apply col-start-1 sm:col-start-2;
470520
}
471521

472-
.pagination a {
473-
@apply text-neutral-600 no-underline hover:text-[#65a30d] dark:text-neutral-400 dark:hover:text-[#c8f55a];
522+
.pagination .pagination-label {
523+
@apply font-mono text-[11px] tracking-[0.2em] text-neutral-500 uppercase dark:text-neutral-400;
524+
}
525+
526+
.pagination .pagination-title {
527+
@apply mt-1 font-serif text-[17px] leading-snug;
474528
}
475529

476530
/* ---------------------------------------------------------------------------

ui-bundle/src/img/close.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<button class="nav-toggle"></button>
1+
<button class="nav-toggle" type="button" aria-label="Toggle navigation" aria-expanded="false"></button>
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{{#unless (eq page.attributes.pagination undefined)}}
21
{{#if (or page.previous page.next)}}
3-
<nav class="pagination">
4-
{{#if (ne page.attributes.pagination 'next')}}
2+
<nav class="pagination" aria-label="Page navigation">
53
{{#with page.previous}}
6-
<span class="prev"><a href="{{{relativize ./url}}}">{{{./content}}}</a></span>
4+
<a class="prev" href="{{{relativize ./url}}}" rel="prev">
5+
<span class="pagination-label">← Previous</span>
6+
<span class="pagination-title">{{{./content}}}</span>
7+
</a>
78
{{/with}}
8-
{{/if}}
9-
{{#if (ne page.attributes.pagination 'prev')}}
109
{{#with page.next}}
11-
<span class="next"><a href="{{{relativize ./url}}}">{{{./content}}}</a></span>
10+
<a class="next" href="{{{relativize ./url}}}" rel="next">
11+
<span class="pagination-label">Next →</span>
12+
<span class="pagination-title">{{{./content}}}</span>
13+
</a>
1214
{{/with}}
13-
{{/if}}
1415
</nav>
1516
{{/if}}
16-
{{/unless}}

0 commit comments

Comments
 (0)