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') {
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');
@@ -84,19 +101,18 @@ const isEnded = computed(() => status.value === 'ended');
</div>
</c-card>
<Countdown :deadline="alarmAtFormatted" :stop="status !== 'running'" mb-2 @time-elapsed="ended()" />
<n-p align="center">
Alarm at: {{ alarmAtDate }}
</n-p>
<div mb-2 flex justify-center>
<c-button
:disabled="status === 'stopped'"
@click="stop"
>
Stop
</c-button>
<div id="fullScreenElement" ref="fullScreenElement" mb-2>
<div>
<Countdown :deadline="alarmAtFormatted" :stop="status !== 'running'" mb-2 countdown-size="5rem" @time-elapsed="ended()" />
<div mb-2 flex justify-center>
<c-button
:disabled="status === 'stopped'"
@click="toggleFullScreen"
>
Toggle Fullscreen
</c-button>
</div>
</div>
</div>
<n-modal v-model:show="isEnded" mask-closable="false">
@@ -117,6 +133,19 @@ const isEnded = computed(() => status.value === 'ended');
</n-card>
</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">
<div flex justify-center gap-1>
<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" />
</div>
</template>
<style scoped>
#fullScreenElement:fullscreen {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
</style>