<script setup>
import { inject } from 'vue';

import Domains from '#/components/domains/domains.vue';

const pageContext = inject('pageContext');
const { routeParams } = pageContext;

const domain = routeParams.domain;
const stash = pageContext.pageProps.stash;
</script>

<template>
	<div class="stash">
		<div class="header">
			<h2 class="title">
				<Icon
					v-if="stash.isPrimary"
					icon="heart7"
				/>

				<Icon
					v-else
					icon="box"
				/>

				{{ stash.name }}
			</h2>

			<Domains
				:domain="domain"
				:path="`/stash/${stash.user.username}/${stash.slug}`"
				class="domains-header"
			/>

			<a
				:href="`/user/${stash.user.username}`"
				class="user nolink"
			>
				<img
					:src="stash.user.avatar"
					class="avatar"
				><span class="userame ellipsis">{{ stash.user.username }}</span>
			</a>
		</div>

		<Domains
			:domain="domain"
			:path="`/stash/${stash.user.username}/${stash.slug}`"
			class="domains-bar"
		/>

		<div class="content">
			<slot />
		</div>
	</div>
</template>

<style scoped>
.stash {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
}

.header {
	display: flex;
	justify-content: space-between;
	align-items: stretch;
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 0 1rem;
	color: var(--text-light);
	background: var(--grey-dark-40);
	flex-shrink: 0;
}

.title {
	margin: 0;
	text-transform: capitalize;
	display: flex;
	align-items: center;
	padding: .5rem 0;
	font-size: 1.2rem;
	margin-right: 1rem;

	.icon {
		width: 1.25rem;
		height: 1.25rem;
		margin-right: .75rem;
		fill: var(--text-light);
	}
}

.user {
	display: flex;
	align-items: center;
	font-weight: bold;
	overflow: hidden;
}

.avatar {
	width: 1.5rem;
	height: 1.5rem;
	margin-right: .75rem;
	border-radius: .25rem;
}

.domains-bar {
	display: none;
}

.scenes-container {
	overflow-y: auto;
}

.content {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	overflow-y: auto;
}

@media(--small) {
	.domains-header {
		display: none;
	}

	.domains-bar {
		display: flex;
	}
}

@media(--small-50) {
	.title {
		font-size: 1rem;

		.icon {
			width: 1rem;
			height: 1rem;
		}
	}

	.avatar {
		display: none;
	}
}
</style>
