koel/resources/assets/js/components/ui/ViewModeSwitch.vue

69 lines
1.7 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<span class="view-modes">
<label
:class="{ active: value === 'thumbnails' }"
2022-04-15 14:24:30 +00:00
class="thumbnails"
2022-05-03 16:51:59 +00:00
data-testid="view-mode-thumbnail"
title="View as thumbnails"
2022-04-15 14:24:30 +00:00
>
<input v-model="value" class="hidden" name="view-mode" type="radio" value="thumbnails">
2022-07-15 07:23:55 +00:00
<icon :icon="faThumbnailsHehe"/>
2022-04-15 14:24:30 +00:00
<span class="hidden">View as thumbnails</span>
</label>
<label
:class="{ active: value === 'list' }"
2022-04-15 14:24:30 +00:00
class="list"
2022-05-03 16:51:59 +00:00
data-testid="view-mode-list"
title="View as list"
2022-04-15 14:24:30 +00:00
>
<input v-model="value" class="hidden" name="view-mode" type="radio" value="list">
2022-07-15 07:23:55 +00:00
<icon :icon="faList"/>
2022-04-15 14:24:30 +00:00
<span class="hidden">View as list</span>
</label>
</span>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-07-15 07:23:55 +00:00
import { faMicrosoft as faThumbnailsHehe } from '@fortawesome/free-brands-svg-icons'
import { faList } from '@fortawesome/free-solid-svg-icons'
2022-04-30 08:11:01 +00:00
import { computed } from 'vue'
2022-04-15 14:24:30 +00:00
2022-05-29 21:36:45 +00:00
const props = withDefaults(defineProps<{ modelValue?: ArtistAlbumViewMode }>(), { modelValue: 'thumbnails' })
const emit = defineEmits(['update:modelValue'])
2022-04-15 14:24:30 +00:00
const value = computed({
2022-05-29 21:36:45 +00:00
get: () => props.modelValue,
set: value => emit('update:modelValue', 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%;
2022-07-15 07:23:55 +00:00
display: flex;
align-items: center;
justify-content: center;
height: 2rem;
2022-04-15 14:24:30 +00:00
margin-bottom: 0;
cursor: pointer;
&.active {
background: var(--color-text-primary);
color: var(--color-bg-primary);
}
}
2022-10-09 08:32:22 +00:00
@media only screen and (max-width: 768px) {
2022-04-15 14:24:30 +00:00
margin-top: 8px;
}
}
</style>