safetwitch/src/views/CategoryView.vue

72 lines
2.0 KiB
Vue
Raw Normal View History

2023-03-19 19:51:55 -04:00
<script lang="ts">
import { useRoute } from 'vue-router'
2023-03-31 07:50:46 -04:00
import StreamPreviewVue from '@/components/StreamPreview.vue'
2023-03-19 19:51:55 -04:00
export default {
2023-03-19 19:51:55 -04:00
async setup() {
2023-04-08 20:04:28 -04:00
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
2023-03-19 19:51:55 -04:00
const route = useRoute()
const game = route.params.game
2023-04-08 20:04:28 -04:00
const res = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/discover/${game}`)
const data = await res.json()
2023-04-08 20:04:28 -04:00
let frontend_url = protocol + import.meta.env.VITE_INSTANCE_DOMAIN
2023-03-19 19:51:55 -04:00
return {
data,
frontend_url
2023-03-19 19:51:55 -04:00
}
},
methods: {
abbreviate(text: number) {
return Intl.NumberFormat('en-US', {
//@ts-ignore
notation: 'compact',
maximumFractionDigits: 1
}).format(text)
2023-03-19 19:51:55 -04:00
}
2023-03-31 07:50:46 -04:00
},
components: {
StreamPreviewVue
2023-03-19 19:51:55 -04:00
}
}
</script>
<template>
<div class="flex flex-col max-w-5xl mx-auto">
<div class="flex space-x-4 p-3">
<img :src="data.cover" class="self-start rounded-md" />
2023-03-19 19:51:55 -04:00
<div>
<h1 class="font-bold text-5xl text-white">{{ data.name }}</h1>
<div class="inline-flex my-1 space-x-3">
<p class="font-bold text-white text-lg">Followers: {{ abbreviate(data.followers) }}</p>
<p class="font-bold text-white text-lg">Viewers: {{ abbreviate(data.viewers) }}</p>
2023-03-19 19:51:55 -04:00
</div>
<ul class="mb-5">
<li v-for="tag in data.tags" :key="tag" class="inline-flex">
<span class="text-white p-1 py-0.5 mr-1 text-sm font-bold bg-ctp-overlay1 rounded-sm">{{
tag
}}</span>
</li>
</ul>
<p class="text-md text-gray-400 overflow-y-auto">{{ data.description }}</p>
</div>
2023-03-19 19:51:55 -04:00
</div>
<div class="max-w-[58rem] mx-auto">
<ul>
<li
v-for="stream in data.streams"
:key="stream"
class="inline-flex m-2 hover:scale-105 transition-transform"
>
2023-03-31 07:50:46 -04:00
<StreamPreviewVue :stream="stream"></StreamPreviewVue>
</li>
</ul>
2023-03-19 19:51:55 -04:00
</div>
</div>
</template>