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

72 lines
2.2 KiB
Vue
Raw Permalink Normal View History

<script setup lang="ts">
defineProps<{
title: string
collapsed?: boolean
/** Incoming attacks: the band in oxblood. */
alarm?: boolean
/** Floats over the village: offers a way back into the dock. */
floating?: boolean
/** Can be dragged (wide screens). */
draggable?: boolean
}>()
const emit = defineEmits<{ grab: [e: PointerEvent]; toggle: []; dock: [] }>()
</script>
<!--
One box of a dock: its header folds it with a click and drags it with the pointer (to
another place in the dock, or out to float anywhere); a floating box has a way back.
-->
<template>
<section class="dock-card" :class="alarm ? 'border-blood-700' : 'border-wood-700'">
<header
class="panel-head panel-title flex select-none items-center gap-1 py-0.5"
:class="[alarm ? 'dock-alarm' : '', draggable ? 'cursor-grab active:cursor-grabbing' : 'cursor-pointer']"
@pointerdown="emit('grab', $event)"
>
<span class="min-w-0 flex-1 truncate">{{ title }}</span>
<slot name="extra" />
<button
v-if="floating"
type="button"
class="btn btn-ghost px-1 normal-case"
:class="alarm ? 'text-parchment-50' : ''"
:title="$t('window.dock')"
@pointerdown.stop
@click.stop="emit('dock')"
>
<IconUi name="return" class="size-3.5" />
<span class="sr-only">{{ $t('window.dock') }}</span>
</button>
<button
type="button"
class="btn btn-ghost px-1"
:class="alarm ? 'text-parchment-50' : ''"
:title="$t(collapsed ? 'window.unfold' : 'window.fold')"
:aria-expanded="!collapsed"
@pointerdown.stop
@click.stop="emit('toggle')"
>
<IconUi :name="collapsed ? 'plus' : 'minus'" class="size-3.5" />
<span class="sr-only">{{ $t(collapsed ? 'window.unfold' : 'window.fold') }}</span>
</button>
</header>
<div v-show="!collapsed">
<slot />
</div>
</section>
</template>
<style scoped>
@reference "~/assets/css/main.css";
.dock-card {
@apply border bg-parchment-50;
background-image: var(--pat-parchment-50);
}
/* Incoming attacks: the band in oxblood, no cloth texture. */
.dock-alarm {
@apply border-blood-800 bg-blood-700 text-parchment-50;
background-image: none;
}
</style>