Transparent background for custom icons (#3145)

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev authored and GitHub committed 2021-06-22 15:30:38 +03:00
1 parent 4096b87f99
commit ad6224ad8c
1 file changed
+13 -1
+13 -1
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"