Skip to content

Commit

Permalink
fix(icons): fix avatar colors on creation / on fetch from server
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Feb 21, 2024
1 parent 415c141 commit dce7984
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
17 changes: 17 additions & 0 deletions css/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,20 @@
background-image: url(../img/app-dark.svg);
filter: var(--background-invert-if-dark);
}

/* To be used in new conversation dialog */
.conversation-icon .icon-conversation-group.icon--dark {
background-image: url('../img/icon-conversation-group-dark.svg')
}

.conversation-icon .icon-conversation-group.icon--bright {
background-image: url('../img/icon-conversation-group-bright.svg')
}

.conversation-icon .icon-conversation-public.icon--dark {
background-image: url('../img/icon-conversation-public-dark.svg')
}

.conversation-icon .icon-conversation-public.icon--bright {
background-image: url('../img/icon-conversation-public-bright.svg')
}
4 changes: 2 additions & 2 deletions lib/Service/AvatarService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

class AvatarService {
public const THEMING_PLACEHOLDER = '{{THEMING}}';
public const THEMING_DARK_BACKGROUND = '3B3B3B';
public const THEMING_BRIGHT_BACKGROUND = 'DBDBDB';
public const THEMING_DARK_BACKGROUND = '999999';
public const THEMING_BRIGHT_BACKGROUND = '6B6B6B';

public function __construct(
private IAppData $appData,
Expand Down
18 changes: 10 additions & 8 deletions src/components/ConversationIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ export default {
iconClass() {
if (this.item.isDummyConversation) {
// Prevent a 404 when trying to load an avatar before the conversation data is actually loaded
return 'icon-contacts'
// Also used in new conversation dialog
const type = this.item.type === CONVERSATION.TYPE.PUBLIC ? 'icon-conversation-public' : 'icon-conversation-group'
const theme = isDarkTheme ? 'dark' : 'bright'
return `${type} icon--dummy icon--${theme}`
}

if (!supportsAvatar) {
Expand Down Expand Up @@ -201,11 +204,6 @@ export default {
return 'icon-contacts'
}

if (this.item.type === CONVERSATION.TYPE.PUBLIC) {
// Public icon for new conversation dialog
return 'icon-public'
}

// Fall-through for other conversation suggestions to user-avatar handling
return undefined
},
Expand All @@ -215,7 +213,7 @@ export default {
},

avatarUrl() {
if (!supportsAvatar) {
if (!supportsAvatar || this.item.isDummyConversation) {
return undefined
}

Expand All @@ -242,7 +240,11 @@ export default {
height: var(--icon-size);
line-height: var(--icon-size);
background-size: calc(var(--icon-size) / 2);
background-color: var(--color-background-darker);
background-color: var(--color-text-maxcontrast);

&--dummy {
background-size: var(--icon-size);
}

&.icon-changelog {
background-size: cover !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ section {
height: 100%;
padding-bottom: 6px;
border-radius: 100%;
background-color: var(--color-background-darker);
background-color: var(--color-text-maxcontrast);
font-size: 575%;
line-height: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const NEW_CONVERSATION = {
description: '',
hasPassword: false,
type: CONVERSATION.TYPE.GROUP,
isDummyConversation: true,
}

export default {
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/features/conversation-1/avatar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ Feature: conversation/avatar
And the avatar svg of room "room" contains the string "123456"
Then user "participant1" sets emoji "🍏" with color "null" as avatar of room "room" with 200 (v1)
And the avatar svg of room "room" contains the string "🍏"
And the avatar svg of room "room" contains the string "DBDBDB"
And the avatar svg of room "room" not contains the string "3B3B3B"
And the avatar svg of room "room" contains the string "6B6B6B"
And the avatar svg of room "room" not contains the string "999999"
And the dark avatar svg of room "room" contains the string "🍏"
And the dark avatar svg of room "room" not contains the string "DBDBDB"
And the dark avatar svg of room "room" contains the string "3B3B3B"
And the dark avatar svg of room "room" not contains the string "6B6B6B"
And the dark avatar svg of room "room" contains the string "999999"

0 comments on commit dce7984

Please sign in to comment.