1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Transparent background for custom icons (#3145)

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-06-22 15:30:38 +03:00 committed by GitHub
parent 4096b87f99
commit ad6224ad8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,9 +72,21 @@ function getIconString(title: string) {
export function Avatar(props: Props) {
const { title, width = 32, height = 32, colorHash, children, background, ...settings } = props;
const getBackgroundColor = () => {
if (background) {
return background;
}
if (settings.src) {
return "transparent";
}
return randomColor({ seed: colorHash, luminosity: "dark" });
};
const generateAvatarStyle = (): React.CSSProperties => {
return {
backgroundColor: background || randomColor({ seed: colorHash, luminosity: "dark" }),
backgroundColor: getBackgroundColor(),
width,
height,
textTransform: "uppercase"