Update avatar to take initials prop and render text as uppercase

This commit is contained in:
Andrew Kingston 2021-05-21 13:16:54 +01:00
parent 05281c83cb
commit 68ed6b6359
1 changed files with 3 additions and 10 deletions

View File

@ -12,15 +12,7 @@
export let size = "M"
export let url = ""
export let disabled = false
export let name = "John Doe"
function getInitials(name) {
let parts = name.split(" ")
if (parts.length > 0) {
return parts.map(name => name[0]).join("")
}
return name
}
export let initials = "JD"
</script>
{#if url}
@ -38,7 +30,7 @@
size
)}); font-size: calc(var({sizes.get(size)}) / 2)"
>
{getInitials(name)}
{initials || ""}
</div>
{/if}
@ -52,5 +44,6 @@
border-radius: 50%;
overflow: hidden;
user-select: none;
text-transform: uppercase;
}
</style>