2026-10-28 16:57:43 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const { user, logout } = useAuth()
|
|
|
|
|
const notices = useNotices()
|
2026-10-28 20:05:34 +00:00
|
|
|
const route = useRoute()
|
|
|
|
|
const { current } = useCurrentWorld()
|
|
|
|
|
|
|
|
|
|
/** Inside a world (village or map) the header is that world's navigation. */
|
|
|
|
|
const inWorld = computed(() => !!current.value && /^\/(village|map)\//.test(route.path))
|
|
|
|
|
const home = computed(() =>
|
|
|
|
|
inWorld.value && current.value?.villageId ? `/village/${current.value.villageId}` : '/worlds',
|
|
|
|
|
)
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
|
|
|
const connection = computed(() =>
|
2026-10-28 18:04:21 +00:00
|
|
|
isMockServer
|
2026-10-28 19:22:53 +00:00
|
|
|
? { text: t('app.mock'), tone: 'badge-gold' }
|
2026-10-28 18:04:21 +00:00
|
|
|
: ws.is_opened.value
|
2026-10-28 19:22:53 +00:00
|
|
|
? { text: t('app.connected'), tone: 'badge-moss' }
|
|
|
|
|
: { text: t('app.offline'), tone: 'badge-blood' },
|
2026-10-28 16:57:43 +00:00
|
|
|
)
|
|
|
|
|
|
2026-10-28 18:04:21 +00:00
|
|
|
const toastTone = {
|
2026-10-28 19:22:53 +00:00
|
|
|
success: 'border-moss-700 bg-parchment-50 text-moss-700',
|
|
|
|
|
error: 'border-blood-700 bg-[#f0d6c8] text-blood-800',
|
|
|
|
|
warning: 'border-gold-600 bg-parchment-50 text-wood-900',
|
|
|
|
|
info: 'border-wood-700 bg-parchment-50 text-ink-900',
|
2026-10-28 18:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
2026-10-28 16:57:43 +00:00
|
|
|
useHead({ title: () => t('app.title') })
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-28 18:04:21 +00:00
|
|
|
<div class="min-h-dvh">
|
2026-10-28 19:22:53 +00:00
|
|
|
<!-- A dark wooden bar, like a tavern sign board. -->
|
|
|
|
|
<header class="border-b-4 border-wood-950 bg-wood-900 text-parchment-100">
|
|
|
|
|
<div class="flex items-center gap-2 px-4 py-2 sm:gap-3 sm:px-6">
|
2026-10-28 20:05:34 +00:00
|
|
|
<NuxtLink :to="home" class="flex min-w-0 items-center gap-2">
|
2026-10-28 19:22:53 +00:00
|
|
|
<span class="grid size-8 shrink-0 place-items-center rounded-sm border border-gold-600 bg-blood-700 text-gold-400">
|
2026-10-28 18:04:21 +00:00
|
|
|
<IconBuilding type="headquarters" class="size-5" />
|
|
|
|
|
</span>
|
2026-10-28 19:22:53 +00:00
|
|
|
<span class="hidden font-display text-lg font-semibold text-gold-400 sm:inline" style="font-variant: small-caps">
|
|
|
|
|
{{ t('app.title') }}
|
|
|
|
|
</span>
|
2026-10-28 18:04:21 +00:00
|
|
|
</NuxtLink>
|
2026-10-28 16:57:43 +00:00
|
|
|
|
2026-10-28 20:05:34 +00:00
|
|
|
<nav v-if="user && inWorld && current" class="ml-1 flex items-center gap-1">
|
|
|
|
|
<NuxtLink
|
|
|
|
|
v-if="current.villageId"
|
|
|
|
|
:to="`/village/${current.villageId}`"
|
|
|
|
|
class="nav-link"
|
|
|
|
|
active-class="nav-link-active"
|
|
|
|
|
>
|
|
|
|
|
<IconBuilding type="headquarters" class="size-4" />
|
|
|
|
|
{{ t('app.village') }}
|
2026-10-28 18:04:21 +00:00
|
|
|
</NuxtLink>
|
2026-10-28 20:05:34 +00:00
|
|
|
<NuxtLink :to="`/map/${current.worldId}`" class="nav-link" active-class="nav-link-active">
|
2026-10-28 18:58:42 +00:00
|
|
|
<IconUi name="pin" class="size-4" />
|
|
|
|
|
{{ t('app.map') }}
|
|
|
|
|
</NuxtLink>
|
2026-10-28 18:04:21 +00:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<div class="ml-auto flex min-w-0 items-center gap-2">
|
2026-10-28 18:27:17 +00:00
|
|
|
<!-- The socket opens with the first request after login, so before that there is nothing to show. -->
|
|
|
|
|
<span v-if="user" class="badge" :class="connection.tone">
|
2026-10-28 18:04:21 +00:00
|
|
|
<span class="size-1.5 rounded-full bg-current" />
|
|
|
|
|
{{ connection.text }}
|
|
|
|
|
</span>
|
|
|
|
|
<template v-if="user">
|
2026-10-28 19:22:53 +00:00
|
|
|
<span class="hidden truncate text-sm text-parchment-300 md:inline">{{ user.name }}</span>
|
2026-10-28 20:05:34 +00:00
|
|
|
<!-- Leaving the world is a quiet way out, not a tab. -->
|
|
|
|
|
<NuxtLink v-if="inWorld" to="/worlds" class="nav-link px-2" :title="t('app.change_world')">
|
|
|
|
|
<IconUi name="globe" class="size-4" />
|
|
|
|
|
<span class="hidden lg:inline">{{ t('app.change_world') }}</span>
|
|
|
|
|
</NuxtLink>
|
2026-10-28 19:22:53 +00:00
|
|
|
<button type="button" class="nav-link px-2" :title="t('app.logout')" @click="logout()">
|
2026-10-28 18:04:21 +00:00
|
|
|
<IconUi name="logout" class="size-4" />
|
|
|
|
|
<span class="hidden sm:inline">{{ t('app.logout') }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
<NuxtPage />
|
|
|
|
|
</main>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
|
|
|
|
<div class="pointer-events-none fixed inset-x-4 bottom-4 z-50 flex flex-col items-end gap-2">
|
|
|
|
|
<TransitionGroup
|
|
|
|
|
enter-from-class="translate-y-2 opacity-0"
|
|
|
|
|
leave-to-class="opacity-0"
|
|
|
|
|
enter-active-class="transition duration-200"
|
|
|
|
|
leave-active-class="transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
v-for="n in notices.list.value"
|
|
|
|
|
:key="n.id"
|
|
|
|
|
type="button"
|
2026-10-28 19:22:53 +00:00
|
|
|
class="pointer-events-auto w-full max-w-sm rounded-sm border-2 px-3 py-2 text-left text-sm shadow-hard"
|
2026-10-28 18:04:21 +00:00
|
|
|
:class="toastTone[n.type]"
|
|
|
|
|
@click="notices.dismiss(n.id)"
|
|
|
|
|
>
|
|
|
|
|
{{ n.text }}
|
|
|
|
|
</button>
|
|
|
|
|
</TransitionGroup>
|
|
|
|
|
</div>
|
2026-10-28 16:57:43 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2026-10-28 19:22:53 +00:00
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
@reference "~/assets/css/main.css";
|
|
|
|
|
|
|
|
|
|
.nav-link {
|
|
|
|
|
@apply inline-flex items-center gap-1.5 rounded-sm border border-transparent px-3 py-1.5 text-sm font-semibold text-parchment-100 transition-colors hover:border-wood-600 hover:bg-wood-800 focus-visible:outline-2 focus-visible:outline-gold-500;
|
|
|
|
|
}
|
|
|
|
|
.nav-link-active {
|
|
|
|
|
@apply border-gold-600 bg-wood-800 text-gold-400;
|
|
|
|
|
}
|
|
|
|
|
</style>
|