Skip to content

Commit 100ac01

Browse files
committed
Merge branch 'preview'
2 parents fb32e3b + 47cc473 commit 100ac01

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

src/components/dataDisplay/gallery/Gallery.tsx

+37-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import * as Dialog from "@radix-ui/react-dialog";
44
import { KeyboardEvent, useState, useEffect, useCallback } from "react";
55
import Button from "@/components/actions/button/Button";
66
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";
812

913
interface Props {
1014
images: AppBskyEmbedImages.ViewImage[] | string;
@@ -46,6 +50,15 @@ export default function Gallery(props: Props) {
4650
[handleBackward, handleForward],
4751
);
4852

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+
4962
useEffect(() => {
5063
window.addEventListener("keydown", handleKeyboard);
5164

@@ -63,15 +76,28 @@ export default function Gallery(props: Props) {
6376
}}
6477
className="z-50 w-full"
6578
>
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 */}
75101
{imageCount > 1 && currentIndex > 0 && (
76102
<Button
77103
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) {
95121
</Button>
96122
)}
97123

124+
{/* Image Display */}
98125
{Array.isArray(images) && (
99126
<Image
100127
src={images[currentIndex].fullsize}

0 commit comments

Comments
 (0)