From 5cc1630d6adec0a96c403c8c28384739b5cec923 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 18:05:31 +0000 Subject: [PATCH] The calendar is a month again, at every width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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
    on a grid rather than a , 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 Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn --- apps/board/static/board.css | 181 +++++++++++++++++++++-------- apps/board/templates/calendar.html | 135 ++++++++++++--------- apps/board/tests/test_events.py | 56 +++++++-- apps/board/tests/test_templates.py | 142 +++++++++++++++------- docs/server-setup.md | 43 ++++--- 5 files changed, 387 insertions(+), 170 deletions(-) diff --git a/apps/board/static/board.css b/apps/board/static/board.css index f7fe14b..94e7853 100644 --- a/apps/board/static/board.css +++ b/apps/board/static/board.css @@ -167,6 +167,16 @@ button, input, select, textarea { font: inherit; } /* --- prose ----------------------------------------------------------- */ +/* A pasted URL is one word as far as the browser is concerned, and + `profiles.clean_links` lets that word be five hundred characters long. So + everywhere a member's own text is shown, a word wider than its box breaks + instead of leaving it. + `.rich` — the box the text is typed into — has had this since the editor + shipped. The places that *display* what `.rich` wrote did not, which is why + a bio looked right while being written and escaped the card once saved. The + guard in test_templates.py holds the two lists together. */ +.prose, .person-head__links, .panel__row { overflow-wrap: anywhere; } + .prose { line-height: 1.65; } .prose :first-child { margin-top: 0; } .prose :last-child { margin-bottom: 0; } @@ -770,45 +780,96 @@ input[type="file"] { /* --- the private calendar ---------------------------------------------- */ +/* A month, at every width. + * + * This was a
    and it is now a list on a grid, which is not a style + * preference. A table brings `tbody`, `tr` and `td` with it, so every phone + * rule had to name an element to undo them — and `.cal td` at specificity + * (0,1,1) outranks `.cal__pad` at (0,1,0). That is precisely what shipped: the + * padding cells stayed as 92px empty boxes while every real day hid, and a + * month with nothing in it drew nothing at all. A grid has no scaffolding to + * undo, so the class that names a cell is the only rule that can decide + * anything about it. The public agenda has had this shape since it was written + * and has never had the bug. */ + .cal-bar { display: flex; + /* 320px: it reflows rather than pushing the next-month control off the + right edge, which is how a month became impossible to leave. */ + flex-wrap: wrap; align-items: center; - justify-content: space-between; - gap: 1rem; + justify-content: center; + gap: 0.75rem; margin-bottom: 0.35rem; } +.cal-bar__label { min-width: 10rem; text-align: center; font-size: 1.05rem; } +.cal-bar__move { + display: inline-flex; + align-items: center; + justify-content: center; + width: 44px; + height: 44px; + border: 1px solid var(--border-light); + border-radius: 50%; + background: var(--surface); + color: var(--brand); + text-decoration: none; + font-size: 1.1rem; +} +.cal-bar__move:hover { border-color: var(--brand); } .cal-bar__today { text-align: center; margin: 0 0 1rem; } -.cal { - width: 100%; - border-collapse: collapse; - table-layout: fixed; +.cal__head, .cal__grid { + display: grid; + grid-template-columns: repeat(7, 1fr); + gap: 4px; + list-style: none; + margin: 0; + padding: 0; } -.cal th { - padding: 0.4rem; +.cal__head { + margin-bottom: 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); - text-align: left; } +.cal__grid { margin-bottom: 1rem; } .cal__day, .cal__pad { - vertical-align: top; - height: 92px; + /* The day's link is laid over the whole cell on a phone, which is what + makes the cell the tap target rather than six pixels of dot. */ + position: relative; + min-height: 92px; padding: 0.35rem; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.8rem; } +/* The leading and trailing cells are what puts the 1st under its own weekday, + so they keep their space and lose only their ink. */ .cal__pad { background: transparent; border-color: transparent; } .cal__day--today { border-color: var(--brand); background: var(--brand-softer); } +.cal__date { display: block; } .cal__number { color: var(--subtle); font-weight: 700; } -/* The column header carries the weekday at this width, so saying it again in - every one of thirty-one cells would be noise. The phone block below, where - there is no header row, is the only place it shows. */ -.cal__weekday { display: none; } +/* The header row says the weekday at every width now, so the copy inside each + cell is for a screen reader rather than for the eye — it is what makes «22» + announce itself as a Thursday. Hidden by clipping rather than by `display`, + which would take it out of the accessibility tree as well. */ +.cal__weekday { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; +} .cal__events { display: block; } +/* Both of these are the phone's half of the month, and are drawn there. */ +.cal__dots { display: none; } +.cal__list { display: none; } .cal__empty { margin: -0.5rem 0 1rem; text-align: center; } .cal__event { @@ -817,6 +878,9 @@ input[type="file"] { color: var(--brand-dark); text-decoration: none; line-height: 1.3; + /* A title holding a URL is one unbreakable word; without this it leaves the + cell sideways. */ + overflow-wrap: anywhere; } .cal__event:hover { text-decoration: underline; } .cal__event time { font-weight: 700; } @@ -836,44 +900,52 @@ input[type="file"] { .event-facts p { margin: 0 0 0.25rem; } -/* Seven columns of nothing is what a month grid is on a phone, so the month - * becomes a column of days — every day, in order, with its weekday beside it. - * - * Every rule here that decides `display` names the cell's own class, and that - * is the point rather than a style preference. The version that shipped opened - * with `.cal td { display: block }` — specificity (0,1,1) — which outranked - * `.cal__pad { display: none }` at (0,1,0), so the padding cells stayed on - * screen as 92px empty boxes; while `.cal__day:not(:has(.cal__event))` at - * (0,2,0) won, so every real day disappeared. A month with no events drew four - * blank boxes and nothing else, which is exactly what a phone showed. The two - * rules were adjacent and had opposite outcomes, which is why reading them - * looked right. */ +/* Still seven columns: a month that is not a grid is a list of dates, and a + * list of dates is what the previous answer to this width turned out to be. + * What changes is what fits in a fifty-pixel cell — the number and a dot per + * event — with the titles in a list underneath that each busy cell links to. */ @media (max-width: 640px) { - .cal, .cal tbody, .cal tr { display: block; width: auto; } - .cal thead { display: none; } - .cal td.cal__pad { display: none; } - .cal td.cal__day { + .cal__head, .cal__grid { gap: 2px; } + .cal__head { font-size: 0.6rem; letter-spacing: 0; text-align: center; } + .cal__day, .cal__pad { min-height: 54px; padding: 0.2rem; } + .cal__date { text-align: center; } + .cal__events { display: none; } + /* Laid over the whole cell, so tapping anywhere on the 24th — the number + included — goes to the 24th. A cell is about 49px wide on a 390px phone + and 39px on a 320px one, which is as large as a seventh of the screen + can be; the height makes up for it. */ + .cal__dots { + position: absolute; + inset: 0; display: flex; - align-items: baseline; - gap: 0.6rem; - height: auto; - min-height: 44px; - margin-bottom: 0.3rem; + flex-wrap: wrap; + justify-content: center; + align-content: flex-end; + gap: 2px; + padding: 0 2px 4px; } - /* A week still reads as a week. */ - .cal tr + tr { margin-top: 0.5rem; } - /* Fixed, so the dates line up down the page rather than stepping in and - out as the weekday names change length. */ - .cal__date { flex: 0 0 4.2rem; } - /* `display` and not only the colour: the base rule hides this, because up - there the column header says the weekday. Leaving it out left every row - reading as a bare number — the same shape of mistake as the pads, caught - the same way, by looking at the rendered page. */ - .cal__weekday { display: inline; color: var(--subtle); } - .cal__events { flex: 1; min-width: 0; } - /* No hover on a phone, so the + is simply there; `float` would take it out - of the flex row it is now part of. */ - .cal__add { display: inline-flex; float: none; } + .cal__dot { + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--brand); + } + .cal__dot--public { background: var(--muted); } + .cal__list { display: block; } + .cal__listday { margin-bottom: 1rem; } + .cal__listhead { + margin: 0 0 0.2rem; + font-size: 0.85rem; + text-transform: uppercase; + letter-spacing: 0.04em; + color: var(--muted); + } + /* Two classes, deliberately: `.cal__day:hover .cal__add` is (0,2,0) and a + single-class rule here would lose to it the moment a phone browser + decided a tap was a hover. There is no room for a + beside a number and + four dots anyway — adding an event on a phone goes through the button at + the top of the page, which asks for the day. */ + .cal__day .cal__add { display: none; } } /* --- Gestión → Marca ---------------------------------------------------- */ @@ -1038,7 +1110,6 @@ input[type="file"] { .actions .linkish, .feed-head .linkish, - .cal-bar .linkish, .cal-bar__today a, .pager a { display: inline-block; @@ -1070,6 +1141,11 @@ input[type="file"] { it does, so the whole thing is one target. */ .toggle { padding: 0.65rem 0; } + /* A touchscreen has no hover, so the + is simply there. This says + `display` and the 640px block above says `display: none` through + `.cal__day .cal__add` — two classes to this rule's one, so the phone + wins on specificity rather than on which block comes later in the file, + and a tablet wider than 640px keeps its + with a thumb-sized box. */ .cal__add { display: inline-flex; align-items: center; @@ -1077,6 +1153,9 @@ input[type="file"] { min-width: 44px; min-height: 44px; } + /* The day list under the month on a phone: one line of text per event is + a 21px target, and these are the links the dots exist to lead to. */ + .cal__list .cal__event { padding: 0.75rem 0; margin-top: 0; } } /* --- said out loud: a machine wrote this -------------------------------- */ diff --git a/apps/board/templates/calendar.html b/apps/board/templates/calendar.html index c072cb3..df000cf 100644 --- a/apps/board/templates/calendar.html +++ b/apps/board/templates/calendar.html @@ -1,6 +1,16 @@ {% 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) %} + + {%- if item.starts_at %} {% endif %}{{ item.title }} + {%- if item.public %} público{% endif %} + +{% endmacro %} + {% block main %}

    Calendario

    @@ -16,69 +26,88 @@

    {% 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. -#}

    Ir a este mes

    -{# Said above the grid rather than below it: on a phone the month is a column - of days, and a line under thirty-one empty rows is a line nobody reads. The - public agenda says the same thing in its own words (agenda.html). #} +{# 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 %}

    No hay nada en {{ label }}.

    {% endif %} -
    - - {% for day in weekdays %}{% endfor %} - - - {% 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. #} - {% if day == 0 %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} - -
    {{ day }}
    - {# The weekday travels with the number because on a phone the - header row is hidden — the grid is a column there, and a day - without its weekday is just an integer. `loop.index0` of this - loop *is* the weekday, since each week is seven cells - starting on Monday, so nothing has to be computed in Python. - Above 640px .cal__weekday is display:none and the column - header says it instead. #} - - {{ weekdays[loop.index0] }} - {{ day }} - - - {% for item in by_day.get(day, []) %} - - {% if item.starts_at %} {% endif %}{{ item.title }} - {% if item.public %}público{% endif %} - - {% endfor %} - - {% if may_edit %} - {# The day is carried into the form, so adding something to the - 24th starts with the 24th already filled in. #} - + - {% endif %} -
    + +
      + {% 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 %} + + {% else %} +
    1. + {# `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. #} + + {{ weekdays[loop.index0] }} + {{ day }} + + {% 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. #} + + {% for item in by_day.get(day)[:4] %}{% endfor %} + + {% endif %} + + {% for item in by_day.get(day, []) %}{{ event_link(item) }}{% endfor %} + + {% if may_edit %} + {# The day is carried into the form, so adding something to the 24th + starts with the 24th already filled in. #} + + + {% endif %} +
    2. + {% endif %} + {% endfor %} + {% endfor %} +
    + +{# 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. #} +
    + {% for day, items in by_day|dictsort %} +
    +

    {{ day }} de {{ label }}

    + {% for item in items %}{{ event_link(item) }}{% endfor %} +
    + {% endfor %} +

    Los eventos marcados público están en diff --git a/apps/board/tests/test_events.py b/apps/board/tests/test_events.py index 355b4e0..3adf23e 100644 --- a/apps/board/tests/test_events.py +++ b/apps/board/tests/test_events.py @@ -120,14 +120,13 @@ def test_february_in_a_leap_year_has_twenty_nine_days(client, superadmin_id, sig def test_a_month_with_nothing_in_it_says_so_and_still_draws_its_days( client, superadmin_id, sign_in, quiet_gitea): - """On a phone the month is a column of days rather than a grid, so an empty - month is thirty-one empty rows — which is how you see that it is empty. The - line above them says it in words, as the public agenda does. + """An empty month still draws its month, which is how you see that it is + empty. The line above it says so in words, as the public agenda does. The HTML has always been right here; what shipped was a stylesheet that hid every day and kept the cells belonging to the neighbouring months, so the - page was six hundred pixels of nothing. The rule that catches that one is in - test_templates.py, where it can be seen. + page was six hundred pixels of nothing. The rules that catch that one are in + test_templates.py, where they can be seen. """ sign_in(superadmin_id) page = client.get("/comunidad/calendario?mes=2026-12").get_data(as_text=True) @@ -147,12 +146,49 @@ def test_a_month_with_something_in_it_does_not_claim_to_be_empty( assert "Asamblea" in page -def test_every_day_carries_its_weekday_for_the_phone( +def test_a_busy_day_carries_a_dot_per_event_and_a_block_of_its_own( + client, an_event, superadmin_id, sign_in): + """What a phone shows instead of the titles, which do not fit in a cell + fifty pixels wide. + + The dots are the link to the day's block in the list underneath, so the + month stays a month and the titles stay readable. Both halves are asserted + together because either one alone is useless: dots that link nowhere, or a + block nothing points at. + """ + an_event("Asamblea", "2026-10-24") + an_event("Ensayo", "2026-10-24", starts_at="19:00") + sign_in(superadmin_id) + + page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True) + + assert 'href="#eventos-24"' in page + assert page.count('class="cal__dot ') == 2 + block = page.split('id="eventos-24"')[1] + assert "Asamblea" in block and "Ensayo" in block + # A day with nothing in it has nothing to link to. + assert 'href="#eventos-23"' not in page + + +def test_the_month_can_always_be_left(client, superadmin_id, sign_in, quiet_gitea): + """Both controls, at every width, with no text beside them to push one off + the edge. `← Anterior / noviembre 2026 / Siguiente →` was three runs of + text in a row that could not wrap, and at 320px the next month was simply + not reachable.""" + sign_in(superadmin_id) + page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True) + + assert page.count('class="cal-bar__move"') == 2 + assert 'rel="prev"' in page and 'rel="next"' in page + + +def test_every_day_carries_its_weekday_for_a_screen_reader( client, superadmin_id, sign_in, quiet_gitea): - """The column header is hidden at phone width, so without this a day is a - bare number in a list. It comes from the loop position rather than from a - date calculation, which is why this checks the pairing and not the markup: - an off-by-one would put Sunday's name on Monday's row.""" + """The header row says the weekday to anyone who can see it; this copy is + what makes «22» announce itself as a Thursday. It comes from the loop + position rather than from a date calculation, which is why this checks the + pairing and not the markup: an off-by-one would put Sunday's name on + Monday's cell.""" sign_in(superadmin_id) page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True) diff --git a/apps/board/tests/test_templates.py b/apps/board/tests/test_templates.py index 3c1fa49..ca13705 100644 --- a/apps/board/tests/test_templates.py +++ b/apps/board/tests/test_templates.py @@ -306,56 +306,116 @@ def _winning_display(rules, ending_in): return winner +def _rules_in(body): + body = re.sub(r"/\*.*?\*/", "", body, flags=re.DOTALL) + return [(selector.strip(), rule.group("body")) + for rule in RULE.finditer(body) + for selector in rule.group("selectors").split(",") if selector.strip()] + + @pytest.fixture(scope="module") -def calendar_phone_rules(): - css = (Path(__file__).resolve().parents[1] / "static" / "board.css").read_text(encoding="utf-8") - block = CALENDAR_PHONE_BLOCK.search(css) +def board_css(): + return (Path(__file__).resolve().parents[1] / "static" / "board.css").read_text( + encoding="utf-8") + + +@pytest.fixture(scope="module") +def calendar_phone_rules(board_css): + block = CALENDAR_PHONE_BLOCK.search(board_css) assert block, "board.css has no phone block for the calendar" - body = re.sub(r"/\*.*?\*/", "", block.group("body"), flags=re.DOTALL) - rules = [] - for rule in RULE.finditer(body): - for selector in rule.group("selectors").split(","): - if selector.strip(): - rules.append((selector.strip(), rule.group("body"))) - return rules + return _rules_in(block.group("body")) -def test_the_padding_cells_are_actually_hidden_on_a_phone(calendar_phone_rules): - """The one that shipped: `.cal td { display: block }` is (0,1,1) and - `.cal__pad { display: none }` is (0,1,0), so the padding cells stayed as - 92px empty boxes — while `.cal__day:not(:has(.cal__event))` at (0,2,0) won - and hid every real day. A month with no events drew four blank boxes and - nothing else, and the HTML was correct throughout. +@pytest.fixture(scope="module") +def calendar_base_rules(board_css): + """The calendar's rules outside any media block — everything from the + section heading up to the first `@media` after it.""" + start = board_css.index("--- the private calendar") + end = board_css.index("@media", start) + return _rules_in(board_css[start:end]) + + +def test_the_month_is_seven_columns_at_every_width(calendar_base_rules, + calendar_phone_rules): + """The regression this phase is about, stated as a rule. + + The month was a , and the only way to make a seven-column table + legible at 390px was to stop it being one — which turned a calendar into a + list of dates, and on the way there produced the specificity bug that drew + an empty month as four blank boxes. It is a grid now, and a grid stays a + grid: the phone makes the cells smaller and moves the titles out of them, + and that is all it is allowed to do. """ - winner = _winning_display(calendar_phone_rules, {"td.cal__pad", ".cal__pad", "td"}) - assert winner, "nothing in the phone block decides what a padding cell does" - assert winner[2] == "none", ( - f"a padding cell ends up `display: {winner[2]}` from `{winner[1]}`. " - "A rule naming td outranks one naming only the class, so every cell " - "belonging to the neighbouring month is drawn as an empty box." - ) + columns = [re.search(r"grid-template-columns\s*:\s*([^;]+)", body).group(1) + for selector, body in calendar_base_rules + if selector.endswith(".cal__grid") and "grid-template-columns" in body] + assert columns, "the base stylesheet never gives .cal__grid its columns" + assert "repeat(7," in columns[0].replace(" ", ""), ( + f"the month is laid out as `{columns[0].strip()}` rather than seven columns") + + for selector, body in calendar_phone_rules: + if not selector.endswith(".cal__grid"): + continue + display = re.search(r"display\s*:\s*([\w-]+)", body) + assert not display or display.group(1) == "grid", ( + f"`{selector}` takes the month off the grid on a phone " + f"(`display: {display.group(1)}`), which is how it became a list " + "of dates the first time.") + assert "grid-template-columns" not in body, ( + f"`{selector}` changes the number of columns on a phone; a month " + "has seven of them at every width.") -def test_every_day_of_the_month_is_drawn_on_a_phone(calendar_phone_rules): - """The month is a column of days there, not only the days with something in - them: an empty day is how you see the month is empty, and how an admin taps - the 14th to put something on it.""" - winner = _winning_display(calendar_phone_rules, {"td.cal__day", ".cal__day"}) - assert winner and winner[2] != "none", ( - f"a day cell ends up hidden on a phone (`{winner[1] if winner else '—'}`)." - ) +def test_no_cell_of_the_month_is_hidden_on_a_phone(calendar_phone_rules): + """Neither a day nor a padding cell. + + The day cells are obvious. The padding cells are the ones worth a test: + they were `display: none` while the month was a list, and in a grid they + are what puts the 1st under its own weekday — hide them and every date in + the month lands on the wrong column, which still *looks* like a calendar. + """ + for compounds, what in ((({"li.cal__day", ".cal__day"}), "a day"), + (({"li.cal__pad", ".cal__pad"}), "a padding cell")): + winner = _winning_display(calendar_phone_rules, compounds) + assert winner is None or winner[2] != "none", ( + f"{what} ends up hidden on a phone, from `{winner[1]}`.") -def test_the_weekday_shows_on_a_phone(calendar_phone_rules): - """The header row is hidden at that width, and the base stylesheet hides - `.cal__weekday` because up there the header says it. If the phone block - only restyles it without turning it back on, every row of the month reads - as a bare number — which is how it was first rendered.""" - winner = _winning_display(calendar_phone_rules, {".cal__weekday", "span.cal__weekday"}) - assert winner and winner[2] != "none", ( - "the phone block never gives .cal__weekday a display of its own, so the " - "base `display: none` stands and the days lose their weekday." - ) +def test_the_weekday_is_hidden_from_the_eye_and_not_from_a_screen_reader( + calendar_base_rules): + """A fifty-pixel cell has room for a number and nothing else, so the + weekday inside each cell is clipped rather than drawn — the header row says + it for anyone who can see it. `display: none` would be the obvious way to + do that and the wrong one: it takes the element out of the accessibility + tree too, and then «22» is announced as the number 22 with no day attached. + """ + rules = [(selector, body) for selector, body in calendar_base_rules + if selector.strip().endswith(".cal__weekday")] + assert rules, "nothing in board.css hides .cal__weekday from the eye" + for selector, body in rules: + display = re.search(r"display\s*:\s*([\w-]+)", body) + assert not display or display.group(1) != "none", ( + f"`{selector}` uses display:none, which hides the weekday from a " + "screen reader as well. Clip it instead.") + assert any("clip-path" in body for _, body in rules), ( + "the weekday is not clipped, so it is drawn inside every cell") + + +def test_everywhere_a_member_writes_breaks_a_word_too_long_for_its_box(board_css): + """A pasted URL is one word, and `profiles.clean_links` lets it be five + hundred characters long. + + `.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, so a bio + looked right while being written and came back out through the side of the + card. The two lists are the same list, which is the only reason this is a + test rather than a line in the stylesheet nobody reads. + """ + for selector in (".rich", ".prose", ".person-head__links", ".cal__event"): + assert re.search( + r"(^|,)\s*" + re.escape(selector) + r"\s*(,[^{]*)?\{[^}]*overflow-wrap", + board_css, re.MULTILINE), ( + f"`{selector}` has no overflow-wrap, so a pasted link leaves the box") AGENDA_PHONE_BLOCK = re.compile( diff --git a/docs/server-setup.md b/docs/server-setup.md index e561330..0719e20 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -1401,22 +1401,35 @@ In the members area the navigation **wraps** on a phone rather than scrolling: six sections over two lines shows all six, where a swipe strip would have left Calendario and Gestión off the right edge with nothing to say they were there. -**Both calendars become a column of days below 640px** — every day of the month, -in order, with its weekday beside it, the days carrying something standing out, -and a line saying so when the month is empty. The private one -(`/comunidad/calendario`, a `
    `) and the public agenda (`/page/agenda/`, -an `
      `) are deliberately the same shape, because the private one lists the -public events and a member moves between the two. +**The private calendar is a seven-column month at every width.** Below 640px +the cells shrink to about 50px, the titles come out of them and each day with +something in it shows one dot per event and links to that day's block in a list +under the grid — an anchor, so it needs no script. Above 640px the titles are +in the cells and the list is not drawn. The padding cells belonging to the +neighbouring months keep their space at both widths: they are what puts the 1st +under its own weekday. -Both phone blocks are written so that **every rule deciding `display` names the -cell's own class**, and `apps/board/tests/test_templates.py` fails if one does -not. That is the shape of the bug it replaces: the calendar's block opened with -`.cal td { display: block }` — specificity (0,1,1) — which outranked -`.cal__pad { display: none }` at (0,1,0), while `.cal__day:not(:has(…))` at -(0,2,0) won and hid every real day. A month with no events therefore drew four -empty boxes and nothing else, with correct HTML throughout. The guard computes -the specificity and runs the cascade for a padding cell, a day cell and the -weekday label, which is as close as pytest gets to looking at a page. +The weekday inside each cell is **clipped rather than `display: none`**, because +the header row says it to anyone who can see it and a screen reader still needs +«22» to announce itself as a Thursday. + +**It is an `
        ` on a CSS grid and not a `
    `, and that is load-bearing.** +A table brings `tbody`, `tr` and `td` with it, so every phone rule had to name +an element to undo them — and `.cal td` at specificity (0,1,1) outranks +`.cal__pad` at (0,1,0). That is exactly what shipped: the padding cells stayed +as 92px empty boxes while `.cal__day:not(:has(…))` at (0,2,0) won and hid every +real day, so a month with nothing in it drew four empty boxes and nothing else +— with correct HTML throughout. A grid has no scaffolding to undo, which is why +the public agenda (`/page/agenda/`, an `
      ` since it was written) never had +the bug. `apps/board/tests/test_templates.py` computes specificity and runs the +cascade for a day cell, a padding cell and the grid itself, which is as close as +pytest gets to looking at a page. + +**A pasted link breaks rather than leaving its box.** `profiles.clean_links` +accepts a 500-character label and a URL is one word, so `.prose`, +`.person-head__links`, `.cal__event` and `.panel__row` all carry +`overflow-wrap: anywhere` — the rule `.rich`, the box the text is *typed* into, +has had since the editor shipped. The guard holds the two lists together. **Tap targets are raised under `@media (pointer: coarse)`** in both stylesheets, and both blocks are **padding only** — no type size, colour or spacing changes,