vienalatina/apps/board/templates/calendar.html
Claude 5cc1630d6a
The calendar is a month again, at every width
A phone showed a column of thirty-one dates. That was my answer to a
seven-column grid being unreadable at 390px, and it stopped being a
calendar: you could not see that the 24th was a Saturday without
counting, and a month you cannot see the shape of is a list.

It is seven columns now at 320, 390 and 1280, measured rather than
reasoned about. Below 640px the cells are about 50px, the titles come
out of them, and a day with something in it shows a dot per event and
links to that day's block in a list under the grid. An anchor, so it
needs no script and cannot fail under the CSP.

It is also an <ol> on a grid rather than a <table>, and that is the
actual fix. A table brings tbody/tr/td with it, so every phone rule had
to name an element to undo them — and `.cal td` at (0,1,1) outranks
`.cal__pad` at (0,1,0), which is how an empty month came to draw four
blank boxes and nothing else. A grid has nothing to undo, which is why
the public agenda has never had the bug. The three CSS guards are
retargeted accordingly, and the padding-cell one is inverted: a pad is
no longer hidden, it is what puts the 1st under its own weekday.

Two more from the same screenshots:

The month arrows. `← Anterior / noviembre 2026 / Siguiente →` was three
runs of text in a flex row that could not wrap, so at 320px the next
month was simply unreachable. Two 44px circles with the label between
them, wrapping, both inside the viewport at every width.

Links leaving their card. `profiles.clean_links` accepts a 500-character
label and a URL is one word, so a bio ran to 519px on a 390px screen.
`.rich` — the box the text is typed into — has broken long words since
the editor shipped; the places that show what was typed did not. Both
the before and the after are measured in the browser, not asserted from
the stylesheet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-13 18:05:31 +00:00

117 lines
4.8 KiB
HTML

{% extends "base.html" %}
{% block title %}Calendario{% endblock %}
{#- One definition of what an event looks like, used in the grid cell and again
in the list underneath it. Two copies of this markup would drift the first
time one of them gained a field. -#}
{% macro event_link(item) %}
<a class="cal__event {{ 'cal__event--public' if item.public }}" href="{{ item.url }}">
{%- if item.starts_at %}<time>{{ item.starts_at }}</time> {% endif %}{{ item.title }}
{%- if item.public %} <span class="tag tag--quiet">público</span>{% endif %}
</a>
{% endmacro %}
{% block main %}
<div class="feed-head">
<h1>Calendario</h1>
{% if may_edit %}
<a class="btn" href="{{ url_for('events.new') }}">Añadir evento</a>
{% endif %}
</div>
{% if public_missing %}
<p class="flash flash--error">
No se pudo leer la agenda pública del servidor de git, así que aquí abajo
faltan los eventos del sitio. Los internos están todos.
</p>
{% endif %}
{#- Two round controls with the month between them, rather than three runs of
text in a row that cannot wrap: at 320px «← Anterior / noviembre 2026 /
Siguiente →» pushed the next-month link off the right edge, which is how a
month became impossible to leave. The same shape as the public agenda's
bar, which has never had that problem. -#}
<nav class="cal-bar" aria-label="Mes">
<a class="cal-bar__move" rel="prev" aria-label="Mes anterior"
href="{{ url_for('events.month', mes=previous) }}">←</a>
<strong class="cal-bar__label">{{ label }}</strong>
<a class="cal-bar__move" rel="next" aria-label="Mes siguiente"
href="{{ url_for('events.month', mes=next) }}">→</a>
</nav>
<p class="muted small cal-bar__today">
<a href="{{ url_for('events.month', mes=this_month) }}">Ir a este mes</a>
</p>
{# Said above the grid rather than below it, so a thumb meets it first. The
grid is drawn either way: a month that draws nothing because it holds
nothing looks broken, and looking broken is what it did. #}
{% if not by_day %}
<p class="muted cal__empty">No hay nada en {{ label }}.</p>
{% endif %}
<ol class="cal__head" aria-hidden="true">
{% for day in weekdays %}<li>{{ day }}</li>{% endfor %}
</ol>
<ol class="cal__grid">
{% for week in weeks %}
{% for day in week %}
{# calendar.monthdayscalendar pads the first and last weeks with zeroes,
which are days belonging to the neighbouring months. They keep their
space — that is what puts the 1st under its own weekday — and lose only
their ink. #}
{% if day == 0 %}
<li class="cal__pad" aria-hidden="true"></li>
{% else %}
<li class="cal__day {{ 'cal__day--today' if day == today }}">
{# `loop.index0` of this inner loop *is* the weekday, since each week is
seven cells starting on Monday, so nothing has to be computed in
Python. The column header says the weekday at every width now, so
this copy is for a screen reader: it is what makes «22» announce
itself as a Thursday. #}
<span class="cal__date">
<span class="cal__weekday">{{ weekdays[loop.index0] }}</span>
<span class="cal__number">{{ day }}</span>
</span>
{% if by_day.get(day) %}
{# A phone cell is about fifty pixels wide, which holds a number and
some dots and nothing else. The dots are the link to this day's
block in the list below, so the month stays a month and the titles
stay readable. Above 640px they are hidden and the titles sit in the
cell itself. #}
<a class="cal__dots" href="#eventos-{{ day }}"
aria-label="{{ by_day.get(day)|length }} evento{{ '' if by_day.get(day)|length == 1 else 's' }} el {{ day }}">
{% for item in by_day.get(day)[:4] %}<i class="cal__dot {{ 'cal__dot--public' if item.public }}"></i>{% endfor %}
</a>
{% endif %}
<span class="cal__events">
{% for item in by_day.get(day, []) %}{{ event_link(item) }}{% endfor %}
</span>
{% if may_edit %}
{# The day is carried into the form, so adding something to the 24th
starts with the 24th already filled in. #}
<a class="cal__add" title="Añadir evento este día"
href="{{ url_for('events.new', dia='%s-%02d'|format(month_key, day)) }}">+</a>
{% endif %}
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ol>
{# Only the days that have something in them, and only on a phone — above 640px
every title is already in its cell and this would say it all twice. #}
<section class="cal__list" aria-label="Eventos del mes">
{% for day, items in by_day|dictsort %}
<div class="cal__listday" id="eventos-{{ day }}">
<h2 class="cal__listhead">{{ day }} de {{ label }}</h2>
{% for item in items %}{{ event_link(item) }}{% endfor %}
</div>
{% endfor %}
</section>
<p class="muted small">
Los eventos marcados <span class="tag tag--quiet">público</span> están en
vienalatina.com y los ve cualquiera. Los demás sólo se ven desde aquí.
</p>
{% endblock %}