navbar UI improved

This commit is contained in:
Daniel
2023-06-07 23:04:50 +03:30
parent 35a8d74943
commit 39abb09002
7 changed files with 35 additions and 70 deletions
+21 -12
View File
@@ -1,5 +1,4 @@
import React from "react";
import ImageWithFallback from "./ImageWithFallback";
import React, { useEffect, useState } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faUser } from "@fortawesome/free-solid-svg-icons";
@@ -9,16 +8,26 @@ type Props = {
};
export default function ProfilePhoto({ src, className }: Props) {
return (
<ImageWithFallback
src={src}
className={`h-10 w-10 shadow rounded-full border-[3px] border-sky-100 ${className}`}
const [error, setError] = useState(false);
useEffect(() => {
console.log(src);
}, []);
return error || !src ? (
<div
className={`bg-sky-500 text-white h-10 w-10 shadow rounded-full border-[3px] border-slate-200 flex items-center justify-center ${className}`}
>
<div
className={`bg-sky-500 text-white h-10 w-10 shadow rounded-full border-[3px] border-sky-100 flex items-center justify-center ${className}`}
>
<FontAwesomeIcon icon={faUser} className="w-5 h-5" />
</div>
</ImageWithFallback>
<FontAwesomeIcon icon={faUser} className="w-5 h-5" />
</div>
) : (
<img
alt=""
src={src}
className={`h-10 w-10 shadow rounded-full border-[3px] border-slate-200 ${className}`}
onError={() => {
setError(true);
}}
/>
);
}