Author SHA1 Message Date
adamfandClaude Opus 5.5 76735f0552 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]>
2026-10-01 15:15:10 +01:00
4 changed files with 170 additions and 113 deletions
+98 -19
View File
@@ -7,6 +7,13 @@
* class and the three breakpoints below (desktop / <=1360px tablet / <=700px
* 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
* issues one GraphQL query for the whole page.
*
@@ -30,11 +37,36 @@ import Gym2 from "./Gym2.vue";
import Consumption from "./Consumption.vue";
import Steam from "./Steam.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>
<template>
<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">
<Time class="time-sidebar cell" />
<Timer class="timer-sidebar cell" />
@@ -150,42 +182,87 @@ import Bookmarks from "./Bookmarks.vue";
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) {
.outerWrap {
flex-direction: column;
align-items: center;
height: auto;
gap: 5px;
padding-bottom: 10px;
}
/* Visual order is sheet, tab bar, selected widget — whatever the DOM order */
.homeGrid {
order: -1;
order: -2;
width: 95vw;
height: 297mm;
margin-inline: 0;
box-sizing: border-box;
}
.sidebar {
.widget-tabs {
order: -1;
display: flex;
gap: 5px;
width: 95vw;
flex-direction: column;
align-items: center;
flex: unset;
justify-content: space-around;
margin-top: 5px;
}
.commits-sidebar,
.steam-sidebar,
.bookmarks-sidebar {
width: 100%;
max-height: 300px;
/* The two sidebars stop being boxes, so their widgets become direct flex
children of .outerWrap and the one selected widget sits under the tabs. */
.sidebar {
display: contents;
}
.chat-sidebar {
width: 100%;
min-height: 400px;
max-height: 800px;
height: 25vh;
/* One fixed panel size for every tab, so switching doesn't make the page
jump. The .outerWrap prefix is for specificity: it has to beat the
widgets' own scoped height rules (Steam's 54mm, Chat's 100%). */
.outerWrap .commits-sidebar,
.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,
@@ -203,7 +280,9 @@ import Bookmarks from "./Bookmarks.vue";
border-width: 0;
grid-template-columns: 1fr 1fr 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:
"intro intro intro"
"intro intro intro"
+34 -5
View File
@@ -72,7 +72,7 @@ onMounted(() => {
<div
@click="nextSong"
:key="song.track.name"
class="flex flex-col items-center"
class="song flex flex-col items-center"
>
<img
:src="song.track.album.images[0].url"
@@ -109,16 +109,45 @@ onMounted(() => {
position: relative;
flex: 1;
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 {
width: 70%;
max-width: 100%;
height: auto;
flex: 1 1 0;
min-height: 0;
width: 100%;
object-fit: contain;
}
p {
flex-shrink: 0;
width: 100%;
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>
+22 -79
View File
@@ -5,15 +5,10 @@
* The order is shuffled on module load so the wall looks different each visit.
* The rAF loop then drifts the scroll position diagonally and bounces off each
* edge — it drives the DOM's scrollLeft/scrollTop directly rather than any
* reactive state, and reads scrollWidth/clientWidth each frame because the
* wall is re-sized whenever the cell is.
*
* The wall is a fixed-track grid whose column and row counts are derived from
* the cell's own size (see fitWall), so it always overflows on both axes. A
* wrapping flex row only overflowed when the cell happened to be narrower than
* the wall, which left it motionless at tablet widths.
* reactive state, and reads scrollWidth/clientWidth each frame because images
* load in progressively and change the bounds.
*/
import { ref, computed, onMounted, onUnmounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
import Touchscreen from "@/components/util/Touchscreen.vue";
import Link from "@/components/text/Link.vue";
@@ -39,56 +34,7 @@ let srcs = [
// page load but stable while the widget is mounted. Mutates in place.
shuffleArray(srcs);
// The two linked stamps stay first; the shuffled local ones follow.
const stamps = [
{
src: "https://www.adam-french.co.uk/img/stamps/mine.gif",
alt: "adam-french.co.uk",
href: "https://www.adam-french.co.uk",
},
{
src: "https://jacobbarron.xyz/Banneh.gif",
alt: "jacobbarron.xyz",
href: "https://jacobbarron.xyz",
},
...srcs.map((src) => ({ src, alt: src.split("/").pop().split(".")[0] })),
];
// Must match the grid track sizes in the <style> block.
const STAMP_W = 89;
const STAMP_H = 59;
const touchscreen = ref(null);
const cols = ref(4);
const rows = ref(4);
// Every grid slot is filled, cycling through the stamps when the wall needs
// more slots than there are stamps — a ragged last row would leave a blank
// strip drifting into view.
const cells = computed(() =>
Array.from(
{ length: cols.value * rows.value },
(_, i) => stamps[i % stamps.length],
),
);
/**
* Size the wall to between one and two stamps larger than the cell on each
* axis, so there is always something to bounce across whatever the page size.
* Rows are also raised, if need be, until every stamp appears at least once.
*/
function fitWall() {
const el = touchscreen.value?.$el;
if (!el) return;
cols.value = Math.ceil(el.clientWidth / STAMP_W) + 1;
rows.value = Math.max(
Math.ceil(el.clientHeight / STAMP_H) + 1,
Math.ceil(stamps.length / cols.value),
);
}
let resizeObserver = null;
let animId = null;
let posX = 0;
let posY = 0;
@@ -100,7 +46,7 @@ let dy = 0.12;
*
* Writes scrollLeft/scrollTop on the DOM node directly (no reactive state, so
* no re-render per frame), and re-reads scrollWidth/clientWidth every frame
* because fitWall changes the bounds whenever the cell is resized.
* because the stamp images load in progressively and keep changing the bounds.
*/
function bounce() {
const el = touchscreen.value?.$el;
@@ -136,46 +82,43 @@ function bounce() {
}
onMounted(() => {
fitWall();
// The cell's size follows the home grid's breakpoints (and the scrollbars
// appearing inside it), not just window resizes, so observe the element.
resizeObserver = new ResizeObserver(fitWall);
resizeObserver.observe(touchscreen.value.$el);
animId = requestAnimationFrame(bounce);
});
onUnmounted(() => {
if (animId) cancelAnimationFrame(animId);
resizeObserver?.disconnect();
});
</script>
<template>
<Touchscreen ref="touchscreen">
<div class="wall" :style="{ '--cols': cols }">
<template v-for="(stamp, i) in cells" :key="i">
<Link v-if="stamp.href" bare :href="stamp.href">
<img :src="stamp.src" :alt="stamp.alt" />
</Link>
<img v-else :src="stamp.src" :alt="stamp.alt" loading="lazy" />
</template>
<div class="flex flex-wrap tst">
<Link bare href="https://www.adam-french.co.uk">
<img
src="https://www.adam-french.co.uk/img/stamps/mine.gif"
alt="adam-french.co.uk"
/>
</Link>
<Link bare href="https://jacobbarron.xyz">
<img src="https://jacobbarron.xyz/Banneh.gif" alt="jacobbarron.xyz" />
</Link>
<img
v-for="src in srcs"
:src="src"
:alt="src.split('/').pop().split('.')[0]"
loading="lazy"
/>
</div>
</Touchscreen>
</template>
<style scoped>
img {
display: block;
width: 89px;
height: 59px;
}
/* Fixed tracks rather than flex-wrap: the wall's size comes from --cols (set
by fitWall), never from how much room the cell happens to have. */
.wall {
display: grid;
grid-template-columns: repeat(var(--cols), 89px);
grid-auto-rows: 59px;
width: max-content;
.tst {
min-width: calc(89px * 4);
}
</style>
+16 -10
View File
@@ -54,7 +54,7 @@ function formatHours(minutes) {
<div
@click="nextGame"
:key="game.appId"
class="flex flex-col items-center pt-2"
class="game flex flex-col items-center pt-2"
>
<img
:src="game.headerImageUrl"
@@ -89,24 +89,30 @@ function formatHours(minutes) {
position: relative;
flex: 1;
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 {
flex: 0 1 auto;
min-height: 0;
width: 90%;
max-width: 300px;
max-width: 460px; /* Steam header images are 460x215 */
height: auto;
object-fit: contain;
}
p {
flex-shrink: 0;
width: 100%;
margin: 0 auto;
}
@media (max-width: 850px) {
.steam-wrapper {
height: auto;
min-height: 120px;
}
}
</style>