You've already forked AstralRinth
forked from didirus/AstralRinth
Gallery improvements (#404)
* Redo gallery controls
* Remove old css
* Geo's fixes to the gallery
* Fix filters not updating when clearing them
* Add max width to expanded images
* Center text as it gets super long
* Object-fit: cover
* Fix extra margin 😱
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
@click="
|
@click="
|
||||||
selectedLoader = getDefaultLoader()
|
selectedLoader = getDefaultLoader()
|
||||||
selectedGameVersions = []
|
selectedGameVersions = []
|
||||||
|
updateVersionFilters()
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<CrossIcon />
|
<CrossIcon />
|
||||||
|
|||||||
@@ -6,10 +6,6 @@
|
|||||||
@click="expandedGalleryItem = null"
|
@click="expandedGalleryItem = null"
|
||||||
>
|
>
|
||||||
<div class="content" @click.stop="">
|
<div class="content" @click.stop="">
|
||||||
<button class="close circle-button" @click="expandedGalleryItem = null">
|
|
||||||
<CrossIcon aria-hidden="true" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="image"
|
class="image"
|
||||||
:src="
|
:src="
|
||||||
@@ -24,23 +20,36 @@
|
|||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="floating">
|
||||||
<div class="description">
|
<h2 v-if="expandedGalleryItem.title">
|
||||||
<h2 v-if="expandedGalleryItem.title">
|
{{ expandedGalleryItem.title }}
|
||||||
{{ expandedGalleryItem.title }}
|
</h2>
|
||||||
</h2>
|
<div class="controls">
|
||||||
<p v-if="expandedGalleryItem.description">
|
<div v-if="gallery.length > 1" class="buttons">
|
||||||
{{ expandedGalleryItem.description }}
|
<button
|
||||||
</p>
|
class="close circle-button"
|
||||||
</div>
|
@click="expandedGalleryItem = null"
|
||||||
|
>
|
||||||
<div v-if="gallery.length > 1" class="buttons">
|
<CrossIcon aria-hidden="true" />
|
||||||
<button class="previous circle-button" @click="previousImage()">
|
</button>
|
||||||
<LeftArrowIcon aria-hidden="true" />
|
<a
|
||||||
</button>
|
class="open circle-button"
|
||||||
<button class="next circle-button" @click="nextImage()">
|
target="_blank"
|
||||||
<RightArrowIcon aria-hidden="true" />
|
:href="
|
||||||
</button>
|
expandedGalleryItem.url
|
||||||
|
? expandedGalleryItem.url
|
||||||
|
: 'https://cdn.modrinth.com/placeholder-banner.svg'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<ExternalIcon aria-hidden="true" />
|
||||||
|
</a>
|
||||||
|
<button class="previous circle-button" @click="previousImage()">
|
||||||
|
<LeftArrowIcon aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button class="next circle-button" @click="nextImage()">
|
||||||
|
<RightArrowIcon aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -222,6 +231,7 @@ import RightArrowIcon from '~/assets/images/utils/right-arrow.svg?inline'
|
|||||||
import LeftArrowIcon from '~/assets/images/utils/left-arrow.svg?inline'
|
import LeftArrowIcon from '~/assets/images/utils/left-arrow.svg?inline'
|
||||||
import EditIcon from '~/assets/images/utils/edit.svg?inline'
|
import EditIcon from '~/assets/images/utils/edit.svg?inline'
|
||||||
import CheckIcon from '~/assets/images/utils/check.svg?inline'
|
import CheckIcon from '~/assets/images/utils/check.svg?inline'
|
||||||
|
import ExternalIcon from '~/assets/images/utils/external.svg?inline'
|
||||||
|
|
||||||
import SmartFileInput from '~/components/ui/SmartFileInput'
|
import SmartFileInput from '~/components/ui/SmartFileInput'
|
||||||
import Checkbox from '~/components/ui/Checkbox'
|
import Checkbox from '~/components/ui/Checkbox'
|
||||||
@@ -238,6 +248,7 @@ export default {
|
|||||||
CrossIcon,
|
CrossIcon,
|
||||||
RightArrowIcon,
|
RightArrowIcon,
|
||||||
LeftArrowIcon,
|
LeftArrowIcon,
|
||||||
|
ExternalIcon,
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
beforeRouteLeave(to, from, next) {
|
beforeRouteLeave(to, from, next) {
|
||||||
@@ -272,6 +283,22 @@ export default {
|
|||||||
fetch() {
|
fetch() {
|
||||||
this.gallery = JSON.parse(JSON.stringify(this.project.gallery))
|
this.gallery = JSON.parse(JSON.stringify(this.project.gallery))
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this._keyListener = function (e) {
|
||||||
|
if (this.expandedGalleryItem) {
|
||||||
|
e.preventDefault()
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
this.expandedGalleryItem = null
|
||||||
|
} else if (e.key === 'ArrowLeft') {
|
||||||
|
this.previousImage()
|
||||||
|
} else if (e.key === 'ArrowRight') {
|
||||||
|
this.nextImage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('keydown', this._keyListener.bind(this))
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showPreviewImage(files, index) {
|
showPreviewImage(files, index) {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
@@ -399,44 +426,24 @@ export default {
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: auto;
|
width: calc(100vw - 2 * var(--spacing-card-lg));
|
||||||
height: auto;
|
height: calc(100vh - 2 * var(--spacing-card-lg));
|
||||||
max-height: 96vh;
|
|
||||||
max-width: 96vw;
|
|
||||||
background-color: var(--color-raised-bg);
|
|
||||||
overflow: auto;
|
|
||||||
border-radius: var(--size-rounded-card);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.close {
|
|
||||||
position: absolute;
|
|
||||||
top: 0.5rem;
|
|
||||||
right: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.next {
|
|
||||||
top: 20rem;
|
|
||||||
right: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.previous {
|
|
||||||
top: 20rem;
|
|
||||||
left: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.circle-button {
|
.circle-button {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
max-width: 2rem;
|
max-width: 2rem;
|
||||||
background-color: var(--color-raised-bg);
|
background-color: var(--color-button-bg);
|
||||||
border-radius: var(--size-rounded-max);
|
border-radius: var(--size-rounded-max);
|
||||||
margin: 0 0.5rem 0 0;
|
margin: 0;
|
||||||
box-shadow: inset 0px -1px 1px rgb(17 24 39 / 10%);
|
box-shadow: inset 0px -1px 1px rgb(17 24 39 / 10%);
|
||||||
|
|
||||||
&:hover,
|
&:not(:last-child) {
|
||||||
&:active {
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
background-color: var(--color-button-bg-hover) !important;
|
background-color: var(--color-button-bg-hover) !important;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@@ -444,6 +451,14 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: var(--color-button-bg-active) !important;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
color: var(--color-button-text-active) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
@@ -451,40 +466,37 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
object-fit: contain;
|
object-fit: cover;
|
||||||
max-height: 80vh;
|
position: absolute;
|
||||||
max-width: 80vw;
|
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));
|
||||||
|
border-radius: var(--size-rounded-card);
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.floating {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
bottom: var(--spacing-card-md);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: column;
|
||||||
margin: 0.5rem 0.75rem 0.75rem 0.75rem;
|
align-items: center;
|
||||||
|
gap: var(--spacing-card-sm);
|
||||||
|
|
||||||
.buttons {
|
h2 {
|
||||||
display: flex;
|
margin-bottom: 0.25rem;
|
||||||
flex-direction: row;
|
font-size: 1.25rem;
|
||||||
flex-grow: 0;
|
text-shadow: 1px 1px 10px #000000d4;
|
||||||
align-items: center;
|
text-align: center;
|
||||||
|
|
||||||
.circle-button {
|
|
||||||
background-color: var(--color-button-bg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
.controls {
|
||||||
.description {
|
background-color: var(--color-raised-bg);
|
||||||
flex-grow: 1;
|
padding: var(--spacing-card-md);
|
||||||
width: min-content;
|
border-radius: var(--size-rounded-card);
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
font-size: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user