π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move description to bottom-left with gradient overlays on desktop
Anand Baburajan2e76dcb8d813
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.cssindex 60ea0f14c3..cb0e53cda7 100644--- a/web/apps/photos/src/styles/photoswipe.css+++ b/web/apps/photos/src/styles/photoswipe.css@@ -11,6 +11,33 @@top: calc(env(titlebar-area-height, 0px) * 0.4);}+@media (width >= 450px) {+ .pswp-ente .pswp__top-bar {+ padding-top: 24px;+ }+}++/* Black gradient overlay at the top */+.pswp-ente .pswp__top-bar::before {+ content: "";+ position: absolute;+ top: 0;+ left: 0;+ right: 0;+ height: 125px;+ background: linear-gradient(+ to top,+ transparent 0%,+ rgb(0 0 0 / 0.05) 20%,+ rgb(0 0 0 / 0.15) 40%,+ rgb(0 0 0 / 0.3) 60%,+ rgb(0 0 0 / 0.45) 80%,+ rgb(0 0 0 / 0.6) 100%+ );+ pointer-events: none;+ z-index: -1;+}+/* The PhotoSwipe CSS already disables and re-enables pointer-events for hiddenUI elements, but for a reason that I didn't investigate more, that isn'tworking, and the hidden buttons still remain clickable.@@ -81,6 +108,13 @@line-height: 20px;}+@media (width >= 450px) {+ .pswp-ente .pswp__counter {+ margin-top: 22px;+ margin-inline-start: 44px;+ }+}+.pswp-ente .pswp__button--zoom .pswp__icn {top: 16px;transform: scale(0.85);@@ -102,6 +136,16 @@margin-right: 2px;}+@media (width >= 450px) {+ .pswp-ente .pswp__top-bar .pswp__button {+ margin-left: 8px;+ }++ .pswp-ente .pswp__button--close {+ margin-right: 20px;+ }+}+.pswp-ente .pswp__button--arrow--prev .pswp__icn {transform: scale(0.8);}@@ -148,14 +192,12 @@}}-/* 4 line caption */+/* Caption styling */.pswp-ente .pswp__caption {border-radius: 3px;/* Same opacity as the other controls. */color: rgb(255 255 255 / 0.85);- background-color: rgb(0 0 0 / 0.2);- backdrop-filter: blur(10px);max-width: 375px;max-height: 200px;p {@@ -171,17 +213,18 @@}}+/* Desktop caption: max 40% width */+@media (width >= 450px) {+ .pswp-ente .pswp__caption {+ max-width: 40%;+ }+}+.pswp-ente .pswp__caption.ente-video {- /* Adding a caption with a blur backdrop filter above the video element- contained in a media-controller causes a subtle tint to be overlaid on- the entire video. This is visible on both Chrome and Firefox as of- writing.-- We'll hide the caption anyways when hovering on the controls or when the- video is playing, so remove the backdrop filter and rely on the- translucent background. Note that usually the video might not even extent- to this part of the screen on desktop sized screens. */- backdrop-filter: none;+ /* Add blur box background for videos since we hide the gradient overlay */+ background-color: rgb(0 0 0 / 0.2);+ backdrop-filter: blur(10px);+ border-radius: 16px;/* Since there is too much going on in this part of the screen now, alsoreduce the maximum number of lines for the caption. */p {@@ -391,27 +434,78 @@ body:has(display: none;}-/* Bottom right controls container (action buttons + caption) */+/* Bottom controls container (caption on left, action buttons on right on desktop) */.pswp-ente .pswp__bottom-right-controls {position: absolute;bottom: 20px;right: 24px;display: flex;- flex-direction: column;+ /* column-reverse to show buttons on top, caption below (matching original HTML order) */+ flex-direction: column-reverse;align-items: flex-end;gap: 12px;}+/* Black gradient overlay at the bottom */+.pswp-ente .pswp__bottom-right-controls::before {+ content: "";+ position: absolute;+ bottom: -20px;+ left: -24px;+ right: -24px;+ height: 225px;+ background: linear-gradient(+ to bottom,+ transparent 0%,+ rgb(0 0 0 / 0.05) 20%,+ rgb(0 0 0 / 0.15) 40%,+ rgb(0 0 0 / 0.3) 60%,+ rgb(0 0 0 / 0.45) 80%,+ rgb(0 0 0 / 0.6) 100%+ );+ pointer-events: none;+ z-index: -1;+}++/* Row layout on desktop: caption on left, buttons on right */+@media (width >= 450px) {+ .pswp-ente .pswp__bottom-right-controls {+ bottom: 40px;+ left: 28px;+ right: 44px;+ flex-direction: row;+ align-items: flex-end;+ gap: 24px;+ }++ .pswp-ente .pswp__bottom-right-controls::before {+ bottom: -40px;+ left: -28px;+ right: -44px;+ }+}+/* Extra offset for video to clear video controls */.pswp-ente .pswp__bottom-right-controls:has(.pswp__caption.ente-video) {bottom: 100px;}-/* Action buttons row */+/* Hide gradient overlay for videos since they have their own controls gradient */+.pswp-ente .pswp__bottom-right-controls:has(.pswp__caption.ente-video)::before {+ display: none;+}++/* Hide gradient overlay when description is not present */+.pswp-ente .pswp__bottom-right-controls:has(.pswp__caption[style*="display: none"])::before {+ display: none;+}++/* Action buttons row - margin-left: auto keeps them on the right when no caption */.pswp-ente .pswp__action-buttons {display: flex;flex-direction: row;gap: 20px;+ margin-left: auto;}.pswp-ente .pswp__action-button {diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 24fd70fc57..b85fb9cbdd 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -1413,8 +1413,10 @@ export class FileViewerPhotoSwipe {element.querySelector<HTMLElement>(".pswp__caption")!;pswp.on("change", () => {const { fileType, alt } = currSlideData();- captionEl.querySelector("p")!.innerText = alt ?? "";- captionEl.style.display = alt ? "block" : "none";+ const captionText = truncateCaptionIfNeeded(alt);+ captionEl.querySelector("p")!.innerText =+ captionText ?? "";+ captionEl.style.display = captionText ? "block" : "none";captionEl.classList.toggle("ente-video",fileType == FileType.video,@@ -1890,7 +1892,7 @@ const livePhotoVideoHTML = (videoURL: string) => ``;/**- * HTML for the bottom right controls (action buttons + caption).+ * HTML for the bottom controls (caption on left, action buttons on right).** The caption uses the line-clamp CSS property, which behaves unexpectedly* when we also assign padding to the "p" element on which we're setting the@@ -1900,6 +1902,7 @@ const livePhotoVideoHTML = (videoURL: string) => `* padding on the div.*/const bottomRightControlsHTML = () => `+<div class="pswp__caption"><p></p></div><div class="pswp__action-buttons"><button class="pswp__action-button" aria-label="Like"><svg viewBox="0 0 30 26" fill="none">${heartSVGPath} /></svg>@@ -1908,9 +1911,18 @@ const bottomRightControlsHTML = () => `<svg viewBox="0 0 28 28" fill="none">${commentSVGPath} /></svg></button></div>-<div class="pswp__caption"><p></p></div>`;+/**+ * Truncate caption text to 154 characters.+ */+const truncateCaptionIfNeeded = (text: string | undefined) => {+ if (!text) return text;+ const maxLength = 154;+ if (text.length <= maxLength) return text;+ return text.slice(0, maxLength) + "β¦";+};+const createElementFromHTMLString = (htmlString: string) => {const template = document.createElement("template");// Excess whitespace causes excess DOM nodes, causing our firstChild to not