From 8963ed31ce537a736ddba99baf68b31858b319b8 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 6 Nov 2026 20:38:35 +0100 Subject: Add click-to-enlarge image viewer This adds a native dialog for enlarging images throughout the site, including gallery images with previous and next navigation. The viewer supports keyboard navigation, image captions, and responsive layouts, while preserving the existing behaviour of linked images and interactive maps. --- assets/static/css/style.css | 112 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) (limited to 'assets/static/css') diff --git a/assets/static/css/style.css b/assets/static/css/style.css index c210a9b..22df240 100644 --- a/assets/static/css/style.css +++ b/assets/static/css/style.css @@ -1252,3 +1252,115 @@ article::after, pagefind-modal .pf-result-card:has([data-pf-selected]) { background: var(--pf-hover) !important; } + +/* --- Click-to-enlarge content images --- */ +main img[data-enlargeable] { + cursor: zoom-in; + + &:focus-visible { + outline: 2px solid var(--blue); + outline-offset: 0.25rem; + } +} + +dialog#image-viewer { + align-items: center; + background: var(--background); + border: 1px solid var(--foreground); + border-radius: var(--default-border-radius); + color: var(--foreground); + column-gap: clamp(0.5rem, 2vw, 1.5rem); + height: calc(100dvh - 2rem); + max-height: 60rem; + max-width: 96rem; + overflow: hidden; + padding: 3.5rem clamp(0.5rem, 1.5vw, 1.5rem) 1rem; + width: calc(100vw - 2rem); + + &[open] { + display: flex; + } + + &::backdrop { + background: rgb(0 0 0 / 85%); + } + + & > figure { + align-items: center; + border: 0; + display: flex; + flex: 1 1 0; + flex-direction: column; + justify-content: center; + gap: 0.75rem; + height: 100%; + margin: 0; + max-width: none; + min-height: 0; + min-width: 0; + padding: 0; + width: auto; + + & > img { + border-radius: var(--default-border-radius); + display: block; + flex-shrink: 1; + height: auto; + max-height: 100%; + max-width: 100%; + min-height: 0; + object-fit: contain; + width: auto; + } + + & > figcaption { + flex: none; + margin: 0; + max-height: 20dvh; + max-width: 100%; + overflow-y: auto; + text-align: center; + font-style: italic; + } + } + + & > button { + background: var(--background); + border: 1px solid var(--dim-foreground); + border-radius: var(--default-border-radius); + color: var(--foreground); + cursor: pointer; + flex: 0 0 2.5rem; + font: inherit; + height: 2.5rem; + line-height: 1; + padding: 0; + width: 2.5rem; + + &:hover, + &:focus-visible { + background-color: var(--blue); + color: var(--foreground); + } + + &[hidden] { + display: none; + } + + &[data-action="close"] { + position: absolute; + right: 0.75rem; + top: 0.75rem; + } + } + + @media (max-width: 500px) { + column-gap: 0.5rem; + + & > button:not([data-action="close"]) { + flex-basis: 2rem; + height: 2rem; + width: 2rem; + } + } +} -- cgit v1.3.1