traxxx/assets/components/users/user.vue

108 lines
1.6 KiB
Vue

<template>
<div
v-if="user"
class="user"
>
<div class="header">
<h2 class="username">{{ user.username }}</h2>
</div>
<section
v-if="user.stashes?.length > 0"
class="section"
>
<h3 class="heading">Stashes</h3>
<ul class="stashes nolist">
<li
v-for="stash in user.stashes"
:key="stash.id"
class="stash"
>
<Stash
:stash="stash"
:is-me="isMe"
@publish="() => fetchUser()"
/>
</li>
</ul>
</section>
</div>
</template>
<script>
import Stash from './stash.vue';
async function fetchUser() {
this.user = await this.$store.dispatch('fetchUser', this.$route.params.username);
this.isMe = this.user.id === this.$store.state.auth.user?.id;
this.pageTitle = this.user?.username;
}
async function mounted() {
await this.fetchUser();
}
export default {
components: {
Stash,
},
data() {
return {
user: this.$route.params.username === this.$store.state.auth.user?.username
? this.$store.state.auth.user
: null,
isMe: false,
pageTitle: null,
};
},
mounted,
methods: {
fetchUser,
},
};
</script>
<style lang="scss" scoped>
@import 'breakpoints';
.header {
padding: .5rem 1rem;
background: var(--profile);
}
.username {
margin: 0;
font-size: 1.5rem;
color: var(--text-light);
}
.section {
padding: 1rem;
margin: 0 0 1rem 0;
}
.stashes {
display: grid;
grid-template-columns: 1fr 1fr;
}
.heading {
color: var(--primary);
}
.stash {
min-width: 0;
background: var(--background);
margin: 0 0 1rem 0;
box-shadow: 0 0 3px var(--shadow-weak);
}
@media(max-width: $breakpoint-kilo) {
.stashes {
grid-template-columns: 1fr;
}
}
</style>