Populate the User list view

This commit adds a component for an entry in a list of users, and uses
it in the user list view.
This commit is contained in:
Adam Coldrick 2020-05-09 00:17:17 +01:00
parent 85367d66f8
commit e460f430a7
2 changed files with 89 additions and 2 deletions

View File

@ -0,0 +1,57 @@
<template>
<div class="user">
<img :src="avatar" />
<div class="details">
<router-link :to="`/user/${user.id}`">
<h2>{{ user.full_name }}</h2>
</router-link>
<p class="metadata">{{ user.email }}</p>
</div>
</div>
</template>
<script>
import user from '@/api/user.js'
export default {
name: 'UserListItem',
props: ['user'],
data () {
return {
avatar: ''
}
},
created () {
this.avatar = user.getAvatarUrl(this.user, 60)
}
}
</script>
<style lang="scss" scoped>
.user {
display: flex;
align-items: center;
padding: 20px;
border-top: solid 1px #ddd;
&:hover {
background-color: #fff;
}
img {
margin-right: 20px;
border-radius: 100%;
}
h2 {
margin: 0;
font-weight: 300;
}
.metadata {
margin: 0;
color: #777;
}
}
</style>

View File

@ -1,5 +1,35 @@
<template>
<div class="about">
<h1>User list here</h1>
<div class="user-list">
<h1>Users</h1>
<UserListItem v-for="user in users" :key="user.id" :user="user" />
</div>
</template>
<script>
import user from '@/api/user.js'
import UserListItem from '@/components/UserListItem.vue'
export default {
name: 'UserListView',
components: {
UserListItem
},
data () {
return {
users: []
}
},
created () {
this.getUsers()
},
methods: {
async getUsers () {
const params = {
limit: 10
}
this.users = await user.browse(params)
}
}
}
</script>