Skip to content

Commit d0456ac

Browse files
Refactor: remove unused dark mode state and simplify className concatenation
1 parent 7a4af55 commit d0456ac

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

src/pages/More.tsx

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

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-
4631
useEffect(() => {
4732
const loadPage = async () => {
4833
setIsLoading(true);
@@ -60,7 +45,7 @@ const MorePage: React.FC = () => {
6045
if (fetchedPage) {
6146
setPage(fetchedPage);
6247
setNotFoundSlug(null);
63-
document.title = `${fetchedPage.title} - Sugar Labs`;
48+
document.title = fetchedPage.title + ' - Sugar Labs';
6449

6550
if (fetchedPage.category) {
6651
setActiveCategory(fetchedPage.category);
@@ -147,11 +132,7 @@ const MorePage: React.FC = () => {
147132
className="text-blue-600 hover:underline mb-2 inline-block"
148133
>
149134
<motion.button
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-
}
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"
155136
whileHover={{ scale: 1.05 }}
156137
whileTap={{ scale: 0.95 }}
157138
>
@@ -203,7 +184,7 @@ const MorePage: React.FC = () => {
203184
<h3 className="font-bold text-xl mb-4">
204185
{activeCategory === 'All'
205186
? 'All Pages'
206-
: `${activeCategory} Pages`}
187+
: activeCategory + ' Pages'}
207188
</h3>
208189
<ul className="space-y-2">
209190
{pagesByCategory[activeCategory]?.map((linkPage) => (
@@ -232,11 +213,7 @@ const MorePage: React.FC = () => {
232213
transition={{ duration: 0.5 }}
233214
key={page?.slug}
234215
>
235-
<div
236-
className={`${
237-
isDarkMode ? 'bg-amber-950' : 'bg-white'
238-
} rounded-lg shadow-md p-6`}
239-
>
216+
<div className="bg-white rounded-lg shadow-md p-6">
240217
{page ? (
241218
<div className="prose prose-lg max-w-none">
242219
<MarkdownRenderer
@@ -320,12 +297,7 @@ const MorePage: React.FC = () => {
320297
</p>
321298
<button
322299
onClick={closeImageModal}
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-
}
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"
329301
aria-label="Close image"
330302
>
331303
&times;

0 commit comments

Comments
 (0)