The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix favicon bluriness
Karan Handade99e5434180
diff --git a/apps/web/ui/layout/project-select.tsx b/apps/web/ui/layout/project-select.tsxindex f048c5e408..0f7716a445 100644--- a/apps/web/ui/layout/project-select.tsx+++ b/apps/web/ui/layout/project-select.tsx@@ -11,6 +11,7 @@ import Link from "next/link";import { useParams, usePathname } from "next/navigation";import { useCallback, useContext, useMemo, useState } from "react";import useProjects from "@/lib/swr/use-projects";+import { BlurImage } from "../shared/blur-image";export default function ProjectSelect() {const { projects } = useProjects();@@ -76,7 +77,9 @@ export default function ProjectSelect() {className="flex items-center justify-between rounded-lg bg-white p-1.5 text-left text-sm transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200"><div className="flex items-center space-x-3 pr-2">- <img+ <BlurImage+ height={20}+ width={20}src={selected.image}referrerPolicy="no-referrer"alt={selected.id || selected.name}diff --git a/apps/web/ui/shared/blur-image.tsx b/apps/web/ui/shared/blur-image.tsxindex 8dde0d2d0d..e9e8d995aa 100644--- a/apps/web/ui/shared/blur-image.tsx+++ b/apps/web/ui/shared/blur-image.tsx@@ -9,15 +9,21 @@ export function BlurImage(props: ImageProps) {const [src, setSrc] = useState(props.src);useEffect(() => setSrc(props.src), [props.src]); // update the `src` value when the `prop.src` value changes+ const handleLoad = (e) => {+ setLoading(false);+ const target = e.target as HTMLImageElement;+ if (target.naturalWidth < 20 && target.naturalHeight < 20) {+ setSrc(`https://avatar.vercel.sh/${props.alt}`);+ }+ };+return (<Image{...props}src={src}alt={props.alt}className={cn(loading ? "blur-[2px]" : "blur-0", props.className)}- onLoad={async () => {- setLoading(false);- }}+ onLoad={handleLoad}onError={() => {setSrc(`https://avatar.vercel.sh/${props.alt}`); // if the image fails to load, use the default avatar}}