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>
This commit is contained in:
Mattias Granlund 2024-09-14 01:20:37 +02:00 committed by GitHub
parent 1a47f5ec4d
commit ba360d2e85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -16,7 +16,7 @@
</script>
<Tooltip text={tooltip} align={tooltipAlign} position={tooltipPosition}>
<div class="image-wrapper {size}" style:background-color={stringToColor(tooltip)}>
<div class="image-wrapper {size}" style:background-color={stringToColor(srcUrl)}>
<img
class="avatar"
alt={tooltip}

View File

@ -18,5 +18,6 @@ export function stringToColor(name: string | undefined) {
}
const startHash = trimmed.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
return colors[startHash % colors.length];
}