game-village-politics-frontend/app/components/ui/Window.vue

43 lines
1.9 KiB
Vue

<script setup lang="ts">
import type { RouteLocationRaw } from 'vue-router'
defineProps<{
title: string
/** Where the close cross leads. */
closeTo?: RouteLocationRaw
/** A close cross that only emits `close`. */
closable?: boolean
}>()
const emit = defineEmits<{ close: [] }>()
/** Folded to its title bar, so the village behind shows. */
const folded = defineModel<boolean>('folded', { default: false })
</script>
<!--
A window over the fullscreen village, docked to an edge by its parent: a title bar
with fold and close, and its content scrolling inside. Solid like every other frame.
Kept free of position logic so it can become draggable later.
-->
<template>
<section class="pointer-events-auto flex max-h-full min-h-0 flex-col border border-wood-900 bg-parchment-100 shadow-[3px_3px_0_0_rgba(43,29,14,1)]">
<header class="flex shrink-0 items-center gap-1 border-b border-wood-700 bg-parchment-300 px-2 py-0.5">
<span class="panel-title min-w-0 flex-1 truncate">{{ title }}</span>
<button type="button" class="btn btn-ghost px-1" :title="$t(folded ? 'window.unfold' : 'window.fold')" :aria-expanded="!folded" @click="folded = !folded">
<IconUi :name="folded ? 'plus' : 'minus'" class="size-3.5" />
<span class="sr-only">{{ $t(folded ? 'window.unfold' : 'window.fold') }}</span>
</button>
<NuxtLink v-if="closeTo" :to="closeTo" class="btn btn-ghost px-1" :title="$t('window.close')" @click="emit('close')">
<IconUi name="close" class="size-3.5" />
<span class="sr-only">{{ $t('window.close') }}</span>
</NuxtLink>
<button v-else-if="closable" type="button" class="btn btn-ghost px-1" :title="$t('window.close')" @click="emit('close')">
<IconUi name="close" class="size-3.5" />
<span class="sr-only">{{ $t('window.close') }}</span>
</button>
</header>
<div v-show="!folded" class="@container min-h-0 overflow-y-auto">
<slot />
</div>
</section>
</template>