Skip to content

Commit

Permalink
Merge pull request #1217 from nextcloud/avatarFix
Browse files Browse the repository at this point in the history
avatars now in a good looking way
  • Loading branch information
juliusknorr authored Sep 5, 2019
2 parents 4e320ff + b75d1ef commit 2139a82
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 15 deletions.
135 changes: 135 additions & 0 deletions src/components/cards/AvatarList.vue
Original file line number Diff line number Diff line change
@@ -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>
18 changes: 3 additions & 15 deletions src/components/cards/CardBadges.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ cardbadges

<div v-if="card.attachments" class="card-files icon icon-files-dark" />

<div v-if="card.assignedUsers" class="card-assigned-users">
<avatar v-for="user in card.assignedUsers" :key="user.id" :user="user.participant.primaryKey" />
</div>
<avatar-list :users="card.assignedUsers" />
</div>
</template>
<script>
import { Avatar } from 'nextcloud-vue'
import AvatarList from './AvatarList'

export default {
name: 'CardBadges',
components: { Avatar },
components: { Avatar, AvatarList },
props: {
id: {
type: Number,
Expand Down Expand Up @@ -112,9 +111,6 @@ export default {
display: flex;
flex-grow: 1;

& > div {
margin-right: 10px;
}
.icon {
opacity: 0.5;
padding: 12px 3px;
Expand All @@ -126,14 +122,6 @@ export default {
opacity: 1;
}
}
.card-assigned-users {
flex-grow: 1;
padding: 6px 0;
margin-right: -5px;
.avatardiv {
float: right;
}
}
}

.badges .icon.due {
Expand Down

0 comments on commit 2139a82

Please sign in to comment.