2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<span class="view-modes">
|
|
|
|
<label
|
|
|
|
class="thumbnails"
|
2022-04-15 17:00:08 +00:00
|
|
|
:class="{ active: modelValue === 'thumbnails' }"
|
2022-04-15 14:24:30 +00:00
|
|
|
title="View as thumbnails"
|
|
|
|
data-test="view-mode-thumbnail"
|
|
|
|
>
|
2022-04-15 17:00:08 +00:00
|
|
|
<input class="hidden" type="radio" value="thumbnails" v-model="modelValue" @input="onInput">
|
2022-04-15 14:24:30 +00:00
|
|
|
<i class="fa fa-th-large"></i>
|
|
|
|
<span class="hidden">View as thumbnails</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label
|
|
|
|
class="list"
|
2022-04-15 17:00:08 +00:00
|
|
|
:class="{ active: modelValue === 'list' }"
|
2022-04-15 14:24:30 +00:00
|
|
|
title="View as list"
|
|
|
|
data-test="view-mode-list"
|
|
|
|
>
|
2022-04-15 17:00:08 +00:00
|
|
|
<input class="hidden" type="radio" v-model="modelValue" @input="onInput">
|
2022-04-15 14:24:30 +00:00
|
|
|
<i class="fa fa-list"></i>
|
|
|
|
<span class="hidden">View as list</span>
|
|
|
|
</label>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref, toRefs, watchEffect } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = defineProps<{ value: ArtistAlbumViewMode }>()
|
|
|
|
const { value } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
let modelValue = ref<ArtistAlbumViewMode>(null as unknown as ArtistAlbumViewMode)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
watchEffect(() => (modelValue.value = value.value))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const emit = defineEmits(['update:modelValue'])
|
|
|
|
const onInput = (e: InputEvent) => emit('update:modelValue', (e.target as HTMLInputElement).value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.view-modes {
|
|
|
|
display: flex;
|
|
|
|
width: 64px;
|
|
|
|
border: 1px solid rgba(255, 255, 255, .2);
|
|
|
|
border-radius: 5px;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
label {
|
|
|
|
width: 50%;
|
|
|
|
text-align: center;
|
|
|
|
line-height: 2rem;
|
|
|
|
font-size: 1rem;
|
|
|
|
margin-bottom: 0;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
background: var(--color-text-primary);
|
|
|
|
color: var(--color-bg-primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and(max-width: 768px) {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|