Merge pull request 'Improve /stp layout on small screens' (#7) from worktree-small-screen-ui into main
Deploy with Docker Compose / deploy (push) Successful in 28s
Deploy with Docker Compose / deploy (push) Successful in 28s
Reviewed-on: https://www.adam-french.co.uk/gitea/adamf/web_server/pulls/7
This commit was merged in pull request #7.
This commit is contained in:
+98
-19
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user