Skip to content

Commit

Permalink
Merge pull request #34022 from nextcloud/fix/dark-avatar-user-list
Browse files Browse the repository at this point in the history
Fix avatar icons in user list when using dark theme
  • Loading branch information
PVince81 authored Sep 12, 2022
2 parents e85ca5c + 82139cc commit c22d44b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 18 deletions.
7 changes: 6 additions & 1 deletion apps/settings/src/components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@
:settings="settings"
:show-config="showConfig"
:sub-admins-groups="subAdminsGroups"
:user="user" />
:user="user"
:is-dark-theme="isDarkTheme" />
<InfiniteLoading ref="infiniteLoading" @infinite="infiniteHandler">
<div slot="spinner">
<div class="users-icon-loading icon-loading" />
Expand Down Expand Up @@ -378,6 +379,10 @@ export default {
},
]
},
isDarkTheme() {
return window.getComputedStyle(this.$el)
.getPropertyValue('--background-invert-if-dark') === 'invert(100%)'
},
},
watch: {
// watch url change and group select
Expand Down
9 changes: 7 additions & 2 deletions apps/settings/src/components/UserList/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div :class="{'icon-loading-small': loading.delete || loading.disable || loading.wipe}"
class="avatar">
<img v-if="!loading.delete && !loading.disable && !loading.wipe"
:src="generateAvatar(user.id)"
:src="generateAvatar(user.id, isDarkTheme)"
alt=""
height="32"
width="32">
Expand All @@ -54,6 +54,7 @@
:sub-admins-groups="subAdminsGroups"
:user-actions="userActions"
:user="user"
:is-dark-theme="isDarkTheme"
:class="{'row--menu-opened': openedMenu}" />
<div v-else
:class="{
Expand All @@ -65,7 +66,7 @@
<div :class="{'icon-loading-small': loading.delete || loading.disable || loading.wipe}"
class="avatar">
<img v-if="!loading.delete && !loading.disable && !loading.wipe"
:src="generateAvatar(user.id)"
:src="generateAvatar(user.id, isDarkTheme)"
alt=""
height="32"
width="32">
Expand Down Expand Up @@ -295,6 +296,10 @@ export default {
type: Array,
default: () => [],
},
isDarkTheme: {
type: Boolean,
required: true,
},
},
data() {
return {
Expand Down
6 changes: 5 additions & 1 deletion apps/settings/src/components/UserList/UserRowSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
alt=""
width="32"
height="32"
:src="generateAvatar(user.id)" />
:src="generateAvatar(user.id, isDarkTheme)" />
</div>
<!-- dirty hack to ellipsis on two lines -->
<div class="name">
Expand Down Expand Up @@ -130,6 +130,10 @@ export default {
type: Object,
required: true,
},
isDarkTheme: {
type: Boolean,
required: true,
},
},
computed: {
userGroupsLabels() {
Expand Down
27 changes: 19 additions & 8 deletions apps/settings/src/mixins/UserRowMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,27 @@ export default {
* Generate avatar url
*
* @param {string} user The user name
* @param {bool} isDarkTheme Whether the avatar should be the dark version
* @return {string}
*/
generateAvatar(user) {
return generateUrl(
'/avatar/{user}/64?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
generateAvatar(user, isDarkTheme) {
if (isDarkTheme) {
return generateUrl(
'/avatar/{user}/64/dark?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
} else {
return generateUrl(
'/avatar/{user}/64?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
}
},
},
}
4 changes: 2 additions & 2 deletions dist/settings-users-8351.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-8351.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

0 comments on commit c22d44b

Please sign in to comment.