From 91e90cba08d39df04859e59dd020b6e2b5bde9c3 Mon Sep 17 00:00:00 2001 From: rimar1337 <132627503+rimar1337@users.noreply.github.com> Date: Sat, 18 Oct 2025 19:20:37 +0700 Subject: [PATCH] more material 3 tweaks --- src/components/Header.tsx | 6 ++- src/components/InfiniteCustomFeed.tsx | 4 +- src/components/UniversalPostRenderer.tsx | 30 +++++------ src/main.tsx | 63 ++++++++++++++++++++---- src/routes/__root.tsx | 14 +++--- src/routes/index.tsx | 8 ++- src/styles/app.css | 19 +++++++ src/utils/atoms.ts | 2 + 8 files changed, 109 insertions(+), 37 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index ad24a94..691e47a 100644 --- 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 @@ export function Header({ 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 index 9928c9b..96c88e5 100644 --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -1248,7 +1248,7 @@ function UniversalPostRenderer({ // 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 @@ function UniversalPostRenderer({ 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 @@ function UniversalPostRenderer({ 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 @@ function PostEmbeds({ //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 @@ const SmartHLSPlayer = ({ 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" > - - - + + + + // ); } @@ -65,3 +66,45 @@ if (rootElement && !rootElement.innerHTML) { // 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/routes/__root.tsx b/src/routes/__root.tsx index d6eeef0..11d13e3 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -431,7 +431,7 @@ function RootDocument({ children }: { children: React.ReactNode }) { )} -
+
{children}
@@ -448,7 +448,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
{agent?.did ? ( -