source: Klonkt/src/views/pages/timeline.ejs@ cb3d5fc

main
Last change on this file since cb3d5fc was cb3d5fc, checked in by Robin Genis <roboburr@…>, 2 months ago

style(tijdlijn): coloured SVG action icons (no emoji), uniform 36px circular buttons

Like=gold star, boost=green repeat, reply=accent arrow, block=red ban — all identical
36px circles (flex:0 0 36px, box-sizing), coloured per action instead of emoji.

  • Property mode set to 100644
File size: 12.9 KB
Line 
1<div class="tl-wrap">
2 <%- include('../partials/fedi-tabs', { active: 'feed' }) %>
3 <h1 class="tl-title"><%= t('tl.title') %></h1>
4 <p class="tl-lead"><%= t('tl.lead') %></p>
5 <% if (typeof success !== 'undefined' && success) { %><div class="alert alert-success"><%= success %></div><% } %>
6 <% if (typeof error !== 'undefined' && error) { %><div class="alert alert-error"><%= error %></div><% } %>
7
8 <% if (!timeline || !timeline.length) { %>
9 <div class="tl-empty">
10 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>
11 <p><%= t('tl.empty') %></p>
12 </div>
13 <% } else { %>
14 <ol class="tl-feed">
15 <% timeline.forEach(function(p){ %>
16 <li class="tl-item">
17 <div class="tl-head">
18 <span class="tl-avatar"><% if (p.author_icon) { %><img src="<%= p.author_icon %>" alt="" loading="lazy"><% } else { %><%= (p.author_name || '?').charAt(0).toUpperCase() %><% } %></span>
19 <span class="tl-id">
20 <a class="tl-author" href="<%= p.author_url || p.author_uri %>" target="_blank" rel="nofollow noopener"><%= p.author_name %></a>
21 <span class="tl-handle"><%= p.author_handle %></span>
22 </span>
23 <% if (p.published || p.created_at) { %><time class="tl-time"><%= formatDateTime(p.published || p.created_at) %></time><% } %>
24 </div>
25
26 <div class="tl-content"><%- p.content %></div>
27
28 <%
29 var media = []; try { media = JSON.parse(p.media_json || '[]'); } catch (e) { media = []; }
30 var imgs = media.filter(function(m){ return m && m.url && (!m.type || /^image\//.test(m.type)); });
31 var vids = media.filter(function(m){ return m && m.url && m.type && /^video\//.test(m.type); });
32 var auds = media.filter(function(m){ return m && m.url && m.type && /^audio\//.test(m.type); });
33 %>
34 <% if (imgs.length) { %>
35 <div class="tl-media">
36 <% imgs.forEach(function(m){ %>
37 <a class="tl-media-img" href="<%= m.url %>" target="_blank" rel="noopener"><img src="<%= m.url %>" alt="" loading="lazy" decoding="async"></a>
38 <% }); %>
39 </div>
40 <% } %>
41 <% vids.forEach(function(m){ %><video class="tl-media-video" src="<%= m.url %>" controls preload="metadata" playsinline></video><% }); %>
42 <% auds.forEach(function(m){ %><audio class="tl-media-audio" src="<%= m.url %>" controls preload="none"></audio><% }); %>
43
44 <% if (p.embedHtml) { %><div class="tl-embed"><%- p.embedHtml %></div><% } %>
45
46 <% if (p.url) { %><a class="tl-orig" href="<%= p.url %>" target="_blank" rel="nofollow noopener"><%= t('tl.view_original') %></a><% } %>
47
48 <div class="tl-actions">
49 <form method="post" action="/timeline/like" class="tl-act-form"><input type="hidden" name="note" value="<%= p.id %>"><input type="hidden" name="author" value="<%= p.author_uri %>"><button type="submit" class="tl-act tl-act-like" title="<%= t('fedi.likes') %>" aria-label="<%= t('fedi.likes') %>"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.6l2.9 5.88 6.49.95-4.7 4.58 1.11 6.46L12 17.96l-5.8 3.06 1.1-6.46-4.69-4.58 6.49-.95z"/></svg></button></form>
50 <% if (p.boosted) { %>
51 <form method="post" action="/timeline/unboost" class="tl-act-form"><input type="hidden" name="note" value="<%= p.id %>"><input type="hidden" name="author" value="<%= p.author_uri %>"><button type="submit" class="tl-act tl-act-boost is-on" title="<%= t('tl.unboost') %>" aria-label="<%= t('tl.unboost') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg></button></form>
52 <% } else { %>
53 <form method="post" action="/timeline/boost" class="tl-act-form"><input type="hidden" name="note" value="<%= p.id %>"><input type="hidden" name="author" value="<%= p.author_uri %>"><button type="submit" class="tl-act tl-act-boost" title="<%= t('fedi.boosts') %>" aria-label="<%= t('fedi.boosts') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg></button></form>
54 <% } %>
55 <button type="button" class="tl-act tl-act-reply fedi-remote-reply-btn" data-fedi-uri="<%= p.id %>" data-fedi-ph="<%= t('fedi.remote_ph') %>" title="<%= t('fedi.remote_reply') %>" aria-label="<%= t('fedi.remote_reply') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg></button>
56 <form method="post" action="/blocking/add" class="tl-act-form" onsubmit="return confirm('<%= t('tl.block') %>?');"><input type="hidden" name="target" value="<%= p.author_uri %>"><button type="submit" class="tl-act tl-act-block" title="<%= t('tl.block') %>" aria-label="<%= t('tl.block') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg></button></form>
57 </div>
58 </li>
59 <% }); %>
60 </ol>
61 <% } %>
62</div>
63
64<style>
65 .tl-wrap { max-width: 640px; margin: 1rem auto 3rem; padding: 0 1rem; }
66 .tl-title { margin: 0 0 .15rem; font-size: clamp(1.5rem, 4vw, 1.8rem); }
67 .tl-lead { color: var(--ink-soft, #888); margin: 0 0 1.5rem; }
68 .tl-empty { text-align: center; color: var(--ink-soft, #888); margin: 3rem auto; }
69 .tl-empty svg { width: 44px; height: 44px; color: color-mix(in srgb, var(--accent, #888) 60%, transparent); margin: 0 auto .75rem; display: block; }
70
71 .tl-feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
72 .tl-item { padding: 1.1rem 1.15rem; border-radius: 16px;
73 border: 1px solid color-mix(in srgb, var(--ink, #000) 8%, transparent);
74 background: color-mix(in srgb, var(--ink, #000) 2.5%, transparent);
75 transition: border-color .15s ease, box-shadow .15s ease; }
76 .tl-item:hover { border-color: color-mix(in srgb, var(--accent, #888) 32%, transparent);
77 box-shadow: 0 2px 14px color-mix(in srgb, var(--ink, #000) 6%, transparent); }
78
79 .tl-head { display: flex; align-items: center; gap: .65rem; margin: 0 0 .65rem; }
80 .tl-avatar { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
81 display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem;
82 background: color-mix(in srgb, var(--accent, #888) 22%, transparent); color: var(--accent, #555);
83 box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #888) 18%, transparent); }
84 .tl-avatar img { width: 100%; height: 100%; object-fit: cover; }
85 .tl-id { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
86 .tl-author { font-weight: 700; color: var(--ink, inherit); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
87 .tl-author:hover { text-decoration: underline; }
88 .tl-handle { color: var(--ink-soft, #888); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
89 .tl-time { color: var(--ink-soft, #999); font-size: .78rem; flex: 0 0 auto; align-self: flex-start; white-space: nowrap; }
90
91 .tl-content { line-height: 1.55; overflow-wrap: anywhere; }
92 .tl-content p { margin: .4rem 0; } .tl-content p:first-child { margin-top: 0; } .tl-content p:last-child { margin-bottom: 0; }
93 .tl-content a { color: var(--accent, #06c); }
94 .tl-content img { max-width: 100%; height: auto; border-radius: 10px; background: #fff; }
95
96 /* Always show the FULL image at its natural ratio — never cropped, no letterbox. */
97 .tl-media { display: flex; flex-direction: column; gap: .4rem; margin: .75rem 0 0; }
98 .tl-media-img { display: block; border-radius: 12px; overflow: hidden; background: #fff; }
99 .tl-media-img img { width: 100%; height: auto; display: block; }
100
101 .tl-media-video, .tl-media-audio { width: 100%; margin: .75rem 0 0; border-radius: 12px; display: block; }
102 .tl-media-video { max-height: 480px; background: #000; }
103
104 .tl-embed { margin: .75rem 0 0; border-radius: 12px; overflow: hidden; background: var(--paper-2, #111); }
105 .tl-embed-frame { width: 100%; border: 0; display: block; aspect-ratio: 16 / 9; }
106 .tl-embed-spotify { aspect-ratio: auto; height: 152px; }
107 .tl-embed-sc { aspect-ratio: auto; height: 166px; }
108
109 .tl-orig { display: inline-block; margin: .7rem 0 0; font-size: .82rem; color: var(--accent, #06c); text-decoration: none; }
110 .tl-orig:hover { text-decoration: underline; }
111
112 /* Uniform circular action buttons with coloured icons (no emoji). */
113 .tl-actions { display: flex; gap: .5rem; margin-top: .9rem; align-items: center; }
114 .tl-act-form { margin: 0; display: inline-flex; }
115 .tl-act { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; padding: 0; box-sizing: border-box;
116 display: inline-flex; align-items: center; justify-content: center;
117 border: 1px solid color-mix(in srgb, var(--ink, #000) 12%, transparent);
118 background: color-mix(in srgb, var(--ink, #000) 3%, transparent);
119 color: var(--ink-soft, #888); cursor: pointer; -webkit-tap-highlight-color: transparent;
120 transition: background .12s, border-color .12s, transform .1s; }
121 .tl-act svg { width: 18px; height: 18px; display: block; }
122 .tl-act:active { transform: scale(.9); }
123 .tl-act-like svg { color: #e8b04b; }
124 .tl-act-like:hover { background: color-mix(in srgb, #e8b04b 15%, transparent); border-color: color-mix(in srgb, #e8b04b 50%, transparent); }
125 .tl-act-boost svg { color: #2fa85a; }
126 .tl-act-boost:hover { background: color-mix(in srgb, #2fa85a 15%, transparent); border-color: color-mix(in srgb, #2fa85a 50%, transparent); }
127 .tl-act-boost.is-on { background: color-mix(in srgb, #2fa85a 18%, transparent); border-color: color-mix(in srgb, #2fa85a 60%, transparent); }
128 .tl-act-reply svg { color: var(--accent, #06c); }
129 .tl-act-reply:hover { background: color-mix(in srgb, var(--accent, #888) 14%, transparent); border-color: color-mix(in srgb, var(--accent, #888) 50%, transparent); }
130 .tl-act-block svg { color: #e0524d; }
131 .tl-act-block:hover { background: color-mix(in srgb, #d9534f 14%, transparent); border-color: color-mix(in srgb, #d9534f 50%, transparent); }
132</style>
133
134<script>
135(function(){
136 if (window.__fediRemoteWired) return; window.__fediRemoteWired = true;
137 var current = null, currentBtn = null;
138 function close(){ if (current) { current.remove(); current = null; currentBtn = null; } }
139 function go(raw, uri){ var d=(raw||'').trim().replace(/^@?[^@\s]*@/,'').replace(/^https?:\/\//i,'').replace(/\/.*$/,'').trim(); if(d) location.href='https://'+d+'/authorize_interaction?uri='+encodeURIComponent(uri||''); }
140 function place(f, b){ var r=b.getBoundingClientRect(); f.style.top=(r.bottom+window.scrollY+6)+'px'; f.style.left=Math.max(8, Math.min(r.left+window.scrollX, window.scrollX+window.innerWidth-340))+'px'; }
141 document.addEventListener('click', function(e){
142 if (e.target.closest && e.target.closest('.fedi-remote-cancel')) { close(); return; }
143 if (current && e.target.closest && e.target.closest('.fedi-remote-form')) return;
144 var b = e.target.closest && e.target.closest('.fedi-remote-reply-btn');
145 if (b) {
146 e.preventDefault();
147 if (currentBtn === b) { close(); return; }
148 close();
149 var f = document.createElement('form'); f.className='fedi-remote-form'; f.dataset.uri = b.getAttribute('data-fedi-uri')||'';
150 f.innerHTML = '<input type="text" autocomplete="off" spellcheck="false"><button type="submit" class="btn btn-primary fedi-remote-go" aria-label="ok">&rarr;</button><button type="button" class="fedi-remote-cancel" aria-label="x">&times;</button>';
151 f.querySelector('input').placeholder = b.getAttribute('data-fedi-ph') || 'mastodon.social';
152 document.body.appendChild(f); place(f, b); current=f; currentBtn=b; f.querySelector('input').focus();
153 return;
154 }
155 if (current) close();
156 });
157 document.addEventListener('submit', function(e){ var f=e.target.closest && e.target.closest('.fedi-remote-form'); if(!f) return; e.preventDefault(); go(f.querySelector('input').value, f.dataset.uri); });
158 document.addEventListener('keydown', function(e){ if (e.key === 'Escape') close(); });
159 window.addEventListener('scroll', close, true);
160})();
161</script>
Note: See TracBrowser for help on using the repository browser.