koel/resources/assets/js/components/meta/support-koel.vue

91 lines
1.9 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<div class="support-bar" v-if="shown">
<p>
Loving Koel? Please consider supporting its development via
<a href="https://github.com/users/phanan/sponsorship" target="_blank" rel="noopener">
GitHub Sponsors
</a>
and/or
<a href="https://opencollective.com/koel" target="_blank" rel="noopener">OpenCollective</a>.
</p>
<button @click.prevent="close">Hide</button>
<span class="sep"></span>
<button @click.prevent="stopBugging">Don't bug me again</button>
</div>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-04-15 14:24:30 +00:00
import isMobile from 'ismobilejs'
2022-04-15 17:00:08 +00:00
import { computed, ref } from 'vue'
2022-04-15 14:24:30 +00:00
import { eventBus } from '@/utils'
import { preferenceStore as preferences } from '@/stores'
const DELAY_UNTIL_SHOWN = 30 * 60 * 1000
let SUPPORT_BAR_TIMEOUT_HANDLE = 0
2022-04-15 17:00:08 +00:00
const shown = ref(false)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const canNag = computed(() => !isMobile.any && !preferences.supportBarNoBugging)
const setUpShowBarTimeout = () => {
SUPPORT_BAR_TIMEOUT_HANDLE = window.setTimeout(() => (shown.value = true), DELAY_UNTIL_SHOWN)
}
const close = () => {
shown.value = false
window.clearTimeout(SUPPORT_BAR_TIMEOUT_HANDLE)
}
const stopBugging = () => {
preferences.supportBarNoBugging = true
close()
}
eventBus.on('KOEL_READY', () => canNag.value && setUpShowBarTimeout())
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss" scoped>
.support-bar {
background: var(--color-bg-primary);
font-size: .9rem;
padding: .75rem 1rem;
display: flex;
color: rgba(255, 255, 255, .6);
z-index: 9;
> * + * {
margin-left: 1rem;
}
p {
flex: 1;
}
a {
color: var(--color-text-primary);
&:hover {
color: var(--color-highlight);
}
}
.sep {
display: block;
&::after {
content: '•';
display: block;
}
}
button {
color: var(--color-text-primary);
font-size: .9rem;
&:hover {
color: var(--color-highlight);
}
}
}
</style>