Merge pull request #1217 from nextcloud/avatarFix

avatars now in a good looking way
This commit is contained in:
Julius Härtl
2019-09-05 22:48:03 +02:00
committed by GitHub
2 changed files with 138 additions and 15 deletions

View File

@@ -0,0 +1,135 @@
<!--
- @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
-
- @author Julius Härtl <jus@bitgrid.net>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div class="avatars">
<div class="avatar-list" @click.stop="popoverVisible=!popoverVisible">
<div v-if="popover.length > 0" class="avatardiv icon-more" />
<avatar v-for="user in firstUsers" :key="user.id"
:url="avatarUrl(user)" :disable-tooltip="true" :size="32" />
</div>
<div v-show="popoverVisible" class="popovermenu menu-right">
<popover-menu :menu="popover" />
<slot />
</div>
</div>
</template>
<script>
import Avatar from 'nextcloud-vue/dist/Components/Avatar'
import PopoverMenu from 'nextcloud-vue/dist/Components/PopoverMenu'
import Tooltip from 'nextcloud-vue/dist/Directives/Tooltip'
export default {
name: 'AvatarList',
components: {
Avatar,
PopoverMenu
},
directives: {
tooltip: Tooltip
},
props: {
users: {
type: Array,
default: () => { return {} }
}
},
data() {
return {
popoverVisible: false
}
},
computed: {
firstUsers() {
return this.users.slice(0, 3)
},
avatarUrl() {
return (session) => {
const user = session.participant.displayname
const size = 32
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}',
{
user: user,
size: size
})
return window.location.protocol + '//' + window.location.host + avatarUrl
}
},
popover() {
return [
...this.users.slice(3).map((session) => {
return {
href: '#',
icon: this.avatarUrl(session),
text: session.participant.displayname
}
})
]
}
}
}
</script>
<style scoped lang="scss">
.avatars {
margin: 0;
position: relative;
flex-grow: 1;
/deep/ .popovermenu {
margin-right: -4px;
img {
padding: 0;
width: 32px !important;
height: 32px !important;
margin: 6px;
border-radius: 50%;
}
}
}
.avatar-list {
float: right;
display: inline-flex;
flex-direction: row-reverse;
.avatardiv,
/deep/ .avatardiv {
width: 36px;
height: 36px;
margin-right: -8px;
border: 2px solid var(--color-main-background);
background-color: var(--color-main-background) !important;
box-sizing: content-box !important;
&.icon-more {
width: 32px;
height: 32px;
opacity: .5;
background-color: var(--color-background-dark) !important;
cursor: pointer;
}
}
}
.popovermenu {
display: block;
margin: 40px -6px;
}
</style>

View File

@@ -36,17 +36,16 @@ cardbadges
<div v-if="card.attachments" class="card-files icon icon-files-dark" /> <div v-if="card.attachments" class="card-files icon icon-files-dark" />
<div v-if="card.assignedUsers" class="card-assigned-users"> <avatar-list :users="card.assignedUsers" />
<avatar v-for="user in card.assignedUsers" :key="user.id" :user="user.participant.primaryKey" />
</div>
</div> </div>
</template> </template>
<script> <script>
import { Avatar } from 'nextcloud-vue' import { Avatar } from 'nextcloud-vue'
import AvatarList from './AvatarList'
export default { export default {
name: 'CardBadges', name: 'CardBadges',
components: { Avatar }, components: { Avatar, AvatarList },
props: { props: {
id: { id: {
type: Number, type: Number,
@@ -112,9 +111,6 @@ export default {
display: flex; display: flex;
flex-grow: 1; flex-grow: 1;
& > div {
margin-right: 10px;
}
.icon { .icon {
opacity: 0.5; opacity: 0.5;
padding: 12px 3px; padding: 12px 3px;
@@ -126,14 +122,6 @@ export default {
opacity: 1; opacity: 1;
} }
} }
.card-assigned-users {
flex-grow: 1;
padding: 6px 0;
margin-right: -5px;
.avatardiv {
float: right;
}
}
} }
.badges .icon.due { .badges .icon.due {