From fb96e9f71ac191846e32eab023fe730f27245711 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 8 Aug 2023 21:55:10 +0200 Subject: [PATCH] feat: some shit --- components/Image.tsx | 33 ++++++++++++++++++++++----------- components/MovieCard.tsx | 5 ++++- components/RecipeHero.tsx | 3 ++- islands/Search.tsx | 7 ++++--- routes/_404.tsx | 4 ++-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/components/Image.tsx b/components/Image.tsx index c965741..ffee9a1 100644 --- a/components/Image.tsx +++ b/components/Image.tsx @@ -1,14 +1,25 @@ -import { isLocalImage } from "@lib/string.ts"; - -export function Image( - props: { class: string; src: string; width?: number; height?: number }, -) { - if (isLocalImage(props.src)) { - } +import * as CSS from "https://esm.sh/csstype@3.1.2"; +const Image = ( + props: { + class: string; + src: string; + alt?: string; + width?: number | string; + height?: number | string; + style?: CSS.HtmlAttributes; + }, +) => { return ( -
- -
+ {props.alt} ); -} +}; + +export default Image; diff --git a/components/MovieCard.tsx b/components/MovieCard.tsx index 5e323c4..3dd8a08 100644 --- a/components/MovieCard.tsx +++ b/components/MovieCard.tsx @@ -1,14 +1,17 @@ import { Card } from "@components/Card.tsx"; import { Movie } from "@lib/resource/movies.ts"; import { Series } from "@lib/resource/series.ts"; +import { isLocalImage } from "@lib/string.ts"; export function MovieCard({ movie }: { movie: Movie }) { const { meta: { image = "/placeholder.svg" } = {} } = movie; - const imageUrl = image?.startsWith("Media/movies/") + const imageUrl = isLocalImage(image) ? `/api/images?image=${image}&width=200&height=200` : image; + console.log({ imageUrl, image }); + return ( {imageUrl && ( - Recipe Banner { useEventListener("keydown", (e: KeyboardEvent) => { @@ -30,7 +31,7 @@ const SearchResultImage = ({ src }: { src: string }) => { : src; return ( - preview image { const [searchQuery, setSearchQuery] = useState(q); @@ -185,4 +186,4 @@ const SearchComponent = ( ); }; -export default SearchComponent; +export default Search; diff --git a/routes/_404.tsx b/routes/_404.tsx index c8228ab..253928c 100644 --- a/routes/_404.tsx +++ b/routes/_404.tsx @@ -1,5 +1,5 @@ - import { Head } from "$fresh/runtime.ts"; +import Image from "@components/Image.tsx"; export default function Error404() { return ( @@ -9,7 +9,7 @@ export default function Error404() {
-