From 0712a629a9934f1b614f7a2e64d340f1a0487a21 Mon Sep 17 00:00:00 2001 From: rocketdebris Date: Wed, 27 May 2026 08:47:53 -0400 Subject: [PATCH] Typescript support --- app/api/{picsum.js => picsum.ts} | 11 ++++++++++- app/ligonier/control_bar.tsx | 9 +++++++-- app/ligonier/header.tsx | 4 +++- app/ligonier/photo_card.tsx | 4 +++- app/ligonier/photo_gallery.tsx | 19 +++++++++++++++++-- 5 files changed, 40 insertions(+), 7 deletions(-) rename app/api/{picsum.js => picsum.ts} (57%) diff --git a/app/api/picsum.js b/app/api/picsum.ts similarity index 57% rename from app/api/picsum.js rename to app/api/picsum.ts index 937d0e7..4ba11f1 100644 --- a/app/api/picsum.js +++ b/app/api/picsum.ts @@ -1,10 +1,19 @@ +export interface PicsumData { + id: number, + author: string, + width: number, + height: number, + url: string, + download_url: string +} + export async function getPicsumData() { try { const response = await fetch('https://picsum.photos/v2/list'); if (!response.ok) { throw new Error('Picsum API unavailable.'); } - const data = await response.json(); + const data: PicsumData[] = await response.json(); return data; } catch (error) { console.error("Could not fetch data:", error); diff --git a/app/ligonier/control_bar.tsx b/app/ligonier/control_bar.tsx index ff5d942..8acccfe 100644 --- a/app/ligonier/control_bar.tsx +++ b/app/ligonier/control_bar.tsx @@ -1,6 +1,11 @@ -import { useState } from 'react'; +import type { MouseEvent } from "react"; -export function ControlBar({ isGallery, handleClick }) { +export interface ControlBarProps { + isGallery: boolean; + handleClick: React.MouseEventHandler; +} + +export function ControlBar({ isGallery, handleClick }: ControlBarProps ) { return(
+ ); +} + +function Photos({ imageData, isGallery }: PhotosProps) { const listClassNames = "flex flex-wrap" const galleryClassNames = "grid md:grid-cols-2 xl:grid-cols-3" const photoCards = imageData.map(image =>