@@ -4,7 +4,11 @@ import * as Dialog from "@radix-ui/react-dialog";
4
4
import { KeyboardEvent , useState , useEffect , useCallback } from "react" ;
5
5
import Button from "@/components/actions/button/Button" ;
6
6
import { CgClose } from "react-icons/cg" ;
7
- import { BiLeftArrowAlt , BiRightArrowAlt } from "react-icons/bi" ;
7
+ import {
8
+ BiLeftArrowAlt ,
9
+ BiRightArrowAlt ,
10
+ BiSolidCloudDownload ,
11
+ } from "react-icons/bi" ;
8
12
9
13
interface Props {
10
14
images : AppBskyEmbedImages . ViewImage [ ] | string ;
@@ -46,6 +50,15 @@ export default function Gallery(props: Props) {
46
50
[ handleBackward , handleForward ] ,
47
51
) ;
48
52
53
+ const handleSaveImage = ( ) => {
54
+ const imageUrl = Array . isArray ( images )
55
+ ? images [ currentIndex ] . fullsize
56
+ : images ;
57
+ const a = document . createElement ( "a" ) ;
58
+ a . href = imageUrl ;
59
+ a . click ( ) ;
60
+ } ;
61
+
49
62
useEffect ( ( ) => {
50
63
window . addEventListener ( "keydown" , handleKeyboard ) ;
51
64
@@ -63,15 +76,28 @@ export default function Gallery(props: Props) {
63
76
} }
64
77
className = "z-50 w-full"
65
78
>
66
- < Button
67
- className = "text-skin-secondary bg-skin-secondary hover:bg-skin-base hover:text-skin-base fixed left-3 top-3 z-[70] rounded-full p-3.5 border border-skin-base"
68
- onClick = { ( e ) => {
69
- e . stopPropagation ( ) ;
70
- onClose ( ) ;
71
- } }
72
- >
73
- < CgClose className = "text-xl" />
74
- </ Button >
79
+ < div className = "fixed left-3 top-3 z-[70] flex felx-wrap items-center gap-3" >
80
+ < Button
81
+ className = "text-skin-secondary bg-skin-secondary hover:bg-skin-base hover:text-skin-base rounded-full p-3.5 border border-skin-base"
82
+ onClick = { ( e ) => {
83
+ e . stopPropagation ( ) ;
84
+ onClose ( ) ;
85
+ } }
86
+ >
87
+ < CgClose className = "text-xl" />
88
+ </ Button >
89
+ < Button
90
+ className = "gap-2 font-medium text-skin-secondary bg-skin-secondary hover:bg-skin-base hover:text-skin-base rounded-full p-3.5 border border-skin-base"
91
+ onClick = { ( e ) => {
92
+ e . stopPropagation ( ) ;
93
+ handleSaveImage ( ) ;
94
+ } }
95
+ >
96
+ < BiSolidCloudDownload className = "text-xl" />
97
+ </ Button >
98
+ </ div >
99
+
100
+ { /* Navigation Buttons */ }
75
101
{ imageCount > 1 && currentIndex > 0 && (
76
102
< Button
77
103
className = "text-skin-secondary bg-skin-secondary hover:bg-skin-base hover:text-skin-base fixed left-3 top-1/2 z-[70] rounded-full p-3.5 border border-skin-base"
@@ -95,6 +121,7 @@ export default function Gallery(props: Props) {
95
121
</ Button >
96
122
) }
97
123
124
+ { /* Image Display */ }
98
125
{ Array . isArray ( images ) && (
99
126
< Image
100
127
src = { images [ currentIndex ] . fullsize }
0 commit comments