From e533f7401ee2441577a203ca519d46a076711c5c Mon Sep 17 00:00:00 2001 From: "Vitor A. Batista" Date: Wed, 13 Mar 2024 09:09:22 -0300 Subject: [PATCH] fix dark/light theme details page --- src/pages/details-page.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pages/details-page.tsx b/src/pages/details-page.tsx index 73546d8..7b6a823 100644 --- a/src/pages/details-page.tsx +++ b/src/pages/details-page.tsx @@ -17,6 +17,7 @@ export default function DetailsPage() { const { postId } = useParams(); const navigate = useNavigate(); + useEffect(() => { const getPostById = async () => { try { @@ -34,6 +35,14 @@ export default function DetailsPage() { } }, [post]); + useEffect(() => { + const storedTheme = localStorage.getItem('theme') ?? 'light'; + const textContainer = document.getElementById('textcontainer'); + if (textContainer) { + textContainer.setAttribute('data-color-mode', storedTheme); + } + }, []) + if (!loading) return (
@@ -58,10 +67,10 @@ export default function DetailsPage() {

-
-
- -
+
+
+ +
);