2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<article
|
2022-04-15 14:24:30 +00:00
|
|
|
:class="{ selected: theme.selected }"
|
|
|
|
:style="thumbnailStyles"
|
2022-11-29 10:18:58 +00:00
|
|
|
:title="`Set current theme to ${name}`"
|
2024-04-04 22:20:42 +00:00
|
|
|
class="theme h-[96px] bg-center bg-cover relative cursor-pointer rounded-lg overflow-hidden border-2 border-solid border-white/10 transition duration-300 hover:border-white/50]"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2024-04-04 22:20:42 +00:00
|
|
|
<button
|
|
|
|
class="opacity-0 hover:opacity-100 absolute h-full w-full top-0 left-0 flex items-center justify-center text-lg transition-opacity bg-black/20"
|
2024-04-23 21:01:27 +00:00
|
|
|
type="button"
|
2024-04-04 22:20:42 +00:00
|
|
|
@click="$emit('selected', theme)"
|
|
|
|
>
|
|
|
|
{{ name }}
|
|
|
|
</button>
|
|
|
|
</article>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-21 22:51:48 +00:00
|
|
|
import { toRefs } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { slugToTitle } from '@/utils'
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = defineProps<{ theme: Theme }>()
|
|
|
|
const { theme } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
const emit = defineEmits<{ (e: 'selected', theme: Theme): void }>()
|
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
const name = theme.value.name ? theme.value.name : slugToTitle(theme.value.id)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
const thumbnailStyles: Record<string, string> = {
|
|
|
|
'background-color': theme.value.thumbnailColor
|
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
if (theme.value.thumbnailUrl) {
|
|
|
|
thumbnailStyles['background-image'] = `url(${theme.value.thumbnailUrl})`
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2024-04-04 22:20:42 +00:00
|
|
|
.theme.selected {
|
|
|
|
@apply border-white/50;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|