Skip to content

Commit

Permalink
fix dark/light theme details page
Browse files Browse the repository at this point in the history
  • Loading branch information
vabatista committed Mar 13, 2024
1 parent e182cb8 commit e533f74
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pages/details-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function DetailsPage() {
const { postId } = useParams();
const navigate = useNavigate();


useEffect(() => {
const getPostById = async () => {
try {
Expand All @@ -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 (
<div className="min-h-screen bg-light dark:bg-dark">
Expand All @@ -58,10 +67,10 @@ export default function DetailsPage() {
</p>
</div>
</div>
<div className="items-center gap-y-4 px-4 py-10">
<div>
<MDEditor.Markdown source={post.description} className={style.reactMarkDown} style={{ whiteSpace: 'pre-wrap' }} />
</div>
<div className="items-center gap-y-4 px-4 py-10" >
<div id="textcontainer" className="wmde-markdown-var">
<MDEditor.Markdown source={post.description} className=" bg-light dark:bg-dark" style={{ whiteSpace: 'pre-wrap' }} />
</div>
</div>
</div>
);
Expand Down

0 comments on commit e533f74

Please sign in to comment.