waveterm/frontend/app/element/avatar.tsx
Evan Simkowitz 2e91ee843c
Switch from Less to Scss (#1335)
Less hasn't received an update in over a year and the parser is missing
some modern syntax like relative colors so this switches us to scss
2024-11-21 16:05:04 -08:00

37 lines
1.0 KiB
TypeScript

// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import { memo } from "react";
import clsx from "clsx";
import "./avatar.scss";
interface AvatarProps {
name: string;
status: "online" | "offline" | "busy" | "away";
className?: string;
imageUrl?: string;
}
const Avatar = memo(({ name, status = "offline", className, imageUrl }: AvatarProps) => {
const getInitials = (name: string) => {
const nameParts = name.split(" ");
const initials = nameParts.map((part) => part[0]).join("");
return initials.toUpperCase();
};
return (
<div className={clsx("avatar", status, className)} title="status">
{imageUrl ? (
<img src={imageUrl} alt={`${name}'s avatar`} className="avatar-image" />
) : (
<div className="avatar-initials">{getInitials(name)}</div>
)}
<div className={`status-indicator ${status}`} />
</div>
);
});
Avatar.displayName = "Avatar";
export { Avatar };