2021-03-14 03:54:43 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
v-if="user"
|
|
|
|
class="user"
|
|
|
|
>
|
|
|
|
<div class="header">
|
|
|
|
<h2 class="username">{{ user.username }}</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<section
|
2021-03-15 02:30:47 +00:00
|
|
|
v-if="user.stashes?.length > 0"
|
2021-03-14 03:54:43 +00:00
|
|
|
class="section"
|
|
|
|
>
|
|
|
|
<h3 class="heading">Stashes</h3>
|
|
|
|
|
|
|
|
<ul class="stashes nolist">
|
|
|
|
<li
|
2021-03-15 02:30:47 +00:00
|
|
|
v-for="stash in user.stashes"
|
2021-03-14 03:54:43 +00:00
|
|
|
:key="stash.id"
|
|
|
|
>
|
2021-03-20 01:49:17 +00:00
|
|
|
<Stash
|
|
|
|
:stash="stash"
|
|
|
|
:is-me="isMe"
|
|
|
|
@publish="() => fetchUser()"
|
|
|
|
/>
|
2021-03-14 03:54:43 +00:00
|
|
|
</li>
|
2021-03-20 02:22:08 +00:00
|
|
|
|
|
|
|
<li
|
|
|
|
v-if="isMe"
|
|
|
|
class="stashes-add"
|
|
|
|
@click="showAddStash = true"
|
|
|
|
>
|
|
|
|
<Icon icon="plus2" />
|
|
|
|
</li>
|
2021-03-14 03:54:43 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
2021-03-20 02:22:08 +00:00
|
|
|
|
|
|
|
<AddStash
|
|
|
|
v-if="showAddStash"
|
2021-03-20 02:33:29 +00:00
|
|
|
@close="closeAddStash"
|
2021-03-20 02:22:08 +00:00
|
|
|
/>
|
2021-03-14 03:54:43 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-20 01:49:17 +00:00
|
|
|
import Stash from './stash.vue';
|
2021-03-20 02:22:08 +00:00
|
|
|
import AddStash from '../stashes/add-stash.vue';
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-19 01:36:31 +00:00
|
|
|
async function fetchUser() {
|
2021-03-15 02:30:47 +00:00
|
|
|
this.user = await this.$store.dispatch('fetchUser', this.$route.params.username);
|
2021-03-20 01:03:30 +00:00
|
|
|
this.isMe = this.user.id === this.$store.state.auth.user?.id;
|
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
this.pageTitle = this.user?.username;
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 02:33:29 +00:00
|
|
|
async function closeAddStash(addedStash) {
|
|
|
|
this.showAddStash = false;
|
|
|
|
|
|
|
|
if (addedStash) {
|
|
|
|
await this.fetchUser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 01:36:31 +00:00
|
|
|
async function mounted() {
|
|
|
|
await this.fetchUser();
|
|
|
|
}
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2021-03-20 02:22:08 +00:00
|
|
|
AddStash,
|
2021-03-20 01:49:17 +00:00
|
|
|
Stash,
|
2021-03-14 03:54:43 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
user: this.$route.params.username === this.$store.state.auth.user?.username
|
|
|
|
? this.$store.state.auth.user
|
|
|
|
: null,
|
2021-03-20 01:03:30 +00:00
|
|
|
isMe: false,
|
2021-03-15 02:30:47 +00:00
|
|
|
pageTitle: null,
|
2021-03-20 02:22:08 +00:00
|
|
|
showAddStash: false,
|
2021-03-14 03:54:43 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted,
|
2021-03-19 01:36:31 +00:00
|
|
|
methods: {
|
2021-03-20 02:33:29 +00:00
|
|
|
closeAddStash,
|
2021-03-19 01:36:31 +00:00
|
|
|
fetchUser,
|
|
|
|
},
|
2021-03-14 03:54:43 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-03-19 23:41:21 +00:00
|
|
|
@import 'breakpoints';
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
.header {
|
2021-03-15 02:30:47 +00:00
|
|
|
padding: .5rem 1rem;
|
2021-03-14 03:54:43 +00:00
|
|
|
background: var(--profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
.username {
|
|
|
|
margin: 0;
|
|
|
|
font-size: 1.5rem;
|
|
|
|
color: var(--text-light);
|
|
|
|
}
|
|
|
|
|
|
|
|
.section {
|
|
|
|
padding: 1rem;
|
|
|
|
margin: 0 0 1rem 0;
|
|
|
|
}
|
|
|
|
|
2021-03-19 01:36:31 +00:00
|
|
|
.stashes {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
2021-03-20 02:22:08 +00:00
|
|
|
grid-auto-rows: 15fr;
|
|
|
|
grid-gap: 1rem;
|
2021-03-19 01:36:31 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
.heading {
|
|
|
|
color: var(--primary);
|
|
|
|
}
|
|
|
|
|
2021-03-20 02:22:08 +00:00
|
|
|
.stashes-add {
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
background: var(--shadow-hint);
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
width: 1.5rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
fill: var(--shadow-weak);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--shadow-weak);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--shadow);
|
|
|
|
}
|
|
|
|
}
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 23:41:21 +00:00
|
|
|
@media(max-width: $breakpoint-kilo) {
|
|
|
|
.stashes {
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
}
|
|
|
|
}
|
2021-03-14 03:54:43 +00:00
|
|
|
</style>
|