Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dashboard/app/dashboard/music/music-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useEffect, useRef, useState } from "react";
import { animate } from "framer-motion";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { useLenis } from "lenis/react";
import type { MusicStats } from "@/types/music-stats";
import { TopArtistsChart } from "./top-artists-chart";
import { ProductivityChart } from "./productivity-chart";
Expand Down Expand Up @@ -52,6 +53,7 @@ function fmtListened(ms: number): string {

export function MusicClient() {
const [range, setRange] = useState<Preset>("last_7d");
const lenis = useLenis();

const { data, isLoading, isError, error } = useQuery({
queryKey: ["music-stats", range],
Expand All @@ -61,6 +63,11 @@ export function MusicClient() {
refetchInterval: 60_000,
});

// Charts render after data arrives — tell Lenis the page grew
useEffect(() => {
if (data) lenis?.resize();
}, [data, lenis]);

return (
<div className="flex flex-col gap-4">
{/* Range picker */}
Expand Down
11 changes: 11 additions & 0 deletions dashboard/components/smooth-scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ const OPTIONS: LenisOptions = {
function LenisResizer() {
const lenis = useLenis();
const pathname = usePathname();

useEffect(() => {
lenis?.scrollTo(0, { immediate: true });
lenis?.resize();
}, [lenis, pathname]);

// Recalculate scroll height when lazy-loaded content (charts, data) changes
// body height. html { height: 100% } is fixed at viewport — observe body instead.
useEffect(() => {
if (!lenis) return;
const ro = new ResizeObserver(() => lenis.resize());
ro.observe(document.body);
return () => ro.disconnect();
}, [lenis]);

return null;
}

Expand Down
4 changes: 4 additions & 0 deletions dashboard/components/timer-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export function TimerField() {
function resize() {
c.width = window.innerWidth;
c.height = window.innerHeight;
for (const t of timersRef.current) {
t.x = Math.random() * c.width;
t.y = Math.random() * c.height;
}
}
resize();
window.addEventListener("resize", resize);
Expand Down
Loading