- Global :focus-visible ring (text fields get a border instead) and a prefers-reduced-motion override; the navbar marquee stops for it too. - Button: disabled state and horizontal padding. - useCreateForm returns error and submitting, so the create forms show a refused save inline and can't double-submit; they, Login, CreatePlace and CreateUser are real <form>s so Enter submits from any field. - Admin: section list wraps on phones, Manage Users is a table with errors, Manage Radio confirms before deleting, page delete errors show inline. - Hard-coded Tailwind colours replaced with tokens; 404 image alt text and no forced scrollbars. Co-Authored-By: Claude Opus 5.5 <[email protected]>
120 lines
3.1 KiB
Vue
120 lines
3.1 KiB
Vue
<script setup>
|
|
/**
|
|
* Steam widget on /stp: online status plus a rotation through recent games
|
|
* (5s rotation, 5-minute re-poll, both from useRotation()). `settled` comes from
|
|
* homeData so the widget can tell "not fetched yet" from "fetched, nothing to
|
|
* show" — and, unlike `loaded`, it also turns true when the fetch fails, so the
|
|
* widget cannot sit on "Loading..." forever.
|
|
*/
|
|
import { computed } from "vue";
|
|
import { storeToRefs } from "pinia";
|
|
import { useSteamStore } from "@/stores/steam";
|
|
import { useHomeDataStore } from "@/stores/homeData";
|
|
import Header from "@/components/text/Header.vue";
|
|
import { useRotation } from "@/js/useRotation";
|
|
|
|
const ROTATE_MS = 5000;
|
|
const REFRESH_MS = 5 * 60 * 1000;
|
|
|
|
const steamStore = useSteamStore();
|
|
const { steamStatus } = storeToRefs(steamStore);
|
|
const homeData = useHomeDataStore();
|
|
const { settled } = storeToRefs(homeData);
|
|
|
|
const { idx, next: nextGame } = useRotation(
|
|
() => steamStatus.value.recentGames,
|
|
ROTATE_MS,
|
|
{ refresh: () => steamStore.fetchSteam(), refreshMs: REFRESH_MS },
|
|
);
|
|
|
|
const game = computed(() => steamStatus.value.recentGames[idx.value]);
|
|
|
|
function formatHours(minutes) {
|
|
const hrs = (minutes / 60).toFixed(1);
|
|
return `${hrs}h`;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="steam-wrapper">
|
|
<Header class="text-left">
|
|
<span class="flex items-center gap-2">
|
|
Steam
|
|
<span
|
|
class="inline-block w-2 h-2 rounded-full"
|
|
:class="steamStatus.online ? 'bg-secondary' : 'bg-muted'"
|
|
:title="steamStatus.online ? 'Online' : 'Offline'"
|
|
/>
|
|
</span>
|
|
</Header>
|
|
|
|
<div v-if="!settled" class="p-2 text-sm">Loading...</div>
|
|
|
|
<div v-else-if="game" class="game-container">
|
|
<Transition name="fade">
|
|
<div
|
|
@click="nextGame"
|
|
:key="game.appId"
|
|
class="game flex flex-col items-center pt-2"
|
|
>
|
|
<img
|
|
:src="game.headerImageUrl"
|
|
:alt="game.name"
|
|
width="145"
|
|
height="68"
|
|
class="game-img"
|
|
/>
|
|
<p class="text-center">
|
|
<strong>{{ game.name }}</strong>
|
|
</p>
|
|
<p class="text-center text-tertiary text-xs">
|
|
{{ formatHours(game.playtime2Weeks) }} last 2 weeks
|
|
</p>
|
|
</div>
|
|
</Transition>
|
|
</div>
|
|
|
|
<div v-else class="p-2 text-sm">No recent games.</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.steam-wrapper {
|
|
position: relative;
|
|
height: 54mm;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.game-container {
|
|
position: relative;
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* Fit, don't scroll: the text keeps its natural height and the header image
|
|
shrinks into whatever is left of the widget's fixed height. It shrinks but
|
|
never grows (flex: 0 1 auto), so in the tall small-screen tab panel it stays
|
|
at its natural size next to the title instead of floating mid-box. */
|
|
.game {
|
|
height: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.game-img {
|
|
flex: 0 1 auto;
|
|
min-height: 0;
|
|
width: 90%;
|
|
max-width: 460px; /* Steam header images are 460x215 */
|
|
height: auto;
|
|
object-fit: contain;
|
|
}
|
|
|
|
p {
|
|
flex-shrink: 0;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
}
|
|
</style>
|