Compare commits

10 Commits

Author SHA1 Message Date
Garret Patti
39bd815ff0 fix centering issue in media viewer 2026-05-20 17:14:51 -04:00
cab5b28a4d mute by default 2026-05-17 18:49:46 -04:00
a65d86bed6 readd controls 2026-05-17 18:46:54 -04:00
8152ab4a7a more control updates 2026-05-17 18:43:44 -04:00
1987ea4c96 play video inline and mute by default 2026-05-17 18:33:40 -04:00
d84600bce8 touch media viewer fixes 2026-05-17 17:02:53 -04:00
0f30400c7d doom scroll touch edit 2026-05-17 10:34:01 -04:00
80423c3ca2 Merge pull request 'mobile fixes' (#3) from responsive-ui into main
Reviewed-on: http://gitea.lan/gpatti/MediaLore-Web-App/pulls/3
2026-05-17 04:01:36 +00:00
9cd21f9568 mobile fixes 2026-05-17 00:01:21 -04:00
fbe78ae396 switch data to docker volume 2026-05-16 23:05:24 -04:00
4 changed files with 225 additions and 20 deletions

View File

@@ -3,7 +3,7 @@ services:
build: ./backend build: ./backend
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./data:/data - medialore-data:/data
- /data/smb/adult/Images:/media/Images - /data/smb/adult/Images:/media/Images
- /data/smb/adult/Video Clips:/media/Video Clips - /data/smb/adult/Video Clips:/media/Video Clips
environment: environment:
@@ -16,3 +16,6 @@ services:
- "8080:80" - "8080:80"
depends_on: depends_on:
- backend - backend
volumes:
medialore-data:

View File

@@ -21,7 +21,7 @@ function useTheme() {
return { dark, toggle: () => setDark((d) => !d) }; return { dark, toggle: () => setDark((d) => !d) };
} }
function Sidebar({ onToggleTheme, dark }: { onToggleTheme: () => void; dark: boolean }) { function Sidebar({ onToggleTheme, dark, onClose }: { onToggleTheme: () => void; dark: boolean; onClose?: () => void }) {
const { data: libraries = [] } = useQuery<Library[]>({ const { data: libraries = [] } = useQuery<Library[]>({
queryKey: ["libraries"], queryKey: ["libraries"],
queryFn: api.libraries.list, queryFn: api.libraries.list,
@@ -52,7 +52,7 @@ function Sidebar({ onToggleTheme, dark }: { onToggleTheme: () => void; dark: boo
MediaLore MediaLore
</div> </div>
<NavLink to="/search" style={linkStyle}>Search</NavLink> <NavLink to="/search" style={linkStyle} onClick={onClose}>Search</NavLink>
{libraries.length > 0 && ( {libraries.length > 0 && (
<> <>
@@ -60,7 +60,7 @@ function Sidebar({ onToggleTheme, dark }: { onToggleTheme: () => void; dark: boo
Libraries Libraries
</div> </div>
{libraries.map((lib) => ( {libraries.map((lib) => (
<NavLink key={lib.id} to={`/library/${lib.id}`} style={linkStyle}> <NavLink key={lib.id} to={`/library/${lib.id}`} style={linkStyle} onClick={onClose}>
{lib.name} {lib.name}
</NavLink> </NavLink>
))} ))}
@@ -68,7 +68,7 @@ function Sidebar({ onToggleTheme, dark }: { onToggleTheme: () => void; dark: boo
)} )}
<div style={{ marginTop: "auto", display: "flex", flexDirection: "column", gap: 4 }}> <div style={{ marginTop: "auto", display: "flex", flexDirection: "column", gap: 4 }}>
<NavLink to="/settings" style={linkStyle}>Settings</NavLink> <NavLink to="/settings" style={linkStyle} onClick={onClose}>Settings</NavLink>
<button <button
onClick={onToggleTheme} onClick={onToggleTheme}
title={dark ? "Switch to light mode" : "Switch to dark mode"} title={dark ? "Switch to light mode" : "Switch to dark mode"}
@@ -83,11 +83,51 @@ function Sidebar({ onToggleTheme, dark }: { onToggleTheme: () => void; dark: boo
function AppShell() { function AppShell() {
const { dark, toggle } = useTheme(); const { dark, toggle } = useTheme();
const [isMobile, setIsMobile] = useState(() => window.innerWidth < 768);
const [sidebarOpen, setSidebarOpen] = useState(false);
useEffect(() => {
const mq = window.matchMedia("(max-width: 767px)");
setIsMobile(mq.matches);
const handler = (e: MediaQueryListEvent) => {
setIsMobile(e.matches);
if (!e.matches) setSidebarOpen(false);
};
mq.addEventListener("change", handler);
return () => mq.removeEventListener("change", handler);
}, []);
return ( return (
<div style={{ display: "flex", height: "100vh", background: "var(--bg)", color: "var(--text)" }}> <div style={{ display: "flex", height: "100vh", background: "var(--bg)", color: "var(--text)" }}>
<Sidebar onToggleTheme={toggle} dark={dark} /> {/* Mobile hamburger button */}
<main style={{ flex: 1, overflow: "auto", background: "var(--bg)" }}> {isMobile && (
<button
onClick={() => setSidebarOpen((v) => !v)}
style={{ position: "fixed", top: 12, left: 12, zIndex: 301, background: "var(--bg)", border: "1px solid var(--border)", borderRadius: 6, padding: "6px 10px", color: "var(--text)", fontSize: 18, cursor: "pointer" }}
aria-label="Toggle menu"
>
</button>
)}
{/* Mobile backdrop */}
{isMobile && sidebarOpen && (
<div
onClick={() => setSidebarOpen(false)}
style={{ position: "fixed", inset: 0, background: "rgba(0,0,0,0.4)", zIndex: 299 }}
/>
)}
{/* Sidebar */}
<div style={isMobile ? {
position: "fixed", top: 0, left: 0, bottom: 0, zIndex: 300,
transform: sidebarOpen ? "translateX(0)" : "translateX(-100%)",
transition: "transform 0.2s ease",
} : {}}>
<Sidebar onToggleTheme={toggle} dark={dark} onClose={isMobile ? () => setSidebarOpen(false) : undefined} />
</div>
<main style={{ flex: 1, overflow: "auto", background: "var(--bg)", paddingTop: isMobile ? 48 : 0 }}>
<Routes> <Routes>
<Route path="/" element={<SearchPage />} /> <Route path="/" element={<SearchPage />} />
<Route path="/search" element={<SearchPage />} /> <Route path="/search" element={<SearchPage />} />

View File

@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import { api, type MediaItem } from "../../api/client"; import { api, type MediaItem } from "../../api/client";
interface Props { interface Props {
@@ -11,10 +11,12 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
const [index, setIndex] = useState(0); const [index, setIndex] = useState(0);
const [fading, setFading] = useState(false); const [fading, setFading] = useState(false);
const wheelLock = useRef(false); const wheelLock = useRef(false);
const touchStartY = useRef<number | null>(null);
const contentRef = useRef<HTMLDivElement>(null);
const item = items[index]; const item = items[index];
function go(delta: 1 | -1) { const go = useCallback((delta: 1 | -1) => {
if (wheelLock.current) return; if (wheelLock.current) return;
const next = index + delta; const next = index + delta;
if (next < 0 || next >= items.length) return; if (next < 0 || next >= items.length) return;
@@ -25,7 +27,7 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
setFading(false); setFading(false);
wheelLock.current = false; wheelLock.current = false;
}, 200); }, 200);
} }, [index, items.length]);
useEffect(() => { useEffect(() => {
const onWheel = (e: WheelEvent) => { e.deltaY > 0 ? go(1) : go(-1); }; const onWheel = (e: WheelEvent) => { e.deltaY > 0 ? go(1) : go(-1); };
@@ -40,7 +42,62 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
window.removeEventListener("wheel", onWheel); window.removeEventListener("wheel", onWheel);
window.removeEventListener("keydown", onKey); window.removeEventListener("keydown", onKey);
}; };
}, [index, fading]); }, [go, onClose]);
useEffect(() => {
const onTouchStart = (e: TouchEvent) => {
touchStartY.current = e.touches[0].clientY;
if (contentRef.current) contentRef.current.style.transition = "none";
};
const onTouchMove = (e: TouchEvent) => {
e.preventDefault();
if (touchStartY.current === null || !contentRef.current) return;
const offset = e.touches[0].clientY - touchStartY.current;
contentRef.current.style.transform = `translateY(${offset}px)`;
contentRef.current.style.opacity = String(Math.max(0.3, 1 - Math.abs(offset) / 300));
};
const onTouchEnd = (e: TouchEvent) => {
if (touchStartY.current === null) return;
const delta = touchStartY.current - e.changedTouches[0].clientY;
touchStartY.current = null;
if (Math.abs(delta) > 80) {
// Hand off to the fading animation
if (contentRef.current) {
contentRef.current.style.transition = "";
contentRef.current.style.transform = "";
contentRef.current.style.opacity = "";
}
go(delta > 0 ? 1 : -1);
} else {
// Snap back to center
if (contentRef.current) {
const el = contentRef.current;
el.style.transition = "opacity 0.25s ease, transform 0.25s ease";
el.style.transform = "translateY(0)";
el.style.opacity = "1";
setTimeout(() => {
if (contentRef.current) {
contentRef.current.style.transition = "";
contentRef.current.style.transform = "";
contentRef.current.style.opacity = "";
}
}, 260);
}
}
};
window.addEventListener("touchstart", onTouchStart);
window.addEventListener("touchmove", onTouchMove, { passive: false });
window.addEventListener("touchend", onTouchEnd);
return () => {
window.removeEventListener("touchstart", onTouchStart);
window.removeEventListener("touchmove", onTouchMove);
window.removeEventListener("touchend", onTouchEnd);
};
}, [go]);
return ( return (
<> <>
@@ -49,6 +106,7 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
{/* Media area */} {/* Media area */}
<div <div
ref={contentRef}
style={{ style={{
position: "fixed", inset: 0, zIndex: 201, position: "fixed", inset: 0, zIndex: 201,
display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center",
@@ -58,7 +116,6 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
transform: fading ? "translateY(-12px)" : "translateY(0)", transform: fading ? "translateY(-12px)" : "translateY(0)",
}} }}
> >
<div style={{ color: "#ccc", fontSize: 13 }}>{item?.filename}</div>
{item?.media_type === "image" && ( {item?.media_type === "image" && (
<img <img
key={item.id} key={item.id}
@@ -71,8 +128,11 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
<video <video
key={item.id} key={item.id}
src={api.media.fileUrl(item.id)} src={api.media.fileUrl(item.id)}
controls
autoPlay autoPlay
muted
playsInline
controls
loop
style={{ maxWidth: "90vw", maxHeight: "82vh" }} style={{ maxWidth: "90vw", maxHeight: "82vh" }}
/> />
)} )}

View File

@@ -1,4 +1,4 @@
import { useEffect, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { api, type BrowseEntry, type MediaItem } from "../../api/client"; import { api, type BrowseEntry, type MediaItem } from "../../api/client";
import TagPanel from "../TagPanel/TagPanel"; import TagPanel from "../TagPanel/TagPanel";
@@ -11,7 +11,14 @@ interface Props {
} }
export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }: Props) { export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }: Props) {
const [showTags, setShowTags] = useState(true); const TAG_PANEL_WIDTH = 260;
const EDGE_GAP = 16;
const BASE_CARD_TRANSFORM = "translate(-50%, -50%)";
const [showTags, setShowTags] = useState(() => window.innerWidth >= 768);
const touchStartX = useRef<number | null>(null);
const touchStartY = useRef<number | null>(null);
const swipeAxis = useRef<"horizontal" | "vertical" | null>(null);
const contentRef = useRef<HTMLDivElement>(null);
const { data: item } = useQuery<MediaItem>({ const { data: item } = useQuery<MediaItem>({
queryKey: ["media", mediaId], queryKey: ["media", mediaId],
@@ -22,6 +29,16 @@ export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }:
const currentIndex = mediaSiblings.findIndex((e) => e.media_item_id === mediaId); const currentIndex = mediaSiblings.findIndex((e) => e.media_item_id === mediaId);
const prevId = currentIndex > 0 ? mediaSiblings[currentIndex - 1].media_item_id : null; const prevId = currentIndex > 0 ? mediaSiblings[currentIndex - 1].media_item_id : null;
const nextId = currentIndex < mediaSiblings.length - 1 ? mediaSiblings[currentIndex + 1].media_item_id : null; const nextId = currentIndex < mediaSiblings.length - 1 ? mediaSiblings[currentIndex + 1].media_item_id : null;
const cardCenterX = showTags ? `calc((100vw - ${TAG_PANEL_WIDTH}px) / 2)` : "50%";
// Clear inline styles when a new item loads so the card appears cleanly
useEffect(() => {
if (contentRef.current) {
contentRef.current.style.transition = "";
contentRef.current.style.transform = BASE_CARD_TRANSFORM;
contentRef.current.style.opacity = "1";
}
}, [mediaId, BASE_CARD_TRANSFORM]);
useEffect(() => { useEffect(() => {
function onKey(e: KeyboardEvent) { function onKey(e: KeyboardEvent) {
@@ -29,9 +46,93 @@ export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }:
if (e.key === "ArrowLeft" && prevId) onNavigate(prevId); if (e.key === "ArrowLeft" && prevId) onNavigate(prevId);
if (e.key === "ArrowRight" && nextId) onNavigate(nextId); if (e.key === "ArrowRight" && nextId) onNavigate(nextId);
} }
const onTouchStart = (e: TouchEvent) => {
touchStartX.current = e.touches[0].clientX;
touchStartY.current = e.touches[0].clientY;
swipeAxis.current = null;
if (contentRef.current) contentRef.current.style.transition = "none";
};
const onTouchMove = (e: TouchEvent) => {
if (touchStartX.current === null || touchStartY.current === null) return;
const dx = e.touches[0].clientX - touchStartX.current;
const dy = e.touches[0].clientY - touchStartY.current;
// Commit to an axis on the first significant movement
if (swipeAxis.current === null && (Math.abs(dx) > 8 || Math.abs(dy) > 8)) {
swipeAxis.current = Math.abs(dx) >= Math.abs(dy) ? "horizontal" : "vertical";
}
// Vertical gestures (tag panel scroll, etc.) pass through untouched
if (swipeAxis.current !== "horizontal") return;
e.preventDefault();
if (!contentRef.current) return;
contentRef.current.style.transform = `translate(calc(-50% + ${dx}px), -50%)`;
contentRef.current.style.opacity = String(Math.max(0.4, 1 - Math.abs(dx) / 400));
};
const onTouchEnd = (e: TouchEvent) => {
if (touchStartX.current === null) return;
const delta = touchStartX.current - e.changedTouches[0].clientX;
touchStartX.current = null;
touchStartY.current = null;
// Non-horizontal gesture: just reset the transition we disabled on touchstart
if (swipeAxis.current !== "horizontal") {
swipeAxis.current = null;
if (contentRef.current) {
contentRef.current.style.transition = "";
contentRef.current.style.transform = BASE_CARD_TRANSFORM;
contentRef.current.style.opacity = "1";
}
return;
}
swipeAxis.current = null;
const targetId = delta > 0 ? nextId : prevId;
if (Math.abs(delta) > 80 && targetId) {
const el = contentRef.current;
if (el) {
const slideX = delta > 0 ? -120 : 120;
el.style.transition = "opacity 0.2s ease, transform 0.2s ease";
el.style.transform = `translate(calc(-50% + ${slideX}px), -50%)`;
el.style.opacity = "0";
setTimeout(() => onNavigate(targetId), 200);
} else {
onNavigate(targetId);
}
} else {
// Snap back to center
const el = contentRef.current;
if (el) {
el.style.transition = "opacity 0.25s ease, transform 0.25s ease";
el.style.transform = "translate(-50%, -50%)";
el.style.opacity = "1";
setTimeout(() => {
if (contentRef.current) {
contentRef.current.style.transition = "";
contentRef.current.style.transform = BASE_CARD_TRANSFORM;
contentRef.current.style.opacity = "1";
}
}, 260);
}
}
};
window.addEventListener("keydown", onKey); window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey); window.addEventListener("touchstart", onTouchStart);
}, [prevId, nextId, onClose, onNavigate]); window.addEventListener("touchmove", onTouchMove, { passive: false });
window.addEventListener("touchend", onTouchEnd);
return () => {
window.removeEventListener("keydown", onKey);
window.removeEventListener("touchstart", onTouchStart);
window.removeEventListener("touchmove", onTouchMove);
window.removeEventListener("touchend", onTouchEnd);
};
}, [prevId, nextId, onClose, onNavigate, BASE_CARD_TRANSFORM]);
return ( return (
<> <>
@@ -54,15 +155,16 @@ export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }:
<button <button
onClick={() => nextId && onNavigate(nextId)} onClick={() => nextId && onNavigate(nextId)}
disabled={!nextId} disabled={!nextId}
style={{ position: "fixed", right: showTags ? 276 : 16, top: "50%", transform: "translateY(-50%)", zIndex: 102, fontSize: 36, background: "none", border: "none", color: nextId ? "#fff" : "#444", cursor: nextId ? "pointer" : "default" }} style={{ position: "fixed", right: showTags ? TAG_PANEL_WIDTH + EDGE_GAP : EDGE_GAP, top: "50%", transform: "translateY(-50%)", zIndex: 102, fontSize: 36, background: "none", border: "none", color: nextId ? "#fff" : "#444", cursor: nextId ? "pointer" : "default" }}
> >
</button> </button>
{/* Media card */} {/* Media card */}
<div <div
ref={contentRef}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
style={{ position: "fixed", top: "50%", left: "50%", transform: "translate(-50%, -50%)", zIndex: 101, background: "#1a1a1a", borderRadius: 8, padding: 16, display: "flex", flexDirection: "column", alignItems: "center", gap: 12, maxWidth: "80vw", maxHeight: "90vh", overflow: "auto" }} style={{ position: "fixed", top: "50%", left: cardCenterX, transform: BASE_CARD_TRANSFORM, zIndex: 101, background: "#1a1a1a", borderRadius: 8, padding: 16, display: "flex", flexDirection: "column", alignItems: "center", gap: 12, maxWidth: "80vw", maxHeight: "90vh", overflow: "auto" }}
> >
{item?.filename && ( {item?.filename && (
<div style={{ color: "#ccc", fontSize: 13 }}>{item.filename}</div> <div style={{ color: "#ccc", fontSize: 13 }}>{item.filename}</div>
@@ -103,7 +205,7 @@ export default function MediaViewer({ mediaId, siblings, onClose, onNavigate }:
{showTags && item && ( {showTags && item && (
<div <div
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
style={{ position: "fixed", top: 0, right: 0, height: "100%", width: 260, background: "#1a1a1a", borderLeft: "1px solid #333", padding: "48px 16px 16px", zIndex: 101, overflowY: "auto" }} style={{ position: "fixed", top: 0, right: 0, height: "100%", width: TAG_PANEL_WIDTH, background: "#1a1a1a", borderLeft: "1px solid #333", padding: "48px 16px 16px", zIndex: 101, overflowY: "auto" }}
> >
<TagPanel item={item} /> <TagPanel item={item} />
</div> </div>