Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Add image description, make controls less obtrusive, display native s…
Browse files Browse the repository at this point in the history
…ize by default (Fixes #407), Fixed closing modal by clicking out of it (Fixes #405) (#412)
  • Loading branch information
Prospector authored Mar 16, 2022
1 parent 1a23b61 commit 5ebaf56
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 13 deletions.
1 change: 1 addition & 0 deletions assets/images/utils/contract.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/utils/expand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 62 additions & 13 deletions pages/_type/_id/gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
class="expanded-image-modal"
@click="expandedGalleryItem = null"
>
<div class="content" @click.stop="">
<div class="content">
<img
class="image"
:class="{ 'zoomed-in': zoomedIn }"
:src="
expandedGalleryItem.url
? expandedGalleryItem.url
Expand All @@ -18,12 +19,18 @@
? expandedGalleryItem.title
: 'gallery-image'
"
@click.stop=""
/>

<div class="floating">
<h2 v-if="expandedGalleryItem.title">
{{ expandedGalleryItem.title }}
</h2>
<div class="text">
<h2 v-if="expandedGalleryItem.title">
{{ expandedGalleryItem.title }}
</h2>
<p v-if="expandedGalleryItem.description">
{{ expandedGalleryItem.description }}
</p>
</div>
<div class="controls">
<div v-if="gallery.length > 1" class="buttons">
<button
Expand All @@ -43,6 +50,10 @@
>
<ExternalIcon aria-hidden="true" />
</a>
<button class="circle-button" @click="zoomedIn = !zoomedIn">
<ExpandIcon v-if="!zoomedIn" aria-hidden="true" />
<ContractIcon v-else aria-hidden="true" />
</button>
<button class="previous circle-button" @click="previousImage()">
<LeftArrowIcon aria-hidden="true" />
</button>
Expand Down Expand Up @@ -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'
Expand All @@ -249,6 +262,8 @@ export default {
RightArrowIcon,
LeftArrowIcon,
ExternalIcon,
ExpandIcon,
ContractIcon,
},
auth: false,
beforeRouteLeave(to, from, next) {
Expand Down Expand Up @@ -278,6 +293,7 @@ export default {
deleteGalleryUrls: [],
expandedGalleryItem: null,
expandedGalleryIndex: 0,
zoomedIn: false,
}
},
fetch() {
Expand Down Expand Up @@ -404,6 +420,7 @@ export default {
expandImage(item, index) {
this.expandedGalleryItem = item
this.expandedGalleryIndex = index
this.zoomedIn = false
},
},
}
Expand Down Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 5ebaf56

Please sign in to comment.