From fc24ddb6762c148b0128dbed9d9baddaaff4312f Mon Sep 17 00:00:00 2001 From: gbanyan Date: Fri, 21 Nov 2025 01:42:49 +0800 Subject: [PATCH] Portal reading progress bar above all layers --- components/reading-progress.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/reading-progress.tsx b/components/reading-progress.tsx index 5dd3900..62d11af 100644 --- a/components/reading-progress.tsx +++ b/components/reading-progress.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useState } from 'react'; +import { createPortal } from 'react-dom'; export function ReadingProgress() { const [mounted, setMounted] = useState(false); @@ -29,19 +30,21 @@ export function ReadingProgress() { return () => window.removeEventListener('scroll', handleScroll); }, [mounted]); + if (!mounted) return null; - return ( -
+ return createPortal( +
0 ? 1 : 0 }} > -
-
+
, + document.body ); }