Skip to content

Commit

Permalink
feat(toolPage): 💄 Add onError for images & background color
Browse files Browse the repository at this point in the history
  • Loading branch information
julianYaman committed May 30, 2022
1 parent 53cf2ec commit 1ed98ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Binary file added assets/ImageNotLoaded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions components/ToolMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Suspense } from "react";
import { FaGithub, FaLink, FaTwitter } from "react-icons/fa";
import EmbeddedSearchbar from "./EmbeddedSearchbar";
import Image from "next/image";
import ImageNotLoaded from "../assets/ImageNotLoaded.png";

export default function ToolMain(props: any) {

Expand Down Expand Up @@ -49,19 +50,20 @@ export default function ToolMain(props: any) {
props.toolData.tool_images.length > 0 ? (
props.toolData.tool_images.map((image: any, index: number) => {
return (
<div key={index} className="flex w-full h-full">
<div key={index} className="flex w-full h-full bg-white/30">
<Image
className="rounded-lg w-full"
src={image.image_link}
layout="fill"
objectFit="contain"
onError={(e: any) => { e.target.src = ImageNotLoaded }}
alt={props.toolData.tool_name}
/>
</div>
)
})
) : (
<div className="flex h-full w-full">
<div className="flex h-full w-full rounded-lg bg-white/30">
<Image
className="rounded-lg"
layout="fill"
Expand All @@ -72,7 +74,7 @@ export default function ToolMain(props: any) {
</div>
)
}
<div className="flex h-full w-full">
<div className="flex h-full w-full rounded-lg bg-white/30">
<Image
className="rounded-lg"
layout="fill"
Expand Down

1 comment on commit 1ed98ba

@vercel
Copy link

@vercel vercel bot commented on 1ed98ba May 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tooldb – ./

tooldb-git-main-julianyaman.vercel.app
tooldb.vercel.app
tooldb-julianyaman.vercel.app
tooldb.dev

Please sign in to comment.