2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<button
|
|
|
|
class="control"
|
2022-04-20 15:57:53 +00:00
|
|
|
:class="mode"
|
2022-04-15 14:24:30 +00:00
|
|
|
@click.prevent="changeRepeatMode"
|
|
|
|
:title="`Change repeat mode (current mode: ${readableRepeatMode})`"
|
|
|
|
data-testid="repeat-mode-switch"
|
|
|
|
>
|
|
|
|
<i class="fa fa-repeat"></i>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-20 15:57:53 +00:00
|
|
|
import { computed, reactive, toRef } from 'vue'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { playbackService } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { preferenceStore } from '@/stores'
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
const mode = toRef(preferenceStore.state, 'repeatMode')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
const readableRepeatMode = computed(() => mode.value
|
2022-04-15 17:00:08 +00:00
|
|
|
.split('_')
|
|
|
|
.map(part => part[0].toUpperCase() + part.substring(1).toLowerCase())
|
|
|
|
.join(' ')
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:50:45 +00:00
|
|
|
const changeRepeatMode = () => playbackService.changeRepeatMode()
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
button {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&.REPEAT_ALL, &.REPEAT_ONE {
|
|
|
|
color: var(--color-highlight);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.REPEAT_ONE::after {
|
|
|
|
content: "1";
|
|
|
|
position: absolute;
|
|
|
|
display: flex;
|
|
|
|
place-content: center;
|
|
|
|
place-items: center;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
font-weight: 700;
|
|
|
|
font-size: .5rem;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|