Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | 86x 1x 1x 1x 78x 78x 78x 2x 1x 1x 78x 83x 83x 80x 78x | <template>
<Teleport to="body">
<div
v-if="open"
class="space-overlay"
role="dialog"
aria-modal="true"
:aria-label="label"
data-testid="space-overlay"
@click.self="emit('close')"
>
<button
type="button"
class="space-overlay-button space-overlay-close"
:aria-label="t('common.close')"
data-testid="space-overlay-close"
@click="emit('close')"
>
<font-awesome-icon icon="fa-solid fa-xmark" />
</button>
<button
v-if="navigable"
type="button"
class="space-overlay-button space-overlay-prev"
:aria-label="t('spacePages.previous')"
data-testid="space-overlay-prev"
@click="emit('prev')"
>
<font-awesome-icon icon="fa-solid fa-chevron-left" />
</button>
<div class="space-overlay-content" :class="{ 'space-overlay-panel': panel }">
<slot />
</div>
<button
v-if="navigable"
type="button"
class="space-overlay-button space-overlay-next"
:aria-label="t('spacePages.next')"
data-testid="space-overlay-next"
@click="emit('next')"
>
<font-awesome-icon icon="fa-solid fa-chevron-right" />
</button>
</div>
</Teleport>
</template>
<script setup lang="ts">
// @implements UC-SPACE-011.1, UC-SPACE-012.1
/**
* A full-screen layer of the space pages: an item's details, a gallery image.
* Escape closes it; the arrow keys move to the previous and next ones when
* `navigable`.
*/
import { onBeforeUnmount, watch } from 'vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { useUILanguage } from '@/composables/useUILanguage'
const props = withDefaults(
defineProps<{
open: boolean
label: string
navigable?: boolean
/** A light panel (an item's details) rather than a dark backdrop only (an image) */
panel?: boolean
}>(),
{ navigable: false, panel: false }
)
const emit = defineEmits<{ close: []; prev: []; next: [] }>()
const { t } = useUILanguage()
function onKey(event: KeyboardEvent) {
if (event.key === 'Escape') emit('close')
else Iif (props.navigable && event.key === 'ArrowLeft') emit('prev')
else Eif (props.navigable && event.key === 'ArrowRight') emit('next')
}
watch(
() => props.open,
(open) => {
if (open) document.addEventListener('keydown', onKey)
else document.removeEventListener('keydown', onKey)
},
{ immediate: true }
)
onBeforeUnmount(() => document.removeEventListener('keydown', onKey))
</script>
<style scoped>
.space-overlay {
position: fixed;
inset: 0;
z-index: 2000;
background: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
padding: 3rem 1rem;
}
.space-overlay-content {
max-width: min(1000px, 100%);
max-height: 100%;
overflow: auto;
}
.space-overlay-panel {
background: var(--space-background, #fff);
color: var(--space-text, #212529);
border-radius: 12px;
padding: 1.5rem;
width: min(720px, 100%);
}
.space-overlay-button {
position: absolute;
border: 0;
background: rgba(255, 255, 255, 0.15);
color: #fff;
width: 44px;
height: 44px;
border-radius: 50%;
font-size: 1.25rem;
}
.space-overlay-button:hover,
.space-overlay-button:focus-visible {
background: rgba(255, 255, 255, 0.3);
}
.space-overlay-close {
top: 0.75rem;
right: 0.75rem;
}
.space-overlay-prev {
left: 0.5rem;
top: 50%;
transform: translateY(-50%);
}
.space-overlay-next {
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
}
</style>
|