Improve /stp layout on small screens

- Listening and Steam: fit the artwork to the cell instead of scrolling.
  The image is now a flexible item that takes the height left over after
  the text, so a wide/short cell or a wrapped title can no longer overflow.
- Below 1360px the two sidebars collapse into one tabbed panel (Chat,
  Bookmarks, Commits, Steam) under the sheet instead of a long stack of
  individually scrolling boxes. CSS-only: widgets stay mounted once.
- Phone: clamp song/artist to one line and give the grid a minimum
  height so album art stays visible on short screens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-01 15:15:10 +01:00
co-authored by Claude Opus 5.5
parent 8d7606bbe8
commit 76735f0552
3 changed files with 148 additions and 34 deletions
+98 -19
View File
@@ -7,6 +7,13 @@
* class and the three breakpoints below (desktop / <=1360px tablet / <=700px * class and the three breakpoints below (desktop / <=1360px tablet / <=700px
* phone) re-draw the whole area map rather than moving elements around. * phone) re-draw the whole area map rather than moving elements around.
* *
* Below 1360px there is no room for the sidebars, so their widgets collapse
* into a single tabbed panel under the sheet. That is done purely in CSS — the
* tab bar only sets `data-tab` on the wrapper and the media query hides the
* other widgets — so every widget stays mounted exactly once at every width
* (Chat holds a WebSocket, Steam a rotation timer) and resizing across the
* breakpoint loses no state.
*
* The widgets do not fetch individually — they all read stores/homeData.js, which * The widgets do not fetch individually — they all read stores/homeData.js, which
* issues one GraphQL query for the whole page. * issues one GraphQL query for the whole page.
* *
@@ -30,11 +37,36 @@ import Gym2 from "./Gym2.vue";
import Consumption from "./Consumption.vue"; import Consumption from "./Consumption.vue";
import Steam from "./Steam.vue"; import Steam from "./Steam.vue";
import Bookmarks from "./Bookmarks.vue"; import Bookmarks from "./Bookmarks.vue";
import { ref } from "vue";
// Small-screen tab bar. `id` matches the [data-tab] selectors in the tablet
// media query below.
const TABS = [
{ id: "chat", label: "Chat" },
{ id: "bookmarks", label: "Bookmarks" },
{ id: "commits", label: "Commits" },
{ id: "steam", label: "Steam" },
];
const activeTab = ref("chat");
</script> </script>
<template> <template>
<main class="justify-center flex flex-row w-full h-full overflow-x-hidden"> <main class="justify-center flex flex-row w-full h-full overflow-x-hidden">
<div class="outerWrap flex flex-row"> <div class="outerWrap flex flex-row" :data-tab="activeTab">
<nav class="widget-tabs" aria-label="Widgets">
<button
v-for="tab in TABS"
:key="tab.id"
type="button"
class="widget-tab"
:class="{ 'is-active': activeTab === tab.id }"
:aria-pressed="activeTab === tab.id"
@click="activeTab = tab.id"
>
{{ tab.label }}
</button>
</nav>
<div class="sidebar"> <div class="sidebar">
<Time class="time-sidebar cell" /> <Time class="time-sidebar cell" />
<Timer class="timer-sidebar cell" /> <Timer class="timer-sidebar cell" />
@@ -150,42 +182,87 @@ import Bookmarks from "./Bookmarks.vue";
height: 15rem; height: 15rem;
} }
/* Tablet: sidebars stack below the sheet */ /* Small-screen only; switched on in the tablet media query */
.widget-tabs {
display: none;
}
.widget-tab {
flex: 1;
min-width: 0;
padding: 0.5rem 0.25rem;
color: var(--color-primary);
background-color: var(--color-link-bg);
border: 2px solid var(--color-quaternary);
font-family: var(--font-heading);
font-size: 1.125rem;
letter-spacing: 0.025em;
cursor: pointer;
transition:
background-color 120ms ease,
border-color 120ms ease,
color 120ms ease;
}
.widget-tab:hover {
border-color: var(--color-primary);
}
.widget-tab.is-active {
border-color: var(--color-primary);
color: var(--color-tertiary);
background-color: var(--color-surface-tint);
}
/* Tablet: the sidebars collapse into one tabbed panel below the sheet */
@media (max-width: 1360px) { @media (max-width: 1360px) {
.outerWrap { .outerWrap {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
height: auto; height: auto;
gap: 5px;
padding-bottom: 10px;
} }
/* Visual order is sheet, tab bar, selected widget — whatever the DOM order */
.homeGrid { .homeGrid {
order: -1; order: -2;
width: 95vw; width: 95vw;
height: 297mm; height: 297mm;
margin-inline: 0; margin-inline: 0;
box-sizing: border-box; box-sizing: border-box;
} }
.sidebar { .widget-tabs {
order: -1;
display: flex;
gap: 5px;
width: 95vw; width: 95vw;
flex-direction: column; margin-top: 5px;
align-items: center;
flex: unset;
justify-content: space-around;
} }
.commits-sidebar, /* The two sidebars stop being boxes, so their widgets become direct flex
.steam-sidebar, children of .outerWrap and the one selected widget sits under the tabs. */
.bookmarks-sidebar { .sidebar {
width: 100%; display: contents;
max-height: 300px;
} }
.chat-sidebar { /* One fixed panel size for every tab, so switching doesn't make the page
width: 100%; jump. The .outerWrap prefix is for specificity: it has to beat the
min-height: 400px; widgets' own scoped height rules (Steam's 54mm, Chat's 100%). */
max-height: 800px; .outerWrap .commits-sidebar,
height: 25vh; .outerWrap .steam-sidebar,
.outerWrap .bookmarks-sidebar,
.outerWrap .chat-sidebar {
flex: none;
width: 95vw;
height: clamp(360px, 70vh, 640px);
max-height: none;
}
.outerWrap:not([data-tab="commits"]) .commits-sidebar,
.outerWrap:not([data-tab="steam"]) .steam-sidebar,
.outerWrap:not([data-tab="bookmarks"]) .bookmarks-sidebar,
.outerWrap:not([data-tab="chat"]) .chat-sidebar {
display: none;
} }
.time-sidebar, .time-sidebar,
@@ -203,7 +280,9 @@ import Bookmarks from "./Bookmarks.vue";
border-width: 0; border-width: 0;
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr);
height: 150vh; /* The floor keeps the 11 rows usable on short phones, where 150vh alone
leaves the two-row Listening cell too small to show its album art. */
height: max(150vh, 1000px);
grid-template-areas: grid-template-areas:
"intro intro intro" "intro intro intro"
"intro intro intro" "intro intro intro"
+34 -5
View File
@@ -72,7 +72,7 @@ onMounted(() => {
<div <div
@click="nextSong" @click="nextSong"
:key="song.track.name" :key="song.track.name"
class="flex flex-col items-center" class="song flex flex-col items-center"
> >
<img <img
:src="song.track.album.images[0].url" :src="song.track.album.images[0].url"
@@ -109,16 +109,45 @@ onMounted(() => {
position: relative; position: relative;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
overflow-y: auto; overflow: hidden;
}
/* The cell's size is fixed by the home grid, so the content has to fit it
rather than scroll: the text keeps its natural height and the album art takes
whatever is left. Sizing the art by width instead (it is square) overflows
as soon as the cell is wider than it is tall or a title wraps. */
.song {
height: 100%;
padding: 0.25rem;
box-sizing: border-box;
} }
img { img {
width: 70%; flex: 1 1 0;
max-width: 100%; min-height: 0;
height: auto; width: 100%;
object-fit: contain;
} }
p { p {
flex-shrink: 0;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
/* Two lines at most, so a long title can't squeeze the art down to nothing
in the narrow phone cell. */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
}
/* Phone: the cell is one narrow column, where four lines of text would leave
almost nothing for the art. */
@media (max-width: 700px) {
p {
font-size: 0.875rem;
-webkit-line-clamp: 1;
line-clamp: 1;
}
} }
</style> </style>
+16 -10
View File
@@ -54,7 +54,7 @@ function formatHours(minutes) {
<div <div
@click="nextGame" @click="nextGame"
:key="game.appId" :key="game.appId"
class="flex flex-col items-center pt-2" class="game flex flex-col items-center pt-2"
> >
<img <img
:src="game.headerImageUrl" :src="game.headerImageUrl"
@@ -89,24 +89,30 @@ function formatHours(minutes) {
position: relative; position: relative;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
overflow-y: scroll; 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 { .game-img {
flex: 0 1 auto;
min-height: 0;
width: 90%; width: 90%;
max-width: 300px; max-width: 460px; /* Steam header images are 460x215 */
height: auto; height: auto;
object-fit: contain;
} }
p { p {
flex-shrink: 0;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
} }
@media (max-width: 850px) {
.steam-wrapper {
height: auto;
min-height: 120px;
}
}
</style> </style>