fix(contacts): колонки больше не сжимаются — table-layout fixed, скрытая карточка, свёрнутая панель

Причина, почему после пагинации список оставался узким:
- min-width на <td> в табличной раскладке не соблюдается (колонки сжимались);
- карточка контакта занимала 340–460 px ещё до выбора контакта, панель
  ассистента — 330 px (chatOpen: true по умолчанию).

- table-layout:fixed + явные ширины колонок 130/100/110/160/150/130/160,
  min-width таблицы 940px; при нехватке — горизонтальный скролл списка.
- .cols.no-card: пока контакт не выбран, карточка не занимает место; класс
  снимается hx-on::after-request при клике по строке.
- На /contacts панель ассистента стартует свёрнутой (chatOpen false),
  открывается кликом по 🤖; колонка фильтров 220px.
- Ссылка на CSS с версией (?v=<mtime>) — после пересборки браузер не держит
  старые стили.

Замеры headless-Chromium (метрики из DOM): без карточки 1600px → список 1327px,
1366px → 1093px, скролла нет; с карточкой 1600px → 958px (таблица 940
помещается), 1366px → 753px (скролл, ширины сохраняются).
tests/test_contacts_ui.py — 16/16; контейнер пересобран (healthy), живые
запросы подтверждают no-card/chatOpen false/940px и CSS с версией.
This commit is contained in:
2026-10-29 14:09:59 +00:00
parent 9f0f99bdfc
commit f41d00cecb
9 changed files with 95 additions and 16 deletions
+5
View File
@@ -104,6 +104,11 @@ def params_url(base: str, params: dict, **overrides) -> str:
templates.env.globals["params_url"] = params_url
# версия статики в URL — иначе браузер держит старый CSS после пересборки
try:
templates.env.globals["static_ver"] = str(int((ROOT / "static/css/app.css").stat().st_mtime))
except OSError:
templates.env.globals["static_ver"] = "1"
# --- модуль задач (VTODO) ---
app.include_router(tasktracker_router)
+13 -10
View File
@@ -326,7 +326,9 @@ body.f3 .c3{flex:1}
/* ─── Контакты ─────────────────────────────────────────────────────────── */
.cfit{display:flex;flex-direction:column;min-height:0;width:250px}
.cfit{display:flex;flex-direction:column;min-height:0;width:220px;min-width:200px}
/* пока контакт не выбран, карточка не занимает место — список получает всю ширину */
.cols.no-card > .c3{display:none}
.cfilters{display:flex;flex-direction:column;gap:4px;padding:8px 10px;overflow-y:auto;
position:sticky;top:0;background:var(--bg2);z-index:3;max-height:52vh}
.cfilters .cf{display:flex;flex-direction:column;gap:1px;font-size:10.5px;color:var(--fg3)}
@@ -359,15 +361,16 @@ body.f3 .c3{flex:1}
.cwide{flex:2.6;min-width:600px;position:relative;display:flex;flex-direction:column;min-height:0}
.cwide .lw{overflow:auto}
.cols > .c3{min-width:340px;max-width:460px}
.ctab{width:100%;min-width:860px;border-collapse:collapse;font-size:12.5px;white-space:nowrap}
/* минимальные ширины колонок: текст не сжимается в нечитаемое */
.ctab th:nth-child(1),.ctab td:nth-child(1){min-width:120px}
.ctab th:nth-child(2),.ctab td:nth-child(2){min-width:90px}
.ctab th:nth-child(3),.ctab td:nth-child(3){min-width:100px}
.ctab th:nth-child(4),.ctab td:nth-child(4){min-width:140px}
.ctab th:nth-child(5),.ctab td:nth-child(5){min-width:130px}
.ctab th:nth-child(6),.ctab td:nth-child(6){min-width:130px}
.ctab th:nth-child(7),.ctab td:nth-child(7){min-width:150px}
.ctab{width:100%;min-width:940px;table-layout:fixed;border-collapse:collapse;
font-size:12.5px;white-space:nowrap}
/* ширины колонок заданы явно: table-layout:fixed их соблюдает (min-width на td не работает) */
.ctab th:nth-child(1),.ctab td:nth-child(1){width:130px}
.ctab th:nth-child(2),.ctab td:nth-child(2){width:100px}
.ctab th:nth-child(3),.ctab td:nth-child(3){width:110px}
.ctab th:nth-child(4),.ctab td:nth-child(4){width:160px}
.ctab th:nth-child(5),.ctab td:nth-child(5){width:150px}
.ctab th:nth-child(6),.ctab td:nth-child(6){width:130px}
.ctab th:nth-child(7),.ctab td:nth-child(7){width:160px}
.ctab th{position:sticky;top:0;background:var(--bg2);text-align:left;font-weight:600;font-size:11.5px;
color:var(--fg2);padding:6px 8px;border-bottom:1px solid var(--border);cursor:pointer;white-space:nowrap}
.ctab th:hover{color:var(--fg)}
+2 -2
View File
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Email Assistant{% endblock %}</title>
<link rel="stylesheet" href="/static/css/app.css">
<link rel="stylesheet" href="/static/css/app.css?v={{ static_ver }}">
<script src="/static/js/vendor/htmx.min.js" defer></script>
<script src="/static/js/vendor/alpine.min.js" defer></script>
</head>
@@ -90,7 +90,7 @@
function appState() {
return {
dark: localStorage.getItem('ea-theme') !== 'light',
chatOpen: true,
chatOpen: {{ 'false' if page == 'contacts' else 'true' }},
aiCtx: {...window.EA_CONTEXT || {}},
messages: [
{ id: 1, role: 'assistant', html: 'Привет! Я ассистент по вашей почте — работаю локально (qwen3:8b). Спросите про письма, задачи или календарь.' }
@@ -1,5 +1,5 @@
{% from "partials/_contact_macros.html" import edit_value %}
<div class="cols" id="contacts-cols" style="flex:1">
<div class="cols{% if not current %} no-card{% endif %}" id="contacts-cols" style="flex:1">
<!-- колонка 1: фильтры + алфавитный указатель -->
<div class="c1 cfit">
@@ -15,6 +15,7 @@
<tbody>
{% for c in contacts %}
<tr class="crow" hx-get="/contacts/{{ c.id }}" hx-target="#c3" hx-swap="innerHTML"
hx-on::after-request="document.getElementById('contacts-cols').classList.remove('no-card')"
title="открыть карточку контакта">
<td>{{ edit_value(c, 'last_name') }}</td>
<td>{{ edit_value(c, 'first_name') }}</td>