diff --git a/frontend/fresh.gen.ts b/frontend/fresh.gen.ts index cfeec90..1506b7f 100644 --- a/frontend/fresh.gen.ts +++ b/frontend/fresh.gen.ts @@ -15,6 +15,7 @@ import * as $projects_index from "./routes/projects/index.tsx"; import * as $rss_index from "./routes/rss/index.tsx"; import * as $sitemap_index from "./routes/sitemap/index.tsx"; import * as $Counter from "./islands/Counter.tsx"; +import * as $ImageCarousel from "./islands/ImageCarousel.tsx"; import * as $Portal from "./islands/Portal.tsx"; import * as $ProjectCard from "./islands/ProjectCard.tsx"; import * as $ProjectModal from "./islands/ProjectModal.tsx"; @@ -37,6 +38,7 @@ const manifest = { }, islands: { "./islands/Counter.tsx": $Counter, + "./islands/ImageCarousel.tsx": $ImageCarousel, "./islands/Portal.tsx": $Portal, "./islands/ProjectCard.tsx": $ProjectCard, "./islands/ProjectModal.tsx": $ProjectModal, diff --git a/frontend/islands/ImageCarousel.tsx b/frontend/islands/ImageCarousel.tsx new file mode 100644 index 0000000..2304854 --- /dev/null +++ b/frontend/islands/ImageCarousel.tsx @@ -0,0 +1,82 @@ +import { useState } from "preact/hooks"; + +export const ImageCarousel = function ImageCarousel(props: ImageCarouselProps) { + const [currentImageIndex, setCurrentImageIndex] = useState(0); + + const nextImage = (e: Event) => { + e.stopPropagation(); + if (props.images && props.images?.length > 0) { + const localImage = props.images; + setCurrentImageIndex((prev) => (prev + 1) % localImage.length || 0); + } + }; + + const prevImage = (e: Event) => { + e.stopPropagation(); + if (props.images && props.images.length > 0) { + const localImage = props.images; + setCurrentImageIndex( + (prev) => (prev - 1 + localImage.length) % localImage.length, + ); + } + }; + + return ( +
{props.description}
@@ -90,4 +95,5 @@ type ProjectProps = { description?: string; tech: string; wip?: boolean; + images?: string[]; }; diff --git a/frontend/islands/ProjectModal.tsx b/frontend/islands/ProjectModal.tsx index c64788c..62c31aa 100644 --- a/frontend/islands/ProjectModal.tsx +++ b/frontend/islands/ProjectModal.tsx @@ -1,8 +1,11 @@ import { useEffect, useRef, useState } from "preact/hooks"; import type { ComponentChildren } from "preact"; +import * as hi from "jsr:@preact-icons/hi2"; export type ModalAction = { label: string; + // deno-lint-ignore no-explicit-any + icon?: any; onClick: () => void; variant?: "primary" | "secondary" | "link"; }; @@ -62,6 +65,7 @@ export const ProjectModal = function ProjectModal({ ...actions, { label: "Close", + icon: