mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-14 15:54:13 +01:00
53 lines
2.1 KiB
Vue
53 lines
2.1 KiB
Vue
<script lang="ts" setup>
|
|
import { type Activity, IDEs } from '~~/types'
|
|
|
|
const { data: activity, refresh } = await useAsyncData<Activity>('activity', () => $fetch('/api/activity'))
|
|
useIntervalFn(async () => await refresh(), 5000)
|
|
const codingActivity = computed(() => activity.value!.data.activities.filter(activity => IDEs.some(ide => ide.name === activity.name))[0])
|
|
|
|
function formatDate(date: number) {
|
|
return `${useDateFormat(date, 'DD MMM YYYY').value} at ${useDateFormat(date, 'HH:mm:ss').value}`
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<p
|
|
v-if="codingActivity"
|
|
class="flex items-start gap-2"
|
|
>
|
|
<UTooltip :text="codingActivity.state.toLowerCase().includes('editing') ? 'I\'m online 👋' : 'I\'m sleeping 😴'">
|
|
<div class="relative flex h-3 w-3 mt-2">
|
|
<div
|
|
v-if="codingActivity.state.toLowerCase().includes('editing')"
|
|
class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-500 opacity-75"
|
|
/>
|
|
<div
|
|
:class="codingActivity.state.toLowerCase().includes('editing') ? 'bg-green-500' : 'bg-amber-500'"
|
|
class="relative inline-flex rounded-full h-3 w-3"
|
|
/>
|
|
</div>
|
|
</UTooltip>
|
|
<span v-if="codingActivity.state.toLowerCase().includes('editing')">
|
|
I'm actually working on <strong>{{ codingActivity.details }}</strong>,
|
|
{{ codingActivity.state.charAt(0).toLowerCase() + codingActivity.state.slice(1) }}.
|
|
using <strong>{{ codingActivity.name }}</strong>.
|
|
I've started <strong>{{ useTimeAgo(codingActivity.timestamps.start).value }}</strong>, the
|
|
<strong>{{ formatDate(codingActivity.timestamps.start) }}</strong>.
|
|
</span>
|
|
<span v-else>
|
|
I'm Idling on my computer with <strong>{{ codingActivity.name }}</strong> running in background.
|
|
</span>
|
|
</p>
|
|
<div
|
|
v-else
|
|
class="my-5 flex md:items-start gap-2"
|
|
>
|
|
<UTooltip text="I'm offline 🫥">
|
|
<span class="cursor-not-allowed h-3 w-3 inline-flex rounded-full bg-red-500 mt-2" />
|
|
</UTooltip>
|
|
<p class="not-prose">
|
|
I'm currently offline. Come back later to see what I'm working on.
|
|
</p>
|
|
</div>
|
|
</template>
|