From 55877854b67104b4b5643211153c47a00f59e087 Mon Sep 17 00:00:00 2001 From: Akshat752 Date: Sat, 16 May 2026 16:15:33 -0400 Subject: [PATCH 1/2] Favorites --- src/App.jsx | 40 +++++++++++------ src/components/ComicDisplay.jsx | 58 ++++++++++++++++++------- src/components/FavoritesPanel.jsx | 71 +++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 28 deletions(-) create mode 100644 src/components/FavoritesPanel.jsx diff --git a/src/App.jsx b/src/App.jsx index f6d170c..96bde95 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -6,6 +6,7 @@ import SearchResults from './components/SearchResults' import ComicDisplay from './components/ComicDisplay' import NavigationButtons from './components/NavigationButtons' import TranscriptPanel from './components/TranscriptPanel' +import FavoritesPanel from './components/FavoritesPanel' import DarkModeToggle from './components/DarkModeToggle' import SettingsModal from './components/SettingsModal' import Blog from './components/Blog' @@ -151,6 +152,16 @@ function ComicsView() { }) const [isSettingsOpen, setIsSettingsOpen] = useState(false) + const [favorites, setFavorites] = useState(() => { + + if (typeof window !== 'undefined') { + const saved = localStorage.getItem('favorites') + return saved ? JSON.parse(saved) : ['2010-03-28','2005-05-17','2001-03-08','1995-06-12','2021-09-16'] + } + return ['2010-03-28','2005-05-17', '2001-03-08', '1995-06-12','2021-09-16'] + + }) + const baseUrl = import.meta.env.BASE_URL // Helper function to load a year's data (with caching) @@ -817,7 +828,7 @@ function ComicsView() { return ( <> - {currentDate && currentComic ? ( + {currentDate ? (
{/* Left column - Comic (70%) */}
@@ -828,6 +839,8 @@ function ComicsView() { comicsData={comicsData} comicsIndex={comicsIndex} useLocalImages={useLocalImages} + favorites={favorites} + setFavorites={setFavorites} />
@@ -888,20 +901,23 @@ function ComicsView() { )} ) : ( -
- -
+ <> +
+ +
+
+ +
+ )} - ) : currentDate ? ( -
-
-

Loading comic data...

-
) : null} {/* Settings Modal */} diff --git a/src/components/ComicDisplay.jsx b/src/components/ComicDisplay.jsx index 80183eb..3864778 100644 --- a/src/components/ComicDisplay.jsx +++ b/src/components/ComicDisplay.jsx @@ -1,7 +1,6 @@ import { useEffect, useCallback, useState } from 'react' -function ComicDisplay({ date, comic, comicsData, comicsIndex, useLocalImages }) { - const [showTranscript, setShowTranscript] = useState(false) +function ComicDisplay({ date, comic, comicsData, comicsIndex, useLocalImages,favorites,setFavorites }) { const [imageError, setImageError] = useState(false) const [isArchiveOrgError, setIsArchiveOrgError] = useState(false) @@ -28,7 +27,11 @@ function ComicDisplay({ date, comic, comicsData, comicsIndex, useLocalImages }) } // When local images are disabled, use archive.org URL - return comicData.originalimageurl || '' + // return comicData.originalimageurl || '' + return comicData.originalimageurl.replace( + /^https?:\/\/web\.archive\.org\/web\/[^/]+\/(https?:\/\/.+)$/, + '$1' + ); }, [useLocalImages]) // Reset error state when comic or image source changes @@ -80,19 +83,42 @@ function ComicDisplay({ date, comic, comicsData, comicsIndex, useLocalImages }) return (
-
-

- {h2Content} -

-
- - - - -
-
+
+
+

+ {h2Content} +

+ + +
+ +
+ + + + +
+
diff --git a/src/components/FavoritesPanel.jsx b/src/components/FavoritesPanel.jsx new file mode 100644 index 0000000..b8a04bd --- /dev/null +++ b/src/components/FavoritesPanel.jsx @@ -0,0 +1,71 @@ +import { useState } from 'react' +import { useNavigate, useParams } from 'react-router-dom' + +function FavoritesPanel({ favorites, setFavorites }) { + const [showFavorites, setShowFavorites] = useState(false) + const navigate = useNavigate() + const { date: currentDate } = useParams() + + return ( +
+ + + {showFavorites && ( +
+ {favorites.length > 0 ? ( + favorites.map((date) => ( + + )) + ) : ( +

Click the star to favorite comics.

+ )} +
+ )} +
+ ) +} + +export default FavoritesPanel \ No newline at end of file From a4f73104b398f22b7bbea6fba10a5735e1ecada0 Mon Sep 17 00:00:00 2001 From: Akshat752 Date: Mon, 15 Jun 2026 15:20:19 -0400 Subject: [PATCH 2/2] remove default favorites --- src/App.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 40ebfc9..1b57e10 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -152,9 +152,9 @@ function ComicsView({ useLocalImages, useArchivedUrls }) { if (typeof window !== 'undefined') { const saved = localStorage.getItem('favorites') - return saved ? JSON.parse(saved) : ['2010-03-28','2005-05-17','2001-03-08','1995-06-12','2021-09-16'] + return saved ? JSON.parse(saved) : [] } - return ['2010-03-28','2005-05-17', '2001-03-08', '1995-06-12','2021-09-16'] + return [] })