From a4ded545a326076c20129c17e4b767a71f412377 Mon Sep 17 00:00:00 2001 From: bchbib <1023915+bchbib@users.noreply.github.com> Date: Tue, 1 Dec 2026 17:12:59 +0100 Subject: [PATCH] feat(ui): step through a ticket's images in its header, show the count on the card A ticket with several images showed only the first one: on its card and as the header of the ticket view. The others sat in the attachment list at the bottom of the ticket and were easy to miss; on the board nothing said they were there. - Card: when a ticket holds more than one image, its cover carries a small badge with the number of images. - Ticket view: with more than one image the header is a small gallery. Previous / next buttons on the image, or the left and right arrow keys, step through the images and wrap around; a counter shows the position and the first image is marked "Cover" (the one the card shows). - The arrow keys are left alone while typing in a field, while the full-screen preview is open and when a modifier is held. Frontend only; tickets with one image or none look as before. Co-Authored-By: Claude Fable 5.2 --- apps/desktop/src/lib/components/Card.svelte | 32 +++++- .../src/lib/components/TicketModal.svelte | 108 ++++++++++++++++-- 2 files changed, 129 insertions(+), 11 deletions(-) diff --git a/apps/desktop/src/lib/components/Card.svelte b/apps/desktop/src/lib/components/Card.svelte index ce8ab0c..3a46584 100644 --- a/apps/desktop/src/lib/components/Card.svelte +++ b/apps/desktop/src/lib/components/Card.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte'; import { get } from 'svelte/store'; import { browser } from '$app/environment'; - import { MessageSquare, Paperclip, CheckSquare, ShieldCheck } from 'lucide-svelte'; + import { MessageSquare, Paperclip, CheckSquare, ShieldCheck, Images } from 'lucide-svelte'; import Chip from './ui/Chip.svelte'; import Avatar from './Avatar.svelte'; import CardMenu from './CardMenu.svelte'; @@ -85,10 +85,12 @@ }, step); return () => clearInterval(iv); }); - // First image attachment becomes a compact card cover, like Trello. - let cover = $derived( - ticket.attachments.find((a) => mediaKind(a.mime, a.name) === 'image') + // First image attachment becomes a compact card cover, like Trello. When the + // ticket holds more images than the one shown, the cover says how many. + let images = $derived( + ticket.attachments.filter((a) => mediaKind(a.mime, a.name) === 'image') ); + let cover = $derived(images[0]); // Resolve an assignee to its identity. Identities are keyed by bare email, but // assignees are often stored as the full git form `Name ` — so fall back // to matching the address inside the angle brackets (else the avatar/name/kind @@ -154,6 +156,11 @@ alt={cover.name} loading="lazy" /> + {#if images.length > 1} + {images.length} + {/if} {/if} @@ -344,6 +351,7 @@ } } .cover { + position: relative; margin: -12px -12px 0; max-height: 120px; overflow: hidden; @@ -356,6 +364,22 @@ max-height: 120px; object-fit: cover; } + .cover-count { + position: absolute; + right: 8px; + bottom: 8px; + display: inline-flex; + align-items: center; + gap: 4px; + padding: 2px 7px; + border-radius: var(--wp-r-pill); + background: color-mix(in srgb, var(--wp-card) 78%, transparent); + backdrop-filter: blur(4px); + color: var(--wp-text); + font-size: 11px; + font-family: var(--wp-font-mono); + line-height: 16px; + } .prio { width: 8px; height: 8px; diff --git a/apps/desktop/src/lib/components/TicketModal.svelte b/apps/desktop/src/lib/components/TicketModal.svelte index 8a7de54..9462d49 100644 --- a/apps/desktop/src/lib/components/TicketModal.svelte +++ b/apps/desktop/src/lib/components/TicketModal.svelte @@ -2,7 +2,17 @@ import { fade, scale, fly } from 'svelte/transition'; import { browser } from '$app/environment'; import { get } from 'svelte/store'; - import { X, Pencil, Send, Flag, Check, CheckSquare, ShieldCheck } from 'lucide-svelte'; + import { + X, + Pencil, + Send, + Flag, + Check, + CheckSquare, + ShieldCheck, + ChevronLeft, + ChevronRight + } from 'lucide-svelte'; import Chip from './ui/Chip.svelte'; import Avatar from './Avatar.svelte'; import Markdown from './Markdown.svelte'; @@ -15,7 +25,7 @@ import MdToolbar from './MdToolbar.svelte'; import { mdkeys, mdlists } from '$lib/md'; import { mention } from '$lib/mention'; - import { openLightbox } from '$lib/stores/lightbox'; + import { lightbox, openLightbox } from '$lib/stores/lightbox'; import { api, mediaUrl } from '$lib/api'; import { board, @@ -54,10 +64,25 @@ let currentList = $derived($board?.lists.find((l) => l.tickets.some((t) => t.id === ticketId))); let readOnly = $derived($rewinding); - // First image attachment becomes the modal cover. - let cover = $derived( - ticket?.attachments.find((a) => mediaKind(a.mime, a.name) === 'image') + // The ticket's images, in attachment order. The first is the cover: the one + // its card shows on the board, and the one the header opens on. With more than + // one, the header is a small gallery - the buttons on the image, or the left + // and right arrow keys, step through them (and wrap around). + let images = $derived( + ticket?.attachments.filter((a) => mediaKind(a.mime, a.name) === 'image') ?? [] ); + // Remembered by path, so the image in view stays put when attachments change. + let shownPath = $state(null); + $effect(() => { + void ticketId; + shownPath = null; + }); + let shownAt = $derived(Math.max(0, images.findIndex((a) => a.path === shownPath))); + let shown = $derived(images[shownAt]); + function stepImage(by: -1 | 1) { + if (images.length < 2) return; + shownPath = images[(shownAt + by + images.length) % images.length].path; + } // Comments and activity events, interleaved and sorted newest-first - the // Trello-style timeline in the right pane. @@ -302,6 +327,17 @@ }); } function onKey(e: KeyboardEvent) { + if ((e.key === 'ArrowLeft' || e.key === 'ArrowRight') && ticketId && images.length > 1) { + // The arrows belong to whatever is being typed in, to an open full-screen + // preview, and to shortcuts with a modifier - only otherwise to the gallery. + if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return; + if (get(lightbox)) return; + const el = e.target instanceof HTMLElement ? e.target : null; + if (el?.isContentEditable || el?.closest('input, textarea, select')) return; + e.preventDefault(); + stepImage(e.key === 'ArrowLeft' ? -1 : 1); + return; + } if (e.key !== 'Escape' || !ticketId) return; // An inner control (open popover, a checklist-item edit input) that handled the // Escape marks it defaultPrevented - don't also close the whole modal then. @@ -322,9 +358,25 @@ transition:scale={{ duration: dur, start: 0.97, opacity: 0 }} > - {#if cover} + {#if shown}
- {cover.name} + {shown.name} + {#if images.length > 1} + + +
+ {shownAt + 1} / {images.length} + {#if shownAt === 0} + Cover + {/if} +
+ {/if}
{/if} @@ -680,6 +732,7 @@ box-shadow: var(--wp-shadow-lift); } .cover { + position: relative; width: 100%; max-height: 260px; overflow: hidden; @@ -692,6 +745,47 @@ max-height: 260px; object-fit: cover; } + .cover-nav { + position: absolute; + top: 50%; + transform: translateY(-50%); + display: inline-flex; + padding: 8px; + border-radius: var(--wp-r-pill); + border: none; + background: color-mix(in srgb, var(--wp-card) 70%, transparent); + backdrop-filter: blur(4px); + color: var(--wp-text-muted); + cursor: pointer; + } + .cover-nav.prev { + left: 12px; + } + .cover-nav.next { + right: 12px; + } + .cover-nav:hover { + background: var(--wp-elevated); + color: var(--wp-text); + } + .cover-bar { + position: absolute; + left: 12px; + bottom: 12px; + display: flex; + align-items: center; + gap: 6px; + } + .cover-tag { + padding: 3px 9px; + border-radius: var(--wp-r-pill); + background: color-mix(in srgb, var(--wp-card) 78%, transparent); + backdrop-filter: blur(4px); + color: var(--wp-text); + font-size: 11px; + font-family: var(--wp-font-mono); + line-height: 16px; + } .close { position: absolute; top: 12px;