Skip to content

Commit ba360d2

Browse files
mtsgrdPavelLaptev
andauthored
Base avatar bg color on srcUrl instead of tooltip (#4903)
* Base avatar bg color on srcUrl instead of tooltip - consistent per author --------- Co-authored-by: Pavel Laptev <pawellaptew@gmail.com>
1 parent 1a47f5e commit ba360d2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

packages/ui/src/lib/avatar/Avatar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</script>
1717

1818
<Tooltip text={tooltip} align={tooltipAlign} position={tooltipPosition}>
19-
<div class="image-wrapper {size}" style:background-color={stringToColor(tooltip)}>
19+
<div class="image-wrapper {size}" style:background-color={stringToColor(srcUrl)}>
2020
<img
2121
class="avatar"
2222
alt={tooltip}

packages/ui/src/lib/utils/stringToColor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ export function stringToColor(name: string | undefined) {
1818
}
1919

2020
const startHash = trimmed.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
21+
2122
return colors[startHash % colors.length];
2223
}

0 commit comments

Comments
 (0)