mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
2e91ee843c
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
37 lines
1.0 KiB
TypeScript
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 };
|