66 @click =" expandedGalleryItem = null"
77 >
88 <div class =" content" @click.stop =" " >
9- <button class =" close circle-button" @click =" expandedGalleryItem = null" >
10- <CrossIcon aria-hidden =" true" />
11- </button >
12-
139 <img
1410 class =" image"
1511 :src ="
2420 "
2521 />
2622
27- <div class =" footer" >
28- <div class =" description" >
29- <h2 v-if =" expandedGalleryItem.title" >
30- {{ expandedGalleryItem.title }}
31- </h2 >
32- <p v-if =" expandedGalleryItem.description" >
33- {{ expandedGalleryItem.description }}
34- </p >
35- </div >
36-
37- <div v-if =" gallery.length > 1" class =" buttons" >
38- <button class =" previous circle-button" @click =" previousImage()" >
39- <LeftArrowIcon aria-hidden =" true" />
40- </button >
41- <button class =" next circle-button" @click =" nextImage()" >
42- <RightArrowIcon aria-hidden =" true" />
43- </button >
23+ <div class =" floating" >
24+ <h2 v-if =" expandedGalleryItem.title" >
25+ {{ expandedGalleryItem.title }}
26+ </h2 >
27+ <div class =" controls" >
28+ <div v-if =" gallery.length > 1" class =" buttons" >
29+ <button
30+ class =" close circle-button"
31+ @click =" expandedGalleryItem = null"
32+ >
33+ <CrossIcon aria-hidden =" true" />
34+ </button >
35+ <a
36+ class =" open circle-button"
37+ target =" _blank"
38+ :href ="
39+ expandedGalleryItem.url
40+ ? expandedGalleryItem.url
41+ : 'https://cdn.modrinth.com/placeholder-banner.svg'
42+ "
43+ >
44+ <ExternalIcon aria-hidden =" true" />
45+ </a >
46+ <button class =" previous circle-button" @click =" previousImage()" >
47+ <LeftArrowIcon aria-hidden =" true" />
48+ </button >
49+ <button class =" next circle-button" @click =" nextImage()" >
50+ <RightArrowIcon aria-hidden =" true" />
51+ </button >
52+ </div >
4453 </div >
4554 </div >
4655 </div >
@@ -222,6 +231,7 @@ import RightArrowIcon from '~/assets/images/utils/right-arrow.svg?inline'
222231import LeftArrowIcon from ' ~/assets/images/utils/left-arrow.svg?inline'
223232import EditIcon from ' ~/assets/images/utils/edit.svg?inline'
224233import CheckIcon from ' ~/assets/images/utils/check.svg?inline'
234+ import ExternalIcon from ' ~/assets/images/utils/external.svg?inline'
225235
226236import SmartFileInput from ' ~/components/ui/SmartFileInput'
227237import Checkbox from ' ~/components/ui/Checkbox'
@@ -238,6 +248,7 @@ export default {
238248 CrossIcon,
239249 RightArrowIcon,
240250 LeftArrowIcon,
251+ ExternalIcon,
241252 },
242253 auth: false ,
243254 beforeRouteLeave (to , from , next ) {
@@ -272,6 +283,22 @@ export default {
272283 fetch () {
273284 this .gallery = JSON .parse (JSON .stringify (this .project .gallery ))
274285 },
286+ mounted () {
287+ this ._keyListener = function (e ) {
288+ if (this .expandedGalleryItem ) {
289+ e .preventDefault ()
290+ if (e .key === ' Escape' ) {
291+ this .expandedGalleryItem = null
292+ } else if (e .key === ' ArrowLeft' ) {
293+ this .previousImage ()
294+ } else if (e .key === ' ArrowRight' ) {
295+ this .nextImage ()
296+ }
297+ }
298+ }
299+
300+ document .addEventListener (' keydown' , this ._keyListener .bind (this ))
301+ },
275302 methods: {
276303 showPreviewImage (files , index ) {
277304 const reader = new FileReader ()
@@ -399,92 +426,77 @@ export default {
399426
400427 .content {
401428 position : relative ;
402- width : auto ;
403- height : auto ;
404- max-height : 96vh ;
405- max-width : 96vw ;
406- background-color : var (--color-raised-bg );
407- overflow : auto ;
408- border-radius : var (--size-rounded-card );
409- display : flex ;
410- flex-direction : column ;
411-
412- .close {
413- position : absolute ;
414- top : 0.5rem ;
415- right : 0.5rem ;
416- }
417-
418- .next {
419- top : 20rem ;
420- right : 0.5rem ;
421- }
422-
423- .previous {
424- top : 20rem ;
425- left : 0.5rem ;
426- }
429+ width : calc (100vw - 2 * var (--spacing-card-lg ));
430+ height : calc (100vh - 2 * var (--spacing-card-lg ));
427431
428432 .circle-button {
429433 padding : 0.5rem ;
430434 line-height : 1 ;
431435 display : flex ;
432436 max-width : 2rem ;
433- background-color : var (--color-raised -bg );
437+ background-color : var (--color-button -bg );
434438 border-radius : var (--size-rounded-max );
435- margin : 0 0.5 rem 0 0 ;
439+ margin : 0 ;
436440 box-shadow : inset 0px -1px 1px rgb (17 24 39 / 10% );
437441
438- & :hover ,
439- & :active {
442+ & :not (:last-child ) {
443+ margin-right : 0.5rem ;
444+ }
445+
446+ & :hover {
440447 background-color : var (--color-button-bg-hover ) !important ;
441448
442449 svg {
443450 color : var (--color-button-text-hover ) !important ;
444451 }
445452 }
446453
454+ & :active {
455+ background-color : var (--color-button-bg-active ) !important ;
456+
457+ svg {
458+ color : var (--color-button-text-active ) !important ;
459+ }
460+ }
461+
447462 svg {
448463 height : 1rem ;
449464 width : 1rem ;
450465 }
451466 }
452467
453468 .image {
454- object-fit : contain ;
455- max-height : 80vh ;
456- max-width : 80vw ;
469+ object-fit : cover ;
470+ position : absolute ;
471+ left : 50% ;
472+ top : 50% ;
473+ transform : translate (-50% , -50% );
474+ width : auto ;
475+ height : calc (100vh - 2 * var (--spacing-card-lg ));
476+ max-width : calc (100vw - 2 * var (--spacing-card-lg ));
477+ border-radius : var (--size-rounded-card );
457478 }
458479
459- .footer {
480+ .floating {
481+ position : absolute ;
482+ left : 50% ;
483+ transform : translate (-50% , 0 );
484+ bottom : var (--spacing-card-md );
460485 display : flex ;
461- flex-direction : row ;
462- margin : 0.5rem 0.75rem 0.75rem 0.75rem ;
463-
464- .buttons {
465- display : flex ;
466- flex-direction : row ;
467- flex-grow : 0 ;
468- align-items : center ;
486+ flex-direction : column ;
487+ align-items : center ;
488+ gap : var (--spacing-card-sm );
469489
470- .circle-button {
471- background-color : var (--color-button-bg );
472- }
490+ h2 {
491+ margin-bottom : 0.25rem ;
492+ font-size : 1.25rem ;
493+ text-shadow : 1px 1px 10px #000000d4 ;
494+ text-align : center ;
473495 }
474-
475- .description {
476- flex-grow : 1 ;
477- width : min-content ;
478-
479- h2 {
480- margin-bottom : 0.25rem ;
481- font-size : 1.25rem ;
482- }
483-
484- p {
485- margin : 0 ;
486- font-size : 1rem ;
487- }
496+ .controls {
497+ background-color : var (--color-raised-bg );
498+ padding : var (--spacing-card-md );
499+ border-radius : var (--size-rounded-card );
488500 }
489501 }
490502 }
0 commit comments