Skip to content

Commit e115e72

Browse files
Feat: enhance dark mode support and improve styling for MorePage
1 parent 035b782 commit e115e72

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

src/pages/More.tsx

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const MorePage: React.FC = () => {
2020
const [pagesByCategory, setPagesByCategory] = useState<
2121
Record<string, MorePageType[]>
2222
>({});
23+
const [isDarkMode, setIsDarkMode] = useState(false);
2324
const [activeCategory, setActiveCategory] = useState<string>('All');
2425
const [notFoundSlug, setNotFoundSlug] = useState<string | null>(null);
2526
const [zoomableImages, setZoomableImages] = useState<HTMLImageElement[]>([]);
@@ -28,6 +29,20 @@ const MorePage: React.FC = () => {
2829
alt: string;
2930
} | null>(null);
3031

32+
useEffect(() => {
33+
const dark = document.documentElement.classList.contains('dark');
34+
setIsDarkMode(dark);
35+
36+
const observer = new MutationObserver(() => {
37+
const updatedDark = document.documentElement.classList.contains('dark');
38+
setIsDarkMode(updatedDark);
39+
});
40+
41+
observer.observe(document.documentElement, { attributes: true });
42+
43+
return () => observer.disconnect();
44+
}, []);
45+
3146
useEffect(() => {
3247
const loadPage = async () => {
3348
setIsLoading(true);
@@ -45,7 +60,7 @@ const MorePage: React.FC = () => {
4560
if (fetchedPage) {
4661
setPage(fetchedPage);
4762
setNotFoundSlug(null);
48-
document.title = fetchedPage.title + ' - Sugar Labs';
63+
document.title = `${fetchedPage.title} - Sugar Labs`;
4964

5065
if (fetchedPage.category) {
5166
setActiveCategory(fetchedPage.category);
@@ -132,7 +147,11 @@ const MorePage: React.FC = () => {
132147
className="text-blue-600 hover:underline mb-2 inline-block"
133148
>
134149
<motion.button
135-
className="mb-6 px-4 py-2 flex items-center text-blue-600 hover:text-blue-700 transition-colors rounded-md hover:bg-blue-50"
150+
className={
151+
'mb-6 px-4 py-2 flex items-center text-blue-600 ' +
152+
'hover:text-blue-700 transition-colors rounded-md ' +
153+
'hover:bg-blue-50'
154+
}
136155
whileHover={{ scale: 1.05 }}
137156
whileTap={{ scale: 0.95 }}
138157
>
@@ -184,7 +203,7 @@ const MorePage: React.FC = () => {
184203
<h3 className="font-bold text-xl mb-4">
185204
{activeCategory === 'All'
186205
? 'All Pages'
187-
: activeCategory + ' Pages'}
206+
: `${activeCategory} Pages`}
188207
</h3>
189208
<ul className="space-y-2">
190209
{pagesByCategory[activeCategory]?.map((linkPage) => (
@@ -213,7 +232,11 @@ const MorePage: React.FC = () => {
213232
transition={{ duration: 0.5 }}
214233
key={page?.slug}
215234
>
216-
<div className="bg-white rounded-lg shadow-md p-6">
235+
<div
236+
className={`${
237+
isDarkMode ? 'bg-amber-950' : 'bg-white'
238+
} rounded-lg shadow-md p-6`}
239+
>
217240
{page ? (
218241
<div className="prose prose-lg max-w-none">
219242
<MarkdownRenderer
@@ -297,7 +320,12 @@ const MorePage: React.FC = () => {
297320
</p>
298321
<button
299322
onClick={closeImageModal}
300-
className="absolute top-2 right-2 text-white text-2xl hover:text-gray-300 bg-black bg-opacity-50 rounded-full w-8 h-8 flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-white"
323+
className={
324+
'absolute top-2 right-2 text-white text-2xl ' +
325+
'hover:text-gray-300 bg-black bg-opacity-50 rounded-full ' +
326+
'w-8 h-8 flex items-center justify-center ' +
327+
'focus:outline-none focus:ring-2 focus:ring-white'
328+
}
301329
aria-label="Close image"
302330
>
303331
&times;

0 commit comments

Comments
 (0)