diff --git a/src/main.tsx b/src/main.tsx --- a/src/main.tsx +++ b/src/main.tsx @@ -1,18 +1,18 @@ import "~/styles/app.css"; import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister"; -import { QueryClient, QueryClientProvider, } from "@tanstack/react-query"; -import { - persistQueryClient, -} from "@tanstack/react-query-persist-client"; -import { createRouter,RouterProvider } from "@tanstack/react-router"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { persistQueryClient } from "@tanstack/react-query-persist-client"; +import { createRouter, RouterProvider } from "@tanstack/react-router"; +import { useSetAtom } from "jotai"; +import { useEffect } from "react"; //import { StrictMode } from "react"; import ReactDOM from "react-dom/client"; import reportWebVitals from "./reportWebVitals.ts"; // Import the generated route tree import { routeTree } from "./routeTree.gen"; - +import { isAtTopAtom } from "./utils/atoms.ts"; const queryClient = new QueryClient({ defaultOptions: { @@ -28,7 +28,7 @@ persistQueryClient({ queryClient, persister: localStoragePersister, -}) +}); // Create a new router instance const router = createRouter({ @@ -54,9 +54,10 @@ root.render( // double queries annoys me // - - - + + + + // ); } @@ -65,3 +66,45 @@ // to log results (for example: reportWebVitals(// /*mass comment*/ console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals(); + +export default function ScrollTopWatcher() { + const setIsAtTop = useSetAtom(isAtTopAtom); + useEffect(() => { + const meta = document.querySelector('meta[name="theme-color"]'); + let lastAtTop = window.scrollY === 0; + let timeoutId: number | undefined; + + const setVars = (atTop: boolean) => { + const root = document.documentElement; + root.style.setProperty("--is-top", atTop ? "1" : "0"); + + const bg = getComputedStyle(root).getPropertyValue("--header-bg").trim(); + if (meta && bg) meta.setAttribute("content", bg); + setIsAtTop(atTop); + }; + + const check = () => { + const atTop = window.scrollY === 0; + if (atTop !== lastAtTop) { + lastAtTop = atTop; + setVars(atTop); + } + }; + + const handleScroll = () => { + if (timeoutId) clearTimeout(timeoutId); + timeoutId = window.setTimeout(check, 2); + }; + + // initialize + setVars(lastAtTop); + window.addEventListener("scroll", handleScroll, { passive: true }); + + return () => { + window.removeEventListener("scroll", handleScroll); + if (timeoutId) clearTimeout(timeoutId); + }; + }, []); + + return null; +} diff --git a/src/components/Header.tsx b/src/components/Header.tsx --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,4 +1,7 @@ import { Link, useRouter } from "@tanstack/react-router"; +import { useAtom } from "jotai"; + +import { isAtTopAtom } from "~/utils/atoms"; export function Header({ backButtonCallback, @@ -8,9 +11,10 @@ title?: string; }) { const router = useRouter(); + const [isAtTop] = useAtom(isAtTopAtom); //const what = router.history. return ( -
+
{backButtonCallback ? ( - {isRefetching ? : } + ); diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -1248,7 +1248,7 @@ // dont cursor: "pointer", borderBottomWidth: bottomBorder ? (isQuote ? 0 : 1) : 0, }} - className="border-gray-300 dark:border-gray-600" + className="border-gray-300 dark:border-gray-800" > {isRepost && (
@@ -1521,7 +1521,7 @@ hydrate embeds this deep but the connection here is implicit todo: idk make this a real part of the embed shim so its not implicit */ <> -
+
(there is an embed here thats too deep to render)
@@ -1544,7 +1544,7 @@ borderBottomWidth: 1, marginBottom: 8, }} // important for height animation - className="text-gray-500 dark:text-gray-400 border-gray-200 dark:border-gray-700" + className="text-gray-500 dark:text-gray-400 border-gray-200 dark:border-gray-800 was7" > {fullDateTimeFormat(post.indexedAt)}
@@ -1780,7 +1780,7 @@ //boxShadow: theme.cardShadow, overflow: "hidden", }} - className="shadow border border-gray-200 dark:border-gray-700" + className="shadow border border-gray-200 dark:border-gray-800 was7" > {lightboxIndex !== null && ( {lightboxIndex !== null && ( {lightboxIndex !== null && ( {lightboxIndex !== null && (
{thumb && (
{ e.stopPropagation(); setPlaying(true); @@ -2768,7 +2768,7 @@ 100 / (aspect ? aspect.width / aspect.height : 16 / 9) }%`, // 16:9 = 56.25%, 4:3 = 75% }} - className="border border-gray-200 dark:border-gray-700" + className="border border-gray-200 dark:border-gray-800 was7" > )} -
+
{children}
@@ -448,7 +448,7 @@
{agent?.did ? ( -