advplyr.audiobookshelf-app/components/modals/SleepTimerModal.vue

69 lines
2 KiB
Vue
Raw Normal View History

2021-10-30 13:31:21 -05:00
<template>
<modals-modal v-model="show" :width="200" height="100%">
<template #outer>
<div class="absolute top-4 left-4 z-40">
<p class="text-white text-2xl truncate">Sleep Timer</p>
</div>
</template>
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
<div class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
<ul v-if="!sleepTimerRunning" class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
<template v-for="timeout in timeouts">
<li :key="timeout" class="text-gray-50 select-none relative py-4 pr-9 cursor-pointer hover:bg-black-400" role="option" @click="clickedOption(timeout)">
<div class="flex items-center justify-center">
<span class="font-normal ml-3 block truncate text-lg">{{ timeout }} min</span>
</div>
</li>
</template>
</ul>
<div v-else class="px-2 py-4">
<p class="mb-4 text-2xl font-mono text-center">{{ timeRemainingPretty }}</p>
<ui-btn @click="cancelSleepTimer" class="w-full">Cancel Timer</ui-btn>
</div>
</div>
</div>
</modals-modal>
</template>
<script>
export default {
props: {
value: Boolean,
currentTime: Number,
sleepTimerRunning: Boolean
},
data() {
return {}
},
computed: {
show: {
get() {
return this.value
},
set(val) {
this.$emit('input', val)
}
},
timeouts() {
return [1, 15, 30, 45, 60, 75, 90, 120]
},
timeRemainingPretty() {
return this.$secondsToTimestamp(this.currentTime / 1000)
}
},
methods: {
clickedOption(timeoutMin) {
var timeout = timeoutMin * 1000 * 60
this.show = false
this.$nextTick(() => this.$emit('change', timeout))
},
cancelSleepTimer() {
this.$emit('cancel')
this.show = false
}
},
mounted() {}
}
</script>