wrap up initial pages, styling, member and post counts on profiels, vue router scroll behavior

This commit is contained in:
william Murphy 2019-11-17 19:48:11 -06:00
parent c79d983ad3
commit d15e9436ee
6 changed files with 116 additions and 22 deletions

View file

@ -1,10 +1,10 @@
<template> <template>
<div id="app"> <div id="app">
<!-- <div id="nav"> <div class="w3-bar w3-black w3-card">
<router-link to="/">Home</router-link> | <div class="w3-container w3-section">
<router-link to="/about">About</router-link> <router-link to="/"><i class="fas fa-home" title="home"></i></router-link>
</div> --> </div>
<div class="w3-bar w3-black w3-card">&nbsp;</div> </div>
<div class="w3-row"> <div class="w3-row">
<div class="w3-col s0 m1 l2">&nbsp;</div> <div class="w3-col s0 m1 l2">&nbsp;</div>
<div class="w3-col s12 m10 l8 w3-content"> <div class="w3-col s12 m10 l8 w3-content">
@ -13,7 +13,7 @@
<div class="w3-col s0 m1 l2">&nbsp;</div> <div class="w3-col s0 m1 l2">&nbsp;</div>
</div> </div>
<footer class="w3-container w3-padding-64 w3-center w3-opacity w3-light-grey w3-xlarge"> <footer class="w3-container w3-padding-64 w3-center w3-opacity w3-light-grey w3-xlarge">
<a href="https://github.com/wmurphyrd/guppe"><i class="fa fa-github w3-hover-opacity"></i></a> <a href="https://github.com/wmurphyrd/guppe"><i class="fab fa-github w3-hover-opacity"></i></a>
</footer> </footer>
</div> </div>
</template> </template>

View file

@ -1,7 +1,8 @@
<template> <template>
<div class="w3-card w3-margin-bottom"> <div class="w3-card w3-margin-bottom">
<div class="w3-container w3-left-align"> <div class="w3-container w3-left-align">
<img class="icon" crossorigin="anonymous" :src="actorIconUrl"> <!-- remotes aren't serving icons with crossorigin, would need fetch serverside and cache -->
<!-- <img class="icon" crossorigin="anonymous" :src="actorIconUrl"> -->
<label> <label>
<b>{{ actor.preferredUsername }}</b> <b>{{ actor.preferredUsername }}</b>
<span class="w3-text-grey">@{{ actorHost }}</span> <span class="w3-text-grey">@{{ actorHost }}</span>
@ -76,3 +77,12 @@ export default {
height: 32px; height: 32px;
} }
</style> </style>
<style>
.invisible {
display: none;
}
.ellipsis::after {
content: '\2026'
}
</style>

View file

@ -0,0 +1,70 @@
<template>
<div class="w3-center">
<img class="w3-image profile-image" :src="groupProfileSrc">
<h2 class="w3-wide">{{ actor.preferredUsername }}</h2>
<div class="w3-container">
<span class="w3-container w3-show-inline-block"><i class="fas fa-users" title="Group members"></i>{{ followerCount}}</span>
<span class="w3-container w3-show-inline-block"><i class="fas fa-mail-bulk" title="Group posts"></i>{{ postCount}}</span>
</div>
<p class="w3-opacity"><i>{{ actor.summary }}</i></p>
</div>
</template>
<script>
export default {
props: {
actor: {
type: Object,
required: true,
}
},
data() {
return {
followerCount: undefined,
postCount: undefined,
}
},
computed: {
groupProfileSrc () {
return this.actor && this.actor.icon ? this.actor.icon.url : ''
}
},
methods: {
fetchInfo () {
window.fetch(this.actor.followers, {
method: 'get',
headers: {
accept: 'application/activity+json'
}
})
.then(res => res.json())
.then(followersCollection => {
this.followerCount = followersCollection.totalItems
})
window.fetch(this.actor.outbox, {
method: 'get',
headers: {
accept: 'application/activity+json'
}
})
.then(res => res.json())
.then(outboxCollection => {
this.postCount = outboxCollection.totalItems
})
}
},
created () {
this.fetchInfo()
},
updated () {
this.fetchInfo()
}
}
</script>
<style scoped>
.fas {
margin-right: 8px;
}
</style>

View file

@ -19,5 +19,13 @@ export default new Router({
component: Profile, component: Profile,
props: true props: true
} }
] ],
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
}
}) })

View file

@ -23,10 +23,9 @@
</ol> </ol>
<h2 class="w3-center">Active Groups</h2> <h2 class="w3-center">Active Groups</h2>
<div class="profile-grid w3-margin-bottom w3-mobile"> <div class="profile-grid w3-margin-bottom w3-mobile">
<div v-for="group of groups" class="w3-card" :key="group._id"> <div v-for="group of groups" class="w3-card w3-container w3-section" :key="group._id">
<Profile :name="group.preferredUsername" :post-limit="3" <profile-summary :actor="group" class="profile"/>
class="profile"/> <router-link :to="`/u/${group.preferredUsername}`">Group profile...</router-link>
<router-link :to="`/u/${group.preferredUsername}`">More...</router-link>
</div> </div>
</div> </div>
@ -34,12 +33,12 @@
</template> </template>
<script> <script>
import Profile from '@/views/Profile.vue' import ProfileSummary from '@/components/ProfileSummary.vue'
export default { export default {
name: 'home', name: 'home',
components: { components: {
Profile ProfileSummary
}, },
data() { data() {
return { return {
@ -67,9 +66,15 @@ export default {
width: 300px; width: 300px;
} }
.profile-grid { .profile-grid {
display: grid; display: flex;
grid-gap: 15px; flex-flow: row wrap;
grid-template-columns: auto auto; justify-content: space-between;
justify-content: space-evenly; align-content: space-between;
}
</style>
<style>
.profile-image {
width: 75px;
} }
</style> </style>

View file

@ -1,8 +1,6 @@
<template> <template>
<div class="w3-container w3-content w3-center w3-padding-32"> <div class="w3-container w3-content w3-center w3-padding-32">
<img class="w3-image" :src="groupProfileSrc"> <profile-summary :actor="actor"/>
<h2 class="w3-wide">{{ actor.preferredUsername }}</h2>
<p class="w3-opacity"><i>{{ actor.summary }}</i></p>
<p class="w3-left-align">To join {{ actor.preferredUsername }}, enter your handle below and you'll be <p class="w3-left-align">To join {{ actor.preferredUsername }}, enter your handle below and you'll be
redirected back to this group's profile in your app where you can follow it.</p> redirected back to this group's profile in your app where you can follow it.</p>
<form class="w3-container"> <form class="w3-container">
@ -35,9 +33,12 @@
<script> <script>
import PostCard from '@/components/PostCard.vue' import PostCard from '@/components/PostCard.vue'
import ProfileSummary from '@/components/ProfileSummary.vue'
export default { export default {
components: { components: {
PostCard PostCard,
ProfileSummary
}, },
props: { props: {
name: { name: {