Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d843b0baf1 |
+20
-99
@@ -7,13 +7,6 @@
|
|||||||
* 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.
|
||||||
*
|
*
|
||||||
@@ -37,36 +30,11 @@ 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" :data-tab="activeTab">
|
<div class="outerWrap flex flex-row">
|
||||||
<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" />
|
||||||
@@ -182,87 +150,42 @@ const activeTab = ref("chat");
|
|||||||
height: 15rem;
|
height: 15rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Small-screen only; switched on in the tablet media query */
|
/* Tablet: sidebars stack below the sheet */
|
||||||
.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: -2;
|
order: -1;
|
||||||
width: 95vw;
|
width: 95vw;
|
||||||
height: 297mm;
|
height: 297mm;
|
||||||
margin-inline: 0;
|
margin-inline: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-tabs {
|
|
||||||
order: -1;
|
|
||||||
display: flex;
|
|
||||||
gap: 5px;
|
|
||||||
width: 95vw;
|
|
||||||
margin-top: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 {
|
.sidebar {
|
||||||
display: contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
width: 95vw;
|
||||||
height: clamp(360px, 70vh, 640px);
|
flex-direction: column;
|
||||||
max-height: none;
|
align-items: center;
|
||||||
|
flex: unset;
|
||||||
|
justify-content: space-around;
|
||||||
}
|
}
|
||||||
|
|
||||||
.outerWrap:not([data-tab="commits"]) .commits-sidebar,
|
.commits-sidebar,
|
||||||
.outerWrap:not([data-tab="steam"]) .steam-sidebar,
|
.steam-sidebar,
|
||||||
.outerWrap:not([data-tab="bookmarks"]) .bookmarks-sidebar,
|
.bookmarks-sidebar {
|
||||||
.outerWrap:not([data-tab="chat"]) .chat-sidebar {
|
width: 100%;
|
||||||
display: none;
|
max-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-sidebar {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 400px;
|
||||||
|
max-height: 800px;
|
||||||
|
height: 25vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time-sidebar,
|
.time-sidebar,
|
||||||
@@ -280,9 +203,7 @@ const activeTab = ref("chat");
|
|||||||
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);
|
||||||
/* The floor keeps the 11 rows usable on short phones, where 150vh alone
|
height: 150vh;
|
||||||
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"
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ onMounted(() => {
|
|||||||
<div
|
<div
|
||||||
@click="nextSong"
|
@click="nextSong"
|
||||||
:key="song.track.name"
|
:key="song.track.name"
|
||||||
class="song flex flex-col items-center"
|
class="flex flex-col items-center"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
:src="song.track.album.images[0].url"
|
:src="song.track.album.images[0].url"
|
||||||
@@ -109,45 +109,16 @@ onMounted(() => {
|
|||||||
position: relative;
|
position: relative;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow-y: auto;
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 {
|
||||||
flex: 1 1 0;
|
width: 70%;
|
||||||
min-height: 0;
|
max-width: 100%;
|
||||||
width: 100%;
|
height: auto;
|
||||||
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>
|
||||||
|
|||||||
@@ -5,10 +5,15 @@
|
|||||||
* The order is shuffled on module load so the wall looks different each visit.
|
* 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
|
* 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
|
* edge — it drives the DOM's scrollLeft/scrollTop directly rather than any
|
||||||
* reactive state, and reads scrollWidth/clientWidth each frame because images
|
* reactive state, and reads scrollWidth/clientWidth each frame because the
|
||||||
* load in progressively and change the bounds.
|
* 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.
|
||||||
*/
|
*/
|
||||||
import { ref, onMounted, onUnmounted } from "vue";
|
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||||
|
|
||||||
import Touchscreen from "@/components/util/Touchscreen.vue";
|
import Touchscreen from "@/components/util/Touchscreen.vue";
|
||||||
import Link from "@/components/text/Link.vue";
|
import Link from "@/components/text/Link.vue";
|
||||||
@@ -34,7 +39,56 @@ let srcs = [
|
|||||||
// page load but stable while the widget is mounted. Mutates in place.
|
// page load but stable while the widget is mounted. Mutates in place.
|
||||||
shuffleArray(srcs);
|
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 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 animId = null;
|
||||||
let posX = 0;
|
let posX = 0;
|
||||||
let posY = 0;
|
let posY = 0;
|
||||||
@@ -46,7 +100,7 @@ let dy = 0.12;
|
|||||||
*
|
*
|
||||||
* Writes scrollLeft/scrollTop on the DOM node directly (no reactive state, so
|
* Writes scrollLeft/scrollTop on the DOM node directly (no reactive state, so
|
||||||
* no re-render per frame), and re-reads scrollWidth/clientWidth every frame
|
* no re-render per frame), and re-reads scrollWidth/clientWidth every frame
|
||||||
* because the stamp images load in progressively and keep changing the bounds.
|
* because fitWall changes the bounds whenever the cell is resized.
|
||||||
*/
|
*/
|
||||||
function bounce() {
|
function bounce() {
|
||||||
const el = touchscreen.value?.$el;
|
const el = touchscreen.value?.$el;
|
||||||
@@ -82,43 +136,46 @@ function bounce() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
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);
|
animId = requestAnimationFrame(bounce);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (animId) cancelAnimationFrame(animId);
|
if (animId) cancelAnimationFrame(animId);
|
||||||
|
resizeObserver?.disconnect();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Touchscreen ref="touchscreen">
|
<Touchscreen ref="touchscreen">
|
||||||
<div class="flex flex-wrap tst">
|
<div class="wall" :style="{ '--cols': cols }">
|
||||||
<Link bare href="https://www.adam-french.co.uk">
|
<template v-for="(stamp, i) in cells" :key="i">
|
||||||
<img
|
<Link v-if="stamp.href" bare :href="stamp.href">
|
||||||
src="https://www.adam-french.co.uk/img/stamps/mine.gif"
|
<img :src="stamp.src" :alt="stamp.alt" />
|
||||||
alt="adam-french.co.uk"
|
</Link>
|
||||||
/>
|
<img v-else :src="stamp.src" :alt="stamp.alt" loading="lazy" />
|
||||||
</Link>
|
</template>
|
||||||
<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>
|
</div>
|
||||||
</Touchscreen>
|
</Touchscreen>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
img {
|
img {
|
||||||
|
display: block;
|
||||||
width: 89px;
|
width: 89px;
|
||||||
height: 59px;
|
height: 59px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tst {
|
/* Fixed tracks rather than flex-wrap: the wall's size comes from --cols (set
|
||||||
min-width: calc(89px * 4);
|
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;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function formatHours(minutes) {
|
|||||||
<div
|
<div
|
||||||
@click="nextGame"
|
@click="nextGame"
|
||||||
:key="game.appId"
|
:key="game.appId"
|
||||||
class="game flex flex-col items-center pt-2"
|
class="flex flex-col items-center pt-2"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
:src="game.headerImageUrl"
|
:src="game.headerImageUrl"
|
||||||
@@ -89,30 +89,24 @@ function formatHours(minutes) {
|
|||||||
position: relative;
|
position: relative;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow-y: scroll;
|
||||||
}
|
|
||||||
|
|
||||||
/* 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: 460px; /* Steam header images are 460x215 */
|
max-width: 300px;
|
||||||
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>
|
||||||
|
|||||||
Reference in New Issue
Block a user