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

Vue avatars in list #641

Merged
merged 9 commits into from
Sep 26, 2018
34 changes: 34 additions & 0 deletions css/ContentListItem.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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/>.
*
*/

.app-content-list-item-icon {
overflow: hidden;
&__avatar {
position: absolute;
top: 0;
left: 0;
height: inherit;
width: inherit;
background-size: cover;
cursor: pointer;
}
}
1 change: 1 addition & 0 deletions css/contacts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $grid-input-height-with-margin: #{$grid-height-unit - $grid-input-margin * 2};
@import 'settings/settings-addressbook-shares';
@import 'settings/settings-addressbook-sharee';
@import 'ContactDetails';
@import 'ContentListItem';
@import 'Properties/Properties';
@import 'Properties/PropertyTitle';
@import 'importScreen';
Expand Down
9 changes: 8 additions & 1 deletion src/components/ContentList/ContentListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
class="app-content-list-item-checkbox checkbox" @keypress.enter.space.prevent.stop="toggleSelect">
<label :for="contact.key" @click.prevent.stop="toggleSelect" @keypress.enter.space.prevent.stop="toggleSelect" />
-->
<div :style="{ 'backgroundColor': colorAvatar, 'backgroundImage': `url(${contact.url} + ?photo)` }" class="app-content-list-item-icon">{{ contact.displayName | firstLetter }}</div>
<div :style="{ 'backgroundColor': colorAvatar }" class="app-content-list-item-icon">
{{ contact.displayName | firstLetter }}
<!-- try to fetch the avatar only if the contact exists on the server -->
<div v-if="contact.dav" :style="{ 'backgroundImage': avatarUrl }" class="app-content-list-item-icon__avatar" />
</div>
<div class="app-content-list-item-line-one">{{ contact.displayName }}</div>
<div v-if="contact.email" class="app-content-list-item-line-two">{{ contact.email }}</div>
<div v-if="contact.addressbook.readOnly" class="icon-delete" tabindex="0"
Expand Down Expand Up @@ -48,6 +52,9 @@ export default {
} catch (e) {
return 'grey'
}
},
avatarUrl() {
return `url(${this.contact.url}?photo)`
}
},
methods: {
Expand Down