Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelfan committed Nov 28, 2024
2 parents fb32e3b + 47cc473 commit 100ac01
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions src/components/dataDisplay/gallery/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import * as Dialog from "@radix-ui/react-dialog";
import { KeyboardEvent, useState, useEffect, useCallback } from "react";
import Button from "@/components/actions/button/Button";
import { CgClose } from "react-icons/cg";
import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi";
import {
BiLeftArrowAlt,
BiRightArrowAlt,
BiSolidCloudDownload,
} from "react-icons/bi";

interface Props {
images: AppBskyEmbedImages.ViewImage[] | string;
Expand Down Expand Up @@ -46,6 +50,15 @@ export default function Gallery(props: Props) {
[handleBackward, handleForward],
);

const handleSaveImage = () => {
const imageUrl = Array.isArray(images)
? images[currentIndex].fullsize
: images;
const a = document.createElement("a");
a.href = imageUrl;
a.click();
};

useEffect(() => {
window.addEventListener("keydown", handleKeyboard);

Expand All @@ -63,15 +76,28 @@ export default function Gallery(props: Props) {
}}
className="z-50 w-full"
>
<Button
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"
onClick={(e) => {
e.stopPropagation();
onClose();
}}
>
<CgClose className="text-xl" />
</Button>
<div className="fixed left-3 top-3 z-[70] flex felx-wrap items-center gap-3">
<Button
className="text-skin-secondary bg-skin-secondary hover:bg-skin-base hover:text-skin-base rounded-full p-3.5 border border-skin-base"
onClick={(e) => {
e.stopPropagation();
onClose();
}}
>
<CgClose className="text-xl" />
</Button>
<Button
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"
onClick={(e) => {
e.stopPropagation();
handleSaveImage();
}}
>
<BiSolidCloudDownload className="text-xl" />
</Button>
</div>

{/* Navigation Buttons */}
{imageCount > 1 && currentIndex > 0 && (
<Button
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"
Expand All @@ -95,6 +121,7 @@ export default function Gallery(props: Props) {
</Button>
)}

{/* Image Display */}
{Array.isArray(images) && (
<Image
src={images[currentIndex].fullsize}
Expand Down

0 comments on commit 100ac01

Please sign in to comment.