diff --git a/apps/dashboard/src/@/components/blocks/Img.tsx b/apps/dashboard/src/@/components/blocks/Img.tsx index 89a0c4ba125..765d284b8b6 100644 --- a/apps/dashboard/src/@/components/blocks/Img.tsx +++ b/apps/dashboard/src/@/components/blocks/Img.tsx @@ -1,6 +1,7 @@ /* eslint-disable @next/next/no-img-element */ "use client"; -import { useState } from "react"; +import { useRef, useState } from "react"; +import { useIsomorphicLayoutEffect } from "../../lib/useIsomorphicLayoutEffect"; import { cn } from "../../lib/utils"; type imgElementProps = React.DetailedHTMLProps< @@ -25,19 +26,39 @@ export function Img(props: imgElementProps) { const { className, fallback, skeleton, ...restProps } = props; const defaultSkeleton =
; const defaultFallback =
; + const imgRef = useRef(null); + + useIsomorphicLayoutEffect(() => { + const imgEl = imgRef.current; + if (!imgEl) { + return; + } + if (imgEl.complete) { + setStatus("loaded"); + } else { + function handleLoad() { + setStatus("loaded"); + } + imgEl.addEventListener("load", handleLoad); + return () => { + imgEl.removeEventListener("load", handleLoad); + }; + } + }, []); return (
{ - setStatus("loaded"); - }} + // avoid setting empty src string to prevent request to the entire page + src={restProps.src || undefined} + ref={imgRef} onError={() => { setStatus("fallback"); }} style={{ opacity: status === "loaded" ? 1 : 0, + ...restProps.style, }} alt={restProps.alt || ""} className={cn( @@ -48,6 +69,7 @@ export function Img(props: imgElementProps) { {status !== "loaded" && (
*]:h-full [&>*]:w-full", className, diff --git a/apps/dashboard/src/components/contract-components/publisher/publisher-header.tsx b/apps/dashboard/src/components/contract-components/publisher/publisher-header.tsx index 6408472c68f..8613ef9245c 100644 --- a/apps/dashboard/src/components/contract-components/publisher/publisher-header.tsx +++ b/apps/dashboard/src/components/contract-components/publisher/publisher-header.tsx @@ -54,7 +54,7 @@ export const PublisherHeader: React.FC = ({ > diff --git a/apps/dashboard/src/components/explore/publisher/index.tsx b/apps/dashboard/src/components/explore/publisher/index.tsx index a41fe479604..8483ce39796 100644 --- a/apps/dashboard/src/components/explore/publisher/index.tsx +++ b/apps/dashboard/src/components/explore/publisher/index.tsx @@ -30,7 +30,7 @@ export const ContractPublisher: React.FC = async ({ > diff --git a/apps/dashboard/src/components/hackathon/Judges.tsx b/apps/dashboard/src/components/hackathon/Judges.tsx index aefa206ab34..b233232ba41 100644 --- a/apps/dashboard/src/components/hackathon/Judges.tsx +++ b/apps/dashboard/src/components/hackathon/Judges.tsx @@ -35,7 +35,7 @@ export const Judges = ({ TRACKING_CATEGORY }: JudgesProps) => { ]; return ( -
+
Judges { {judges.map((judge) => ( {judge.name} diff --git a/apps/dashboard/src/components/hackathon/JudgesEarn.tsx b/apps/dashboard/src/components/hackathon/JudgesEarn.tsx index 85461780d14..ccb1938bdc1 100644 --- a/apps/dashboard/src/components/hackathon/JudgesEarn.tsx +++ b/apps/dashboard/src/components/hackathon/JudgesEarn.tsx @@ -27,7 +27,7 @@ export const JudgesEarn = () => { ]; return ( -
+
Judges { {judges.map((judge) => ( {judge.name} diff --git a/apps/dashboard/src/pages/community/ambassadors.tsx b/apps/dashboard/src/pages/community/ambassadors.tsx index 60dc763abce..372ae22dbff 100644 --- a/apps/dashboard/src/pages/community/ambassadors.tsx +++ b/apps/dashboard/src/pages/community/ambassadors.tsx @@ -599,7 +599,7 @@ const Ambassadors: ThirdwebNextPage = () => { {ambassador.name} @@ -619,7 +619,7 @@ const Ambassadors: ThirdwebNextPage = () => { > - Ready to + Ready to{" "} { = ({ src, alt, - boxSize = 12, className, }) => { return ( - ( - // eslint-disable-next-line @next/next/no-img-element - {alt - )} /> ); };