The private calendar rendered as six hundred pixels of nothing on a phone.
The cause was two adjacent rules in board.css with opposite outcomes:
.cal, .cal tbody, .cal tr, .cal td { display: block } /* (0,1,1) */
.cal__pad { display: none } /* (0,1,0) */
.cal__day:not(:has(.cal__event)) { display: none } /* (0,2,0) */
`.cal td` outranks `.cal__pad`, so every cell belonging to a neighbouring
month stayed on screen as a 92px empty box; `.cal__day:not(:has(…))`
outranks `.cal td`, so every real day disappeared. A month with no events
drew four blank boxes and nothing else, with correct HTML throughout —
which is why reading the file looked right and no test could see it.
Both calendars are now a column of every day of the month below 640px,
with the weekday beside the number (the column header is hidden there),
the days carrying something standing out, and a line saying so when the
month is empty. The public agenda gets the same shape deliberately: the
private calendar lists the public events, and a member moves between the
two. Every rule that decides `display` now names its cell's own class.
Measured rather than reasoned about, in headless Chromium at 320 and 390
across all 22 members-area screens and the public site in three languages:
- padding cells 0px tall, 31 of 31 days drawn, no horizontal overflow
- the ☰ ran off the right edge of a 320px Portuguese home page, because
«Comunidade» is three letters longer than «Comunidad»; the bar now
gives way at 360px
- the navigation links were 37x17, the calendar's + was 7x15, the footer
links 16px tall. A `pointer: coarse` block in each stylesheet raises
them to 44, padding only, so the desktop is untouched. Links inside a
sentence are left alone, as WCAG exempts them.
Registro de actividad and Contenido stop being a sideways-scrolling table
on a phone and stack one card per row, the two columns that do not
describe themselves labelled from `data-label`.
Guards: three stylesheet tests that compute specificity and run the
cascade for a padding cell, a day cell and the weekday label, in both
stylesheets — each verified by putting the shipped rules back. Plus three
request-level tests: an empty month says so and still draws its 31 days,
a month with events does not claim to be empty, and every day carries the
right weekday.
Members area only to deploy — no migration, no schema change — except the
agenda and the stylesheet, which reach the site through the pipeline.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
112 lines
5.1 KiB
HTML
112 lines
5.1 KiB
HTML
{{/* The public agenda: one grid per month, all of them built here.
|
|
|
|
Every month between the first event and the last is rendered, plus the
|
|
current one, and assets/js/agenda.js shows one at a time. Two things fall
|
|
out of building them all rather than fetching a month at a time:
|
|
|
|
* **With JavaScript off, every month is on the page**, stacked, each under
|
|
its own heading. Nothing is hidden from a reader who has no script, and
|
|
nothing is hidden from a crawler either.
|
|
* Moving between months is instant and makes no request.
|
|
|
|
The weekday arithmetic is the awkward part, because Hugo exposes no
|
|
AddDate: the length of a month comes from a table plus a leap-year check,
|
|
and the weekday of the first falls out of formatting that date. It looks
|
|
like something simpler was missed, and it is not. */}}
|
|
{{ define "main" }}
|
|
{{ $lang := .Site.Language.Lang }}
|
|
{{ $events := where (where .Site.RegularPages "Section" "post") "Params.event_date" "!=" nil }}
|
|
|
|
{{/* The span to render: from the earliest event to the latest, and always
|
|
including the month the site was built in, so an empty agenda still shows
|
|
the reader where they are. */}}
|
|
{{ $months := slice }}
|
|
{{ range $events }}{{ $months = $months | append (substr .Params.event_date 0 7) }}{{ end }}
|
|
{{ $months = $months | append (now.Format "2006-01") }}
|
|
{{ $months = sort (uniq $months) }}
|
|
{{ $from := index $months 0 }}
|
|
{{ $to := index $months (sub (len $months) 1) }}
|
|
|
|
{{/* Expanded so a month with nothing in it can still be visited. */}}
|
|
{{ $span := slice }}
|
|
{{ range $y := seq (int (substr $from 0 4)) (int (substr $to 0 4)) }}
|
|
{{ range $m := seq 1 12 }}
|
|
{{ $key := printf "%04d-%02d" $y $m }}
|
|
{{ if and (ge $key $from) (le $key $to) }}{{ $span = $span | append $key }}{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ $script := resources.Get "js/agenda.js" | minify | fingerprint }}
|
|
<script src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}" defer></script>
|
|
|
|
<main class="feed feed--agenda">
|
|
<h1 class="feed__title">{{ .Title }}</h1>
|
|
{{ with .Content }}<div class="agenda__intro">{{ . }}</div>{{ end }}
|
|
|
|
<nav class="agenda__bar" aria-label="{{ partial "t.html" (dict "key" "agenda" "lang" $lang) }}">
|
|
<button class="agenda__move" type="button" data-agenda-move="-1"
|
|
aria-label="{{ partial "t.html" (dict "key" "previous" "lang" $lang) }}">←</button>
|
|
<strong class="agenda__current" data-agenda-label></strong>
|
|
<button class="agenda__move" type="button" data-agenda-move="1"
|
|
aria-label="{{ partial "t.html" (dict "key" "next" "lang" $lang) }}">→</button>
|
|
</nav>
|
|
|
|
{{ range $key := $span }}
|
|
{{ $year := int (substr $key 0 4) }}
|
|
{{ $month := int (substr $key 5 2) }}
|
|
{{ $firstDay := printf "%s-01" $key }}
|
|
|
|
{{/* Days in the month: a table, with February decided by the leap rule —
|
|
every four years, not every hundred, except every four hundred. */}}
|
|
{{ $lengths := slice 31 28 31 30 31 30 31 31 30 31 30 31 }}
|
|
{{ $days := index $lengths (sub $month 1) }}
|
|
{{ if eq $month 2 }}
|
|
{{ if or (and (eq (mod $year 4) 0) (ne (mod $year 100) 0)) (eq (mod $year 400) 0) }}
|
|
{{ $days = 29 }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{/* Monday first, as in Austria and most of Latin America. Go names the
|
|
weekday; this turns the name into a column offset. */}}
|
|
{{ $offsets := dict "Mon" 0 "Tue" 1 "Wed" 2 "Thu" 3 "Fri" 4 "Sat" 5 "Sun" 6 }}
|
|
{{ $lead := index $offsets (($firstDay | time.AsTime).Format "Mon") }}
|
|
|
|
<section class="agenda__month" data-month="{{ $key }}"
|
|
data-label="{{ partial "month-name.html" (dict "month" $month "lang" $lang) }} {{ $year }}">
|
|
<h2 class="agenda__heading">{{ partial "month-name.html" (dict "month" $month "lang" $lang) }} {{ $year }}</h2>
|
|
|
|
<ol class="agenda__grid">
|
|
{{ if gt $lead 0 }}{{ range seq $lead }}<li class="agenda__pad" aria-hidden="true"></li>{{ end }}{{ end }}
|
|
{{ range $day := seq 1 $days }}
|
|
{{ $date := printf "%s-%02d" $key $day }}
|
|
{{ $onThisDay := where $events "Params.event_date" $date }}
|
|
{{/* The column a day falls in is its weekday, Monday first — the
|
|
same arithmetic the padding above is made of. On a phone the
|
|
grid becomes one day per row, where a column position says
|
|
nothing and the name has to be written out. */}}
|
|
{{ $weekday := mod (add (sub $day 1) $lead) 7 }}
|
|
<li class="agenda__day {{ if $onThisDay }}agenda__day--busy{{ end }}">
|
|
<span class="agenda__date">
|
|
<span class="agenda__weekday">{{ partial "weekday-name.html" (dict "weekday" $weekday "lang" $lang) }}</span>
|
|
<span class="agenda__number">{{ $day }}</span>
|
|
</span>
|
|
<span class="agenda__events">
|
|
{{ range $onThisDay }}
|
|
<a class="agenda__event" href="{{ .RelPermalink }}">
|
|
{{ with .Params.event_time }}<time>{{ . }}</time> {{ end }}{{ .Title }}
|
|
</a>
|
|
{{ end }}
|
|
</span>
|
|
</li>
|
|
{{ end }}
|
|
</ol>
|
|
|
|
{{ $inMonth := where (where $events "Params.event_date" "ge" (printf "%s-01" $key)) "Params.event_date" "le" (printf "%s-31" $key) }}
|
|
{{ if not $inMonth }}
|
|
<p class="muted agenda__empty">{{ partial "t.html" (dict "key" "noevents" "lang" $lang) }}</p>
|
|
{{ end }}
|
|
</section>
|
|
{{ end }}
|
|
</main>
|
|
{{ end }}
|