feat(Time Alarm): fullscreen mode

This commit is contained in:
ShareVB committed 2025-05-25 13:53:52 +02:00
1 parent 80a2fb78c3
commit f90a69c86c
1 file changed
+51 -13
+51 -13
View File
@@ -61,6 +61,23 @@ function ended() {
if (status.value === 'running') { if (status.value === 'running') {
status.value = 'ended'; status.value = 'ended';
} }
if (document.fullscreenElement) {
document.exitFullscreen?.();
}
}
const fullScreenElement = ref<HTMLElement>();
function toggleFullScreen() {
const element = fullScreenElement.value;
if (!element) {
return;
}
if (!document.fullscreenElement) {
element?.requestFullscreen();
}
else {
document.exitFullscreen?.();
}
} }
const isEnded = computed(() => status.value === 'ended'); const isEnded = computed(() => status.value === 'ended');
@@ -84,19 +101,18 @@ const isEnded = computed(() => status.value === 'ended');
</div> </div>
</c-card> </c-card>
<Countdown :deadline="alarmAtFormatted" :stop="status !== 'running'" mb-2 @time-elapsed="ended()" /> <div id="fullScreenElement" ref="fullScreenElement" mb-2>
<div>
<n-p align="center"> <Countdown :deadline="alarmAtFormatted" :stop="status !== 'running'" mb-2 countdown-size="5rem" @time-elapsed="ended()" />
Alarm at: {{ alarmAtDate }} <div mb-2 flex justify-center>
</n-p> <c-button
:disabled="status === 'stopped'"
<div mb-2 flex justify-center> @click="toggleFullScreen"
<c-button >
:disabled="status === 'stopped'" Toggle Fullscreen
@click="stop" </c-button>
> </div>
Stop </div>
</c-button>
</div> </div>
<n-modal v-model:show="isEnded" mask-closable="false"> <n-modal v-model:show="isEnded" mask-closable="false">
@@ -117,6 +133,19 @@ const isEnded = computed(() => status.value === 'ended');
</n-card> </n-card>
</n-modal> </n-modal>
<div mb-2 flex justify-center>
<c-button
:disabled="status === 'stopped'"
@click="stop"
>
Stop
</c-button>
</div>
<n-p align="center">
Alarm at: {{ alarmAtDate }}
</n-p>
<c-card v-if="history" title="History"> <c-card v-if="history" title="History">
<div flex justify-center gap-1> <div flex justify-center gap-1>
<template v-for="(entry, index) in history" :key="index"> <template v-for="(entry, index) in history" :key="index">
@@ -131,3 +160,12 @@ const isEnded = computed(() => status.value === 'ended');
<audio ref="audio" loop src="/Beep.mp3" /> <audio ref="audio" loop src="/Beep.mp3" />
</div> </div>
</template> </template>
<style scoped>
#fullScreenElement:fullscreen {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
</style>