Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dark themed avatar on dark theme #3119

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/components/NcAvatar/NcAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ export default {
}

if (this.hasStatus && this.showUserStatus && this.showUserStatusCompact) {
return t('Avatar of {displayName}, {status}', { displayName: this.displayName || this.userId, status: this.userStatus.status })
return t('Avatar of {displayName}, {status}', { displayName: this.displayName ?? this.user, status: this.userStatus.status })
}
return t('Avatar of {displayName}', { displayName: this.displayName || this.userId })
return t('Avatar of {displayName}', { displayName: this.displayName ?? this.user })
},

canDisplayUserStatus() {
Expand Down Expand Up @@ -378,7 +378,7 @@ export default {

if (!this.iconClass && !this.avatarSrcSetLoaded) {
const rgb = usernameToColor(this.getUserIdentifier)
style.backgroundColor = 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')'
style.backgroundColor = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', 0.1)'
}
return style
},
Expand Down Expand Up @@ -559,9 +559,11 @@ export default {
* @return {string}
*/
avatarUrlGenerator(user, size) {
let url = '/avatar/{user}/{size}'
const darkTheme = window.getComputedStyle(this.$el)
.getPropertyValue('--background-invert-if-dark') === 'invert(100%)'
CarlSchwan marked this conversation as resolved.
Show resolved Hide resolved
let url = '/avatar/{user}/{size}' + (darkTheme ? '/dark' : '')
if (this.isGuest) {
url = '/avatar/guest/{user}/{size}'
url = '/avatar/guest/{user}/{size}' + (darkTheme ? '/dark' : '')
}

let avatarUrl = generateUrl(
Expand Down