2026-04-01 11:47:03 +04:00
|
|
|
<template>
|
|
|
|
|
<header class="masthead">
|
|
|
|
|
<div class="masthead-main">
|
2026-04-03 09:55:36 +04:00
|
|
|
<div class="masthead-brand">
|
|
|
|
|
<picture>
|
|
|
|
|
<source srcset="/logo.svg" type="image/svg+xml" />
|
|
|
|
|
<img class="masthead-logo" src="/logo.png" :alt="competitionTitle" />
|
|
|
|
|
</picture>
|
2026-04-01 11:47:03 +04:00
|
|
|
<p class="masthead-subtitle">{{ t('subtitle') }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="masthead-controls">
|
2026-04-03 09:55:36 +04:00
|
|
|
<div ref="controlsRoot" class="controls-popup-anchor">
|
|
|
|
|
<div class="control-toggle-row">
|
|
|
|
|
<button class="control-toggle-btn" type="button" :aria-expanded="controlsOpen ? 'true' : 'false'" @click="toggleControls">
|
|
|
|
|
<span>{{ optionsLabel }}</span>
|
|
|
|
|
<span class="control-toggle-meta">{{ modeShort }} · {{ languageShort }}</span>
|
|
|
|
|
</button>
|
2026-04-01 11:47:03 +04:00
|
|
|
</div>
|
|
|
|
|
|
2026-04-03 09:55:36 +04:00
|
|
|
<Transition name="controls-reveal">
|
|
|
|
|
<div v-if="controlsOpen" class="controls-grid controls-popover">
|
|
|
|
|
<div class="control-box">
|
|
|
|
|
<p class="control-label">{{ t('labels.mode') }}</p>
|
|
|
|
|
<div class="language-switcher mode-switcher">
|
|
|
|
|
<button class="lang-btn" :class="{ active: mode === 'view' }" @click="changeMode('view')">{{ t('viewMode') }}</button>
|
|
|
|
|
<button class="lang-btn" :class="{ active: mode === 'live' }" @click="changeMode('live')">{{ t('liveMode') }}</button>
|
|
|
|
|
<button class="lang-btn" :class="{ active: mode === 'admin' }" @click="changeMode('admin')">{{ t('adminMode') }}</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="control-box">
|
|
|
|
|
<p class="control-label">{{ t('labels.language') }}</p>
|
|
|
|
|
<div class="language-switcher">
|
|
|
|
|
<button class="lang-btn" :class="{ active: language === 'ar' }" @click="changeLanguage('ar')">العربية</button>
|
|
|
|
|
<button class="lang-btn" :class="{ active: language === 'en' }" @click="changeLanguage('en')">English</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-04-01 11:47:03 +04:00
|
|
|
</div>
|
2026-04-03 09:55:36 +04:00
|
|
|
</Transition>
|
2026-04-01 11:47:03 +04:00
|
|
|
</div>
|
|
|
|
|
<div class="status-row">
|
2026-04-03 09:55:36 +04:00
|
|
|
<div class="live-badge">{{ modeStatusLabel }}</div>
|
2026-04-01 11:47:03 +04:00
|
|
|
<div class="server-time" v-if="serverTime">{{ t('labels.lastSync') }}: {{ serverTime }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-04-03 09:55:36 +04:00
|
|
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
2026-04-01 11:47:03 +04:00
|
|
|
t: { type: Function, required: true },
|
|
|
|
|
competitionTitle: { type: String, required: true },
|
|
|
|
|
mode: { type: String, required: true },
|
|
|
|
|
language: { type: String, required: true },
|
|
|
|
|
serverTime: { type: String, default: '' },
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-03 09:55:36 +04:00
|
|
|
const emit = defineEmits(['change-mode', 'change-language'])
|
|
|
|
|
|
|
|
|
|
const controlsOpen = ref(false)
|
|
|
|
|
const controlsRoot = ref(null)
|
|
|
|
|
|
|
|
|
|
const optionsLabel = computed(() => (props.language === 'ar' ? 'خيارات' : 'Options'))
|
|
|
|
|
const modeShort = computed(() => {
|
|
|
|
|
if (props.mode === 'view') return props.language === 'ar' ? 'عرض' : 'View'
|
|
|
|
|
if (props.mode === 'live') return props.language === 'ar' ? 'حي' : 'Live'
|
|
|
|
|
return props.language === 'ar' ? 'إدارة' : 'Admin'
|
|
|
|
|
})
|
|
|
|
|
const languageShort = computed(() => (props.language === 'ar' ? 'AR' : 'EN'))
|
|
|
|
|
const modeStatusLabel = computed(() => {
|
|
|
|
|
if (props.mode === 'view') return '● ' + props.t('labels.liveTracker')
|
|
|
|
|
if (props.mode === 'live') return '● ' + props.t('liveMode')
|
|
|
|
|
return props.t('adminPanel')
|
|
|
|
|
})
|
2026-04-01 11:47:03 +04:00
|
|
|
|
2026-04-03 09:55:36 +04:00
|
|
|
function toggleControls() {
|
|
|
|
|
controlsOpen.value = !controlsOpen.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeMode(nextMode) {
|
|
|
|
|
emit('change-mode', nextMode)
|
|
|
|
|
controlsOpen.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeLanguage(nextLanguage) {
|
|
|
|
|
emit('change-language', nextLanguage)
|
|
|
|
|
controlsOpen.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onGlobalPointerDown(event) {
|
|
|
|
|
if (!controlsOpen.value) return
|
|
|
|
|
const root = controlsRoot.value
|
|
|
|
|
if (root && !root.contains(event.target)) controlsOpen.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onGlobalKeyDown(event) {
|
|
|
|
|
if (event.key === 'Escape') controlsOpen.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
window.addEventListener('pointerdown', onGlobalPointerDown)
|
|
|
|
|
window.addEventListener('keydown', onGlobalKeyDown)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
window.removeEventListener('pointerdown', onGlobalPointerDown)
|
|
|
|
|
window.removeEventListener('keydown', onGlobalKeyDown)
|
|
|
|
|
})
|
|
|
|
|
</script>
|