2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<button
|
2022-07-15 07:23:55 +00:00
|
|
|
:class="{ active: mode !== 'NO_REPEAT' }"
|
2022-05-29 21:37:56 +00:00
|
|
|
:title="`Change repeat mode (current mode: ${readableMode})`"
|
2022-04-25 13:08:00 +00:00
|
|
|
class="control"
|
2022-04-15 14:24:30 +00:00
|
|
|
data-testid="repeat-mode-switch"
|
2022-04-25 13:08:00 +00:00
|
|
|
type="button"
|
2022-05-29 21:37:56 +00:00
|
|
|
@click.prevent="changeMode"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-07-15 07:23:55 +00:00
|
|
|
<FontAwesomeLayers>
|
|
|
|
<icon :icon="faRepeat"/>
|
|
|
|
<FontAwesomeLayersText v-if="mode === 'REPEAT_ONE'" counter value="1"/>
|
|
|
|
</FontAwesomeLayers>
|
2022-04-15 14:24:30 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { FontAwesomeLayers, FontAwesomeLayersText } from '@fortawesome/vue-fontawesome'
|
|
|
|
import { faRepeat } from '@fortawesome/free-solid-svg-icons'
|
2022-04-25 13:08:00 +00:00
|
|
|
import { computed, 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-05-29 21:37:56 +00:00
|
|
|
const readableMode = 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-05-29 21:37:56 +00:00
|
|
|
const changeMode = () => playbackService.changeRepeatMode()
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-07-15 07:23:55 +00:00
|
|
|
.fa-layers-counter {
|
|
|
|
transform: none;
|
|
|
|
font-size: .45rem;
|
|
|
|
font-weight: bold;
|
|
|
|
right: 2px;
|
|
|
|
top: 2px;
|
|
|
|
color: var(--color-highlight);
|
|
|
|
background: transparent;
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-15 07:23:55 +00:00
|
|
|
.active {
|
|
|
|
color: var(--color-highlight);
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|