11<template >
22 <div id =" defaultModal" tabindex =" -1" aria-hidden =" true"
3- class =" fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-modal md:h-full backdrop-blur-lg bg-white/30" >
3+ class =" fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-modal md:h-full backdrop-blur-lg bg-white/30 dark:bg-black/70 " >
44 <div class =" relative mx-auto top-50 w-full h-full max-w-5xl md:h-auto " >
55 <div class =" absolute top-0 right-0 z-50 p-4" >
66 <button @click =" toggleModal" >
77 <carbon-close class =" text-4xl text-white hover:text-white-500 hover:text-5xl ease-in duration-100"
88 aria-hidden =" true" />
99 </button >
1010 </div >
11+ <!-- Left and Right image buttons -->
12+ <div class =" absolute bottom-0 left-0 z-50 p-4" >
13+ <button @click =" prev" >
14+ <carbon-chevron-left
15+ class =" text-4xl text-white hover:text-white-500 hover:text-5xl ease-in duration-100"
16+ aria-hidden =" true" />
17+ </button >
18+
19+ </div >
20+
21+ <div class =" absolute bottom-0 right-0 z-50 p-4" >
22+ <button @click =" next" >
23+ <carbon-chevron-right
24+ class =" text-4xl text-white hover:text-white-500 hover:text-5xl ease-in duration-100"
25+ aria-hidden =" true" />
26+ </button >
27+ </div >
28+
1129 <div class =" relative w-full h-full" >
1230 <img :src =" image" class =" object-cover" />
1331 </div >
@@ -25,6 +43,14 @@ export default {
2543 type: String ,
2644 required: true ,
2745 },
46+ prev: {
47+ type: Function ,
48+ required: true ,
49+ },
50+ next: {
51+ type: Function ,
52+ required: true ,
53+ },
2854 },
2955 setup (props ) {
3056 // toggle modal
@@ -47,9 +73,20 @@ export default {
4773 }
4874 };
4975
76+ // shift to next image on right arrow key
77+ const imageShift = (e ) => {
78+ if (e .key === ' ArrowRight' ) {
79+ props .next ();
80+ } else if (e .key === ' ArrowLeft' ) {
81+ props .prev ();
82+ }
83+ };
84+
5085 // add event listeners
5186 window .addEventListener (' keydown' , closeModal);
5287 window .addEventListener (' click' , closeOnClick);
88+ window .addEventListener (' keydown' , imageShift);
89+
5390
5491 // remove event listeners
5592 onBeforeUnmount (() => {
0 commit comments