Skip to content

Commit

Permalink
Prevent background bleed when image is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Dec 16, 2023
1 parent b88aeac commit 6fd6d11
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 46 deletions.
70 changes: 36 additions & 34 deletions src/components/UserAvatar.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
<template>
<div class="kiwi-avatar">
<svg v-if="user" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle
v-if="avatar.showBackground"
v-bind="awayStatus.vbind"
r="50%"
cx="50%"
cy="50%"
class="kiwi-avatar-circle"
:style="{ fill: user.getColour() }"
/>
<image
v-if="avatar.hasImage"
v-bind="{ ...awayStatus.vbind, ...avatar[avatar.sizeKey[size]].vbind }"
clip-path="url(#kiwi-avatar-clip)"
width="100%"
height="100%"
preserveAspectRatio="xMidYMid slice"
class="kiwi-avatar-image"
loading="lazy"
@error="avatar[avatar.sizeKey[size]].setFailed()"
/>
<text
v-else
:font-size="avatar.initials.length === 1 ? '64px' : '44px'"
<g
v-bind="awayStatus.vbind"
clip-path="url(#kiwi-avatar-clip)"
x="50%"
y="50%"
dy="0.36em"
text-anchor="middle"
class="kiwi-avatar-initials"
>{{ avatar.initials }}</text>
>
<rect
v-if="avatar.showBackground"
class="kiwi-avatar-background"
width="100"
height="100"
:style="{ fill: user.getColour() }"
/>
<image
v-if="avatar.hasImage"
v-bind="{ ...avatar[avatar.sizeKey[size]].vbind }"
width="100"
height="100"
preserveAspectRatio="xMidYMid slice"
class="kiwi-avatar-image"
loading="lazy"
@error="avatar[avatar.sizeKey[size]].setFailed()"
/>
<text
v-else
:font-size="avatar.initials.length === 1 ? '64px' : '44px'"
v-bind="awayStatus.vbind"
clip-path="url(#kiwi-avatar-clip)"
x="50"
y="50"
dy="0.36em"
text-anchor="middle"
class="kiwi-avatar-initials"
>{{ avatar.initials }}</text>
</g>
<circle
v-if="awayStatus.show"
transform="rotate(45 50 50)"
r="12%"
cx="50%"
r="12"
cx="50"
cy="0"
class="kiwi-avatar-status"
:class="{
Expand All @@ -50,12 +52,12 @@
</circle>
</svg>
<svg v-else viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle r="50%" cx="50%" cy="50%" class="kiwi-avatar-circle" />
<circle r="50" cx="50" cy="50" class="kiwi-avatar-background" />
<text
font-size="64px"
clip-path="url(#kiwi-avatar-clip)"
x="50%"
y="50%"
x="50"
y="50"
dy="0.36em"
text-anchor="middle"
class="kiwi-avatar-initials"
Expand Down
2 changes: 1 addition & 1 deletion src/res/configTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const configTemplates = {
},
avatars: {
initials_length: 1,
show_image_background: true,
show_image_background: false,
},
// Startup screen default
startupOptions: {
Expand Down
4 changes: 2 additions & 2 deletions static/themes/coffee/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
color: #fff;
}

.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-circle,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-circle {
.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-background,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-background {
fill: #967c68 !important;
}

Expand Down
6 changes: 3 additions & 3 deletions static/themes/common/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@
background: var(--brand-error);
}

.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-circle,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-circle {
.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-background,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-background {
fill: var(--brand-primary) !important;
}

Expand Down Expand Up @@ -913,7 +913,7 @@
fill: var(--brand-default-bg);
}

.kiwi-avatar-circle {
.kiwi-avatar-background {
fill: var(--brand-darktone);
}

Expand Down
6 changes: 3 additions & 3 deletions static/themes/nightswatch/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@
border-right: 2px solid #444;
}

.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-circle,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-circle {
.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-background,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-background {
fill: #f1f1f1 !important;
}

.kiwi-avatar-circle {
.kiwi-avatar-background {
fill: var(--brand-input-fg);
}

Expand Down
6 changes: 3 additions & 3 deletions static/themes/radioactive/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,12 @@
border-top: 1px #14fdce solid;
}

.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-circle,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-circle {
.kiwi-statebrowser-usermenu-avatar:hover .kiwi-avatar-background,
.kiwi-statebrowser-usermenu--open .kiwi-avatar-background {
fill: #5dd895 !important;
}

.kiwi-avatar-circle {
.kiwi-avatar-background {
fill: #57da93;
}

Expand Down

0 comments on commit 6fd6d11

Please sign in to comment.