diff --git a/public/digest.html b/public/digest.html index 4cb6171..96b37c1 100644 --- a/public/digest.html +++ b/public/digest.html @@ -96,7 +96,38 @@ .digest-empty .btn-primary { margin-top: 10px; } .digest-none { color: var(--muted); font-size: .85rem; font-style: italic; } .digest-highlight { outline: 2px solid #f59e0b; outline-offset: 3px; } - .digest-new-btn { margin-left: auto; } + .digest-new-btn { margin-left: 0; } + .digest-view-toggle { margin-left: auto; align-self: center; padding: 6px 10px; gap: 8px; } + .digest-view-toggle .toggle-text small { font-size: .8rem; } + + .digest-list.digest-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; } + .digest-list.digest-cards .digest-empty { grid-column: 1 / -1; } + .digest-cards .digest-card { border-radius: var(--radius); animation: entryEnter .4s cubic-bezier(.22,1,.36,1) both; } + .digest-cards .digest-card-top { padding: 16px 16px 0; gap: 8px; } + .digest-cards .digest-title { font-size: .95rem; font-weight: 600; } + .digest-cards .digest-badge { font-size: .62rem; padding: 3px 8px; } + .digest-cards .digest-avatar { display: none; } + .digest-cards .digest-meta { gap: 0; min-width: 0; } + .digest-cards .digest-meta-text { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-width: 0; } + .digest-cards .digest-author, + .digest-cards .digest-date { display: inline-flex; align-items: center; max-width: calc(50% - 3px); min-width: 0; background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); color: #fff; font-size: .72rem; font-weight: 600; line-height: 1.3; padding: 3px 9px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .digest-cards .digest-date svg { width: 11px; height: 11px; opacity: .85; } + .digest-cards .digest-main { flex: 1 1 auto; flex-direction: column; gap: 0; padding: 0; } + .digest-cards .digest-cover { flex: 0 0 auto; position: relative; width: 100%; max-width: none; min-width: 0; aspect-ratio: 4/3; border-radius: 0; border-left: none; border-right: none; border-bottom: 1px solid var(--border); } + .digest-cards .digest-cover .digest-meta { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; pointer-events: none; } + .digest-cards .digest-content { padding: 12px 16px 0; gap: 8px; } + .digest-cards .digest-body { font-size: .9rem; line-height: 1.62; } + .digest-cards .digest-body.clamp { max-height: 168px; } + .digest-cards .digest-shot { width: 46px; } + .digest-cards .digest-foot { margin-top: auto; padding: 10px 14px; gap: 8px; } + .digest-cards .digest-act { padding: 6px; font-size: 0; gap: 0; } + + @media (max-width: 1200px) { + .digest-list.digest-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } + } + @media (prefers-reduced-motion: reduce) { + .digest-cards .digest-card { animation: none; } + } .field-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; display: block; } .digest-file-hidden { display: none; } @@ -128,6 +159,7 @@ .digest-side { position: static; max-height: 260px; } } @media (max-width: 720px) { + .digest-list.digest-cards { grid-template-columns: 1fr; } .digest-card-top { padding: 20px 18px 0; } .digest-main { flex-direction: column; gap: 16px; padding: 16px 18px 0; } .digest-cover { flex: none; width: 100%; max-width: none; } @@ -144,6 +176,11 @@

Дайджест

Важные сообщения для команды

+
diff --git a/public/js/digest.js b/public/js/digest.js index 5b36e56..691073c 100644 --- a/public/js/digest.js +++ b/public/js/digest.js @@ -12,7 +12,9 @@ let activeDigestId = null; let digestNavObserver = null; let deletedMode = false; + let cardsView = false; const DRAFT_KEY = 'whatido:digest:draft'; + const VIEW_KEY = 'whatido:digest:view'; function draftPayload() { const titleEl = document.getElementById('digestTitle'); @@ -138,8 +140,17 @@ else if (d.hide_at) badges.push('Скроется ' + esc(fmtDateTimeY(d.hide_at)) + ''); } + const metaHtml = '
' + + '' + + '
' + + '' + esc(d.author_name || '—') + '' + + '' + esc(fmtDateTimeY(d.published_at || d.created_at)) + '' + + '
' + + '
'; + + const coverMeta = cardsView && d.preview_path ? metaHtml : ''; const cover = d.preview_path - ? '
' + ? '
' + coverMeta + '
' : ''; const images = Array.isArray(d.images) ? d.images : []; @@ -156,15 +167,15 @@ const actions = []; if (deleted) { - actions.push(''); - actions.push(''); + actions.push(''); + actions.push(''); } else { if (admin) { - actions.push(''); + actions.push(''); } if (canEdit) { - actions.push(''); - actions.push(''); + actions.push(''); + actions.push(''); } } @@ -184,19 +195,14 @@ : ''; return '
' + + (cardsView ? cover : '') + '
' + (badges.length ? '
' + badges.join('') + '
' : '') + '

' + esc(d.title) + '

' + - '
' + - '' + - '
' + - '' + esc(d.author_name || '—') + '' + - '' + esc(fmtDateTimeY(d.published_at || d.created_at)) + '' + - '
' + - '
' + + (cardsView && d.preview_path ? '' : metaHtml) + '
' + '
' + - cover + + (cardsView ? '' : cover) + '
' + bodyHtml + galleryHtml + '
' + '
' + footHtml + @@ -341,6 +347,13 @@ if (nb) nb.style.display = (!deletedMode && isAdmin()) ? '' : 'none'; } + function applyViewMode() { + const list = document.getElementById('digestList'); + if (list) list.classList.toggle('digest-cards', cardsView); + const toggle = document.getElementById('digestCardsView'); + if (toggle) toggle.checked = cardsView; + } + async function toggleDeletedMode() { deletedMode = !deletedMode; query = ''; @@ -831,6 +844,13 @@ document.getElementById('digestNewBtn').addEventListener('click', function() { openDigestModal(null); }); const delBtn = document.getElementById('digestDeletedBtn'); if (delBtn) delBtn.addEventListener('click', function() { toggleDeletedMode(); }); + const viewToggle = document.getElementById('digestCardsView'); + if (viewToggle) viewToggle.addEventListener('change', function() { + cardsView = viewToggle.checked; + try { localStorage.setItem(VIEW_KEY, cardsView ? 'cards' : 'list'); } catch (e) {} + applyViewMode(); + if (digestLoaded) renderDigests(); + }); const search = document.getElementById('digestSearch'); if (search) search.addEventListener('input', function() { query = search.value; renderDigests(); }); document.addEventListener('click', function(e) { @@ -886,6 +906,8 @@ if (nb) nb.style.display = isAdmin() ? '' : 'none'; bindModal(); bindPage(); + try { cardsView = localStorage.getItem(VIEW_KEY) === 'cards'; } catch (e) {} + applyViewMode(); applyDeletedModeUI(); renderIcons(); await loadDigests();