Skip to content

Commit

Permalink
[front] image を設定していない時もuserlist にavatar (profile + online status) が表…
Browse files Browse the repository at this point in the history
…示される (#284)
  • Loading branch information
kotto5 authored Feb 26, 2024
1 parent 3cd525d commit b921be0
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions frontend/app/ui/user/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ export function Avatar({ avatarURL, size, href, alt, id }: Props) {
const onlineStatuses = useContext(OnlineContext);
const online = id ? onlineStatuses[id] : false;
let sizeClass = "";
if (!avatarURL) {
return <Skeleton className={`flex-none rounded-full ${sizeClass}`} />;
}
let onlineStatusClass = online ? "bg-green-500 " : "bg-gray-500 ";
switch (size) {
case "small":
Expand All @@ -45,9 +42,17 @@ export function Avatar({ avatarURL, size, href, alt, id }: Props) {
default:
throw new Error("Invalid size");
}
if (!avatarURL) {
return <Skeleton className={`flex-none rounded-full ${sizeClass}`} />;
}
const icon = avatarURL ? (
<img
className={`rounded-full object-cover ${sizeClass}`}
src={avatarURL}
alt={alt}
/>
) : (
<div>
<Skeleton className={`flex-none rounded-full ${sizeClass}`} />
</div>
);
const TooltipWrapper = ({ children }: { children: React.ReactNode }) =>
alt !== undefined ? (
<Tooltip>
Expand All @@ -63,13 +68,7 @@ export function Avatar({ avatarURL, size, href, alt, id }: Props) {
<LinkWrapper>
<div className={`relative flex-none ${sizeClass}`}>
<TooltipProvider delayDuration={0}>
<TooltipWrapper>
<img
className={`rounded-full object-cover ${sizeClass}`}
src={avatarURL}
alt={alt}
/>
</TooltipWrapper>
<TooltipWrapper>{icon}</TooltipWrapper>
<Tooltip>
<TooltipTrigger asChild>
<div
Expand Down

0 comments on commit b921be0

Please sign in to comment.