traxxx/assets/components/users/user.vue

244 lines
4.0 KiB
Vue
Raw Normal View History

<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"
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"
:key="stash.id"
2021-03-15 02:30:47 +00:00
class="stash"
>
<div class="stash-section stash-header">
<router-link
:to="{ name: 'stash', params: { stashId: stash.id, stashSlug: stash.slug } }"
class="stash-link nolink"
>
<h4 class="stash-name">{{ stash.name }}</h4>
</router-link>
<label
v-if="isMe"
v-tooltip="'Public'"
:class="{ public: stash.public }"
class="stash-public"
>
<Icon
v-show="stash.public"
icon="eye"
/>
<Icon
v-show="!stash.public"
icon="eye-blocked"
/>
<Toggle
:checked="stash.public"
@change="checked => publishStash(stash, checked)"
/>
</label>
</div>
2021-03-16 01:31:23 +00:00
<ul
v-if="stash.scenes?.length > 0"
class="stash-section stash-scenes nolist"
>
<li
v-for="{ scene } in stash.scenes"
:key="scene.id"
class="stash-scene"
>
<ScenePreview
:scene="scene"
:stash="stash"
@unstash="fetchUser"
/>
</li>
</ul>
2021-03-16 01:31:23 +00:00
<ul
v-if="stash.actors?.length > 0"
class="stash-section stash-actors nolist"
>
<li
v-for="{ actor } in stash.actors"
:key="actor.id"
class="stash-actor"
>
<ActorPreview
:actor="actor"
:stash="stash"
@unstash="fetchUser"
/>
</li>
</ul>
</li>
</ul>
</section>
</div>
</template>
<script>
import ActorPreview from './actor-preview.vue';
import ScenePreview from './scene-preview.vue';
import Toggle from '../form/toggle.vue';
async function fetchUser() {
2021-03-15 02:30:47 +00:00
this.user = await this.$store.dispatch('fetchUser', this.$route.params.username);
this.isMe = this.user.id === this.$store.state.auth.user?.id;
2021-03-15 02:30:47 +00:00
this.pageTitle = this.user?.username;
}
async function publishStash(stash, isPublic) {
await this.$store.dispatch('updateStash', {
stashId: stash.id,
stash: { public: isPublic },
});
this.fetchUser();
}
async function mounted() {
await this.fetchUser();
}
export default {
components: {
ActorPreview,
ScenePreview,
Toggle,
},
data() {
return {
user: this.$route.params.username === this.$store.state.auth.user?.username
? this.$store.state.auth.user
: null,
isMe: false,
2021-03-15 02:30:47 +00:00
pageTitle: null,
};
},
mounted,
methods: {
fetchUser,
publishStash,
},
};
</script>
<style lang="scss" scoped>
@import 'breakpoints';
.header {
2021-03-15 02:30:47 +00:00
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;
2021-03-15 02:30:47 +00:00
background: var(--background);
margin: 0 0 1rem 0;
2021-03-15 02:30:47 +00:00
box-shadow: 0 0 3px var(--shadow-weak);
}
.stash-section {
display: flex;
align-items: center;
padding: .5rem;
&:not(:last-child) {
border-bottom: solid 1px var(--shadow-hint);
}
}
.stash-header {
justify-content: space-between;
padding: 0;
}
.stash-link {
flex-grow: 1;
display: inline-block;
text-decoration: none;
}
.stash-public {
display: flex;
align-items: center;
padding: .5rem;
cursor: pointer;
2021-03-15 02:30:47 +00:00
.icon {
fill: var(--shadow-strong);
margin: 0 .5rem 0 0;
2021-03-15 02:30:47 +00:00
}
}
.stash-name {
padding: .5rem;
margin: 0;
color: var(--shadow-strong);
}
2021-03-15 02:30:47 +00:00
.stash-actors,
.stash-scenes {
display: flex;
overflow-x: auto;
2021-03-20 01:34:49 +00:00
grid-gap: .5rem;
scroll-behavior: smooth;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
.stash-scenes {
height: 8rem;
2021-03-15 02:30:47 +00:00
}
.stash-actor,
.stash-scene {
height: 100%;
flex-shrink: 0;
2021-03-20 01:34:49 +00:00
font-size: 0;
2021-03-15 02:30:47 +00:00
}
@media(max-width: $breakpoint-kilo) {
.stashes {
grid-template-columns: 1fr;
}
}
</style>