From 5ebaf5663d0f4ba3d3eb6cd0d0c6ceeac382a9e3 Mon Sep 17 00:00:00 2001 From: Prospector <6166773+Prospector@users.noreply.github.com> Date: Tue, 15 Mar 2022 22:10:30 -0700 Subject: [PATCH] Add image description, make controls less obtrusive, display native size by default (Fixes #407), Fixed closing modal by clicking out of it (Fixes #405) (#412) --- assets/images/utils/contract.svg | 1 + assets/images/utils/expand.svg | 3 ++ pages/_type/_id/gallery.vue | 75 ++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 assets/images/utils/contract.svg create mode 100644 assets/images/utils/expand.svg diff --git a/assets/images/utils/contract.svg b/assets/images/utils/contract.svg new file mode 100644 index 0000000000..977536891f --- /dev/null +++ b/assets/images/utils/contract.svg @@ -0,0 +1 @@ + diff --git a/assets/images/utils/expand.svg b/assets/images/utils/expand.svg new file mode 100644 index 0000000000..c1f364ead9 --- /dev/null +++ b/assets/images/utils/expand.svg @@ -0,0 +1,3 @@ + + + diff --git a/pages/_type/_id/gallery.vue b/pages/_type/_id/gallery.vue index de38ec5aa3..0791e31285 100644 --- a/pages/_type/_id/gallery.vue +++ b/pages/_type/_id/gallery.vue @@ -5,9 +5,10 @@ class="expanded-image-modal" @click="expandedGalleryItem = null" > -
+
-

- {{ expandedGalleryItem.title }} -

+
+

+ {{ expandedGalleryItem.title }} +

+

+ {{ expandedGalleryItem.description }} +

+
@@ -232,6 +243,8 @@ import LeftArrowIcon from '~/assets/images/utils/left-arrow.svg?inline' import EditIcon from '~/assets/images/utils/edit.svg?inline' import CheckIcon from '~/assets/images/utils/check.svg?inline' import ExternalIcon from '~/assets/images/utils/external.svg?inline' +import ExpandIcon from '~/assets/images/utils/expand.svg?inline' +import ContractIcon from '~/assets/images/utils/contract.svg?inline' import SmartFileInput from '~/components/ui/SmartFileInput' import Checkbox from '~/components/ui/Checkbox' @@ -249,6 +262,8 @@ export default { RightArrowIcon, LeftArrowIcon, ExternalIcon, + ExpandIcon, + ContractIcon, }, auth: false, beforeRouteLeave(to, from, next) { @@ -278,6 +293,7 @@ export default { deleteGalleryUrls: [], expandedGalleryItem: null, expandedGalleryIndex: 0, + zoomedIn: false, } }, fetch() { @@ -404,6 +420,7 @@ export default { expandImage(item, index) { this.expandedGalleryItem = item this.expandedGalleryIndex = index + this.zoomedIn = false }, }, } @@ -466,37 +483,69 @@ export default { } .image { - object-fit: cover; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); - width: auto; - height: calc(100vh - 2 * var(--spacing-card-lg)); max-width: calc(100vw - 2 * var(--spacing-card-lg)); + max-height: calc(100vh - 2 * var(--spacing-card-lg)); border-radius: var(--size-rounded-card); - } + &.zoomed-in { + object-fit: cover; + width: auto; + height: calc(100vh - 2 * var(--spacing-card-lg)); + max-width: calc(100vw - 2 * var(--spacing-card-lg)); + } + } .floating { position: absolute; left: 50%; - transform: translate(-50%, 0); + transform: translateX(-50%); bottom: var(--spacing-card-md); display: flex; flex-direction: column; align-items: center; gap: var(--spacing-card-sm); + transition: opacity 0.25s ease-in-out; + opacity: 1; + padding: 2rem 2rem 0 2rem; + + &:not(&:hover) { + opacity: 0.4; + .text { + transform: translateY(2.5rem) scale(0.8); + opacity: 0; + } + .controls { + transform: translateY(0.25rem) scale(0.9); + } + } - h2 { - margin-bottom: 0.25rem; - font-size: 1.25rem; + .text { + display: flex; + flex-direction: column; + max-width: 40rem; + transition: opacity 0.25s ease-in-out, transform 0.25s ease-in-out; text-shadow: 1px 1px 10px #000000d4; - text-align: center; + margin-bottom: 0.25rem; + gap: 0.5rem; + + h2 { + font-size: 1.25rem; + text-align: center; + margin: 0; + } + + p { + margin: 0; + } } .controls { background-color: var(--color-raised-bg); padding: var(--spacing-card-md); border-radius: var(--size-rounded-card); + transition: opacity 0.25s ease-in-out, transform 0.25s ease-in-out; } } }