Spaces:
Sleeping
Sleeping
Upload 121 files
Browse files- src/App.tsx +15 -8
- src/components/ComicDetail.tsx +36 -1
- src/components/FavoritesView.tsx +99 -0
- src/components/HDComicViewer.tsx +36 -1
- src/components/ImageLightbox.tsx +71 -14
- src/components/NavigationDrawer.tsx +22 -2
- src/utils/favorites.ts +56 -0
src/App.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import { TransferPagesModal } from './components/TransferPagesModal';
|
|
| 23 |
import { Category } from './types/manga';
|
| 24 |
import { PatreonIcon } from './components/PatreonIcon';
|
| 25 |
import { NavigationDrawer } from './components/NavigationDrawer';
|
|
|
|
| 26 |
|
| 27 |
import { SearchBar } from './components/SearchBar';
|
| 28 |
import { SearchResults } from './components/SearchResults';
|
|
@@ -72,11 +73,11 @@ function App() {
|
|
| 72 |
const [navigationHistory, setNavigationHistory] = useState<string[]>([]);
|
| 73 |
const [selectedChapter, setSelectedChapter] = useState<{ manga: Manga; chapter: Chapter } | null>(null);
|
| 74 |
const [mangas, setMangas] = useState<Manga[]>([]);
|
| 75 |
-
const [currentSection, setCurrentSection] = useState<'flow' | 'patreon' | 'onlyfans' | 'grok'>(() => {
|
| 76 |
const params = new URLSearchParams(window.location.search);
|
| 77 |
const sec = params.get('section');
|
| 78 |
-
if (sec === 'flow' || sec === 'patreon' || sec === 'onlyfans' || sec === 'grok') return sec as 'flow' | 'patreon' | 'onlyfans' | 'grok';
|
| 79 |
-
return (localStorage.getItem('currentSection') as 'flow' | 'patreon' | 'onlyfans' | 'grok') || 'flow';
|
| 80 |
});
|
| 81 |
const [showHD, setShowHD] = useState(false);
|
| 82 |
const [showInfo, setShowInfo] = useState(false);
|
|
@@ -116,7 +117,7 @@ function App() {
|
|
| 116 |
useEffect(() => {
|
| 117 |
localStorage.setItem('currentSection', currentSection);
|
| 118 |
const url = new URL(window.location.href);
|
| 119 |
-
if (currentSection === 'patreon' || currentSection === 'onlyfans' || currentSection === 'grok') {
|
| 120 |
url.searchParams.set('section', currentSection);
|
| 121 |
} else {
|
| 122 |
url.searchParams.delete('section');
|
|
@@ -694,10 +695,14 @@ function App() {
|
|
| 694 |
<main className="flex-1 px-4 sm:px-6 md:px-12 py-8">
|
| 695 |
<AnnouncementBanner isAdmin={isAdmin} />
|
| 696 |
|
| 697 |
-
|
| 698 |
-
<
|
| 699 |
-
|
| 700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
placeholder="Buscar por título, autor..."
|
| 702 |
sortType={sortType}
|
| 703 |
onSortTypeChange={setSortType}
|
|
@@ -835,6 +840,8 @@ function App() {
|
|
| 835 |
currentSection={currentSection}
|
| 836 |
/>
|
| 837 |
</div>
|
|
|
|
|
|
|
| 838 |
</main>
|
| 839 |
|
| 840 |
{/* Bulk Action Bar */}
|
|
|
|
| 23 |
import { Category } from './types/manga';
|
| 24 |
import { PatreonIcon } from './components/PatreonIcon';
|
| 25 |
import { NavigationDrawer } from './components/NavigationDrawer';
|
| 26 |
+
import { FavoritesView } from './components/FavoritesView';
|
| 27 |
|
| 28 |
import { SearchBar } from './components/SearchBar';
|
| 29 |
import { SearchResults } from './components/SearchResults';
|
|
|
|
| 73 |
const [navigationHistory, setNavigationHistory] = useState<string[]>([]);
|
| 74 |
const [selectedChapter, setSelectedChapter] = useState<{ manga: Manga; chapter: Chapter } | null>(null);
|
| 75 |
const [mangas, setMangas] = useState<Manga[]>([]);
|
| 76 |
+
const [currentSection, setCurrentSection] = useState<'flow' | 'patreon' | 'onlyfans' | 'grok' | 'favorites'>(() => {
|
| 77 |
const params = new URLSearchParams(window.location.search);
|
| 78 |
const sec = params.get('section');
|
| 79 |
+
if (sec === 'flow' || sec === 'patreon' || sec === 'onlyfans' || sec === 'grok' || sec === 'favorites') return sec as 'flow' | 'patreon' | 'onlyfans' | 'grok' | 'favorites';
|
| 80 |
+
return (localStorage.getItem('currentSection') as 'flow' | 'patreon' | 'onlyfans' | 'grok' | 'favorites') || 'flow';
|
| 81 |
});
|
| 82 |
const [showHD, setShowHD] = useState(false);
|
| 83 |
const [showInfo, setShowInfo] = useState(false);
|
|
|
|
| 117 |
useEffect(() => {
|
| 118 |
localStorage.setItem('currentSection', currentSection);
|
| 119 |
const url = new URL(window.location.href);
|
| 120 |
+
if (currentSection === 'patreon' || currentSection === 'onlyfans' || currentSection === 'grok' || currentSection === 'favorites') {
|
| 121 |
url.searchParams.set('section', currentSection);
|
| 122 |
} else {
|
| 123 |
url.searchParams.delete('section');
|
|
|
|
| 695 |
<main className="flex-1 px-4 sm:px-6 md:px-12 py-8">
|
| 696 |
<AnnouncementBanner isAdmin={isAdmin} />
|
| 697 |
|
| 698 |
+
{currentSection === 'favorites' ? (
|
| 699 |
+
<FavoritesView />
|
| 700 |
+
) : (
|
| 701 |
+
<>
|
| 702 |
+
<div className="max-w-[1800px] mx-auto mb-8 flex-shrink-0">
|
| 703 |
+
<SearchBar
|
| 704 |
+
value={searchTerm}
|
| 705 |
+
onChange={setSearchTerm}
|
| 706 |
placeholder="Buscar por título, autor..."
|
| 707 |
sortType={sortType}
|
| 708 |
onSortTypeChange={setSortType}
|
|
|
|
| 840 |
currentSection={currentSection}
|
| 841 |
/>
|
| 842 |
</div>
|
| 843 |
+
</>
|
| 844 |
+
)}
|
| 845 |
</main>
|
| 846 |
|
| 847 |
{/* Bulk Action Bar */}
|
src/components/ComicDetail.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { ArrowLeft, BookMarked, User, Download, Link as LinkIcon, X, Plus, Rows, Grid2X2, Grid3X3, FileText, Search, Send, Check, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, Eye, ZoomIn, ZoomOut, RotateCcw } from 'lucide-react';
|
| 2 |
import { GlobalFooter } from './GlobalFooter';
|
| 3 |
|
| 4 |
import { useState, useEffect } from 'react';
|
|
@@ -11,6 +11,7 @@ import { ImageLoader } from './ImageLoader';
|
|
| 11 |
import { MangaCard } from './MangaCard';
|
| 12 |
import { LazyImageWrapper } from './LazyImageWrapper';
|
| 13 |
import { getFolderThumbnails } from './SearchResults';
|
|
|
|
| 14 |
|
| 15 |
interface ComicDetailProps {
|
| 16 |
id: string;
|
|
@@ -48,8 +49,26 @@ export function ComicDetail({ id, onBack, onNavigateToManga, onMangaLoaded, onSe
|
|
| 48 |
const [copiedId, setCopiedId] = useState(false);
|
| 49 |
const [recPage, setRecPage] = useState(1);
|
| 50 |
const [zoomLevel, setZoomLevel] = useState(1);
|
|
|
|
| 51 |
const REC_ITEMS_PER_PAGE = 6;
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
const handleZoomIn = () => setZoomLevel(prev => Math.min(prev + 0.25, 3));
|
| 54 |
const handleZoomOut = () => setZoomLevel(prev => Math.max(prev - 0.25, 0.5));
|
| 55 |
const handleResetZoom = () => setZoomLevel(1);
|
|
@@ -811,6 +830,13 @@ export function ComicDetail({ id, onBack, onNavigateToManga, onMangaLoaded, onSe
|
|
| 811 |
className="rounded-lg"
|
| 812 |
imgClassName="group-hover:scale-110"
|
| 813 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
</div>
|
| 815 |
))
|
| 816 |
) : (
|
|
@@ -855,6 +881,13 @@ export function ComicDetail({ id, onBack, onNavigateToManga, onMangaLoaded, onSe
|
|
| 855 |
imgClassName="group-hover:scale-110"
|
| 856 |
/>
|
| 857 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 858 |
</div>
|
| 859 |
))
|
| 860 |
)}
|
|
@@ -1000,6 +1033,8 @@ export function ComicDetail({ id, onBack, onNavigateToManga, onMangaLoaded, onSe
|
|
| 1000 |
images={manga.chapters?.[0].pages || []}
|
| 1001 |
initialIndex={lightboxIndex}
|
| 1002 |
onClose={() => setLightboxOpen(false)}
|
|
|
|
|
|
|
| 1003 |
/>
|
| 1004 |
)}
|
| 1005 |
|
|
|
|
| 1 |
+
import { ArrowLeft, BookMarked, User, Download, Link as LinkIcon, X, Plus, Rows, Grid2X2, Grid3X3, FileText, Search, Send, Check, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, Eye, ZoomIn, ZoomOut, RotateCcw, Heart } from 'lucide-react';
|
| 2 |
import { GlobalFooter } from './GlobalFooter';
|
| 3 |
|
| 4 |
import { useState, useEffect } from 'react';
|
|
|
|
| 11 |
import { MangaCard } from './MangaCard';
|
| 12 |
import { LazyImageWrapper } from './LazyImageWrapper';
|
| 13 |
import { getFolderThumbnails } from './SearchResults';
|
| 14 |
+
import { addFavorite, removeFavorite, isFavorite } from '../utils/favorites';
|
| 15 |
|
| 16 |
interface ComicDetailProps {
|
| 17 |
id: string;
|
|
|
|
| 49 |
const [copiedId, setCopiedId] = useState(false);
|
| 50 |
const [recPage, setRecPage] = useState(1);
|
| 51 |
const [zoomLevel, setZoomLevel] = useState(1);
|
| 52 |
+
const [favRefresh, setFavRefresh] = useState(0); // Para forzar re-render al dar favorito
|
| 53 |
const REC_ITEMS_PER_PAGE = 6;
|
| 54 |
|
| 55 |
+
const toggleFavorite = (e: React.MouseEvent, pageUrl: string, index: number) => {
|
| 56 |
+
e.stopPropagation();
|
| 57 |
+
if (!manga) return;
|
| 58 |
+
const favId = `${manga.id}_${index}`;
|
| 59 |
+
if (isFavorite(manga.id, index)) {
|
| 60 |
+
removeFavorite(favId);
|
| 61 |
+
} else {
|
| 62 |
+
addFavorite({
|
| 63 |
+
mangaId: manga.id,
|
| 64 |
+
mangaTitle: manga.title,
|
| 65 |
+
pageUrl,
|
| 66 |
+
pageIndex: index
|
| 67 |
+
});
|
| 68 |
+
}
|
| 69 |
+
setFavRefresh(prev => prev + 1);
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
const handleZoomIn = () => setZoomLevel(prev => Math.min(prev + 0.25, 3));
|
| 73 |
const handleZoomOut = () => setZoomLevel(prev => Math.max(prev - 0.25, 0.5));
|
| 74 |
const handleResetZoom = () => setZoomLevel(1);
|
|
|
|
| 830 |
className="rounded-lg"
|
| 831 |
imgClassName="group-hover:scale-110"
|
| 832 |
/>
|
| 833 |
+
<button
|
| 834 |
+
onClick={(e) => toggleFavorite(e, pageUrl, index)}
|
| 835 |
+
className={`absolute top-2 right-2 p-2 rounded-full transition-all duration-200 z-10 ${isFavorite(manga.id, index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 836 |
+
title={isFavorite(manga.id, index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 837 |
+
>
|
| 838 |
+
<Heart className="w-4 h-4" fill={isFavorite(manga.id, index) ? "currentColor" : "none"} />
|
| 839 |
+
</button>
|
| 840 |
</div>
|
| 841 |
))
|
| 842 |
) : (
|
|
|
|
| 881 |
imgClassName="group-hover:scale-110"
|
| 882 |
/>
|
| 883 |
)}
|
| 884 |
+
<button
|
| 885 |
+
onClick={(e) => toggleFavorite(e, pageUrl, index)}
|
| 886 |
+
className={`absolute top-2 right-2 p-2 rounded-full transition-all duration-200 z-10 ${isFavorite(manga.id, index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 887 |
+
title={isFavorite(manga.id, index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 888 |
+
>
|
| 889 |
+
<Heart className="w-4 h-4" fill={isFavorite(manga.id, index) ? "currentColor" : "none"} />
|
| 890 |
+
</button>
|
| 891 |
</div>
|
| 892 |
))
|
| 893 |
)}
|
|
|
|
| 1033 |
images={manga.chapters?.[0].pages || []}
|
| 1034 |
initialIndex={lightboxIndex}
|
| 1035 |
onClose={() => setLightboxOpen(false)}
|
| 1036 |
+
mangaId={manga.id}
|
| 1037 |
+
mangaTitle={manga.title}
|
| 1038 |
/>
|
| 1039 |
)}
|
| 1040 |
|
src/components/FavoritesView.tsx
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect } from 'react';
|
| 2 |
+
import { Heart, Trash2 } from 'lucide-react';
|
| 3 |
+
import { getFavorites, removeFavorite, FavoriteImage } from '../utils/favorites';
|
| 4 |
+
import { ImageLoader } from './ImageLoader';
|
| 5 |
+
import { ImageLightbox } from './ImageLightbox';
|
| 6 |
+
|
| 7 |
+
export function FavoritesView() {
|
| 8 |
+
const [favorites, setFavorites] = useState<FavoriteImage[]>([]);
|
| 9 |
+
const [lightboxImages, setLightboxImages] = useState<string[]>([]);
|
| 10 |
+
const [lightboxIndex, setLightboxIndex] = useState(0);
|
| 11 |
+
|
| 12 |
+
const sortFavorites = (favs: FavoriteImage[]) => {
|
| 13 |
+
return favs.sort((a, b) => {
|
| 14 |
+
// Ordenar por título del cómic alfabéticamente
|
| 15 |
+
const titleCompare = a.mangaTitle.localeCompare(b.mangaTitle);
|
| 16 |
+
if (titleCompare !== 0) return titleCompare;
|
| 17 |
+
// Si es el mismo cómic, ordenar por número de página
|
| 18 |
+
return a.pageIndex - b.pageIndex;
|
| 19 |
+
});
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
useEffect(() => {
|
| 23 |
+
setFavorites(sortFavorites(getFavorites()));
|
| 24 |
+
}, []);
|
| 25 |
+
|
| 26 |
+
const handleRemove = (e: React.MouseEvent, id: string) => {
|
| 27 |
+
e.stopPropagation();
|
| 28 |
+
removeFavorite(id);
|
| 29 |
+
setFavorites(sortFavorites(getFavorites()));
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
if (favorites.length === 0) {
|
| 33 |
+
return (
|
| 34 |
+
<div className="flex flex-col items-center justify-center py-20 animate-in fade-in duration-300">
|
| 35 |
+
<Heart className="w-16 h-16 text-gray-600 mb-4 animate-bounce" />
|
| 36 |
+
<p className="text-gray-400 text-lg mb-2">No tienes páginas favoritas</p>
|
| 37 |
+
<p className="text-gray-500 text-sm">Agrega tus páginas preferidas desde el lector de cómics.</p>
|
| 38 |
+
</div>
|
| 39 |
+
);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return (
|
| 43 |
+
<div className="max-w-[1800px] mx-auto p-2 sm:p-4 animate-in fade-in duration-300">
|
| 44 |
+
<div className="flex items-center gap-2 mb-6">
|
| 45 |
+
<Heart className="w-5 h-5 sm:w-6 sm:h-6 text-[#ff4b4b] fill-[#ff4b4b]" />
|
| 46 |
+
<h2 className="text-lg sm:text-xl font-bold text-white">Tus Páginas Favoritas</h2>
|
| 47 |
+
<span className="text-gray-400 text-xs sm:text-sm ml-1">({favorites.length})</span>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<div className="masonry-container">
|
| 51 |
+
{favorites.map((fav, index) => (
|
| 52 |
+
<div
|
| 53 |
+
key={fav.id}
|
| 54 |
+
className="masonry-item group relative bg-black rounded-lg shadow-lg overflow-hidden cursor-pointer"
|
| 55 |
+
onClick={() => {
|
| 56 |
+
setLightboxImages(favorites.map(f => f.pageUrl));
|
| 57 |
+
setLightboxIndex(index);
|
| 58 |
+
}}
|
| 59 |
+
>
|
| 60 |
+
<ImageLoader
|
| 61 |
+
src={fav.pageUrl}
|
| 62 |
+
alt={`Favorito de ${fav.mangaTitle}`}
|
| 63 |
+
aspectRatio="auto"
|
| 64 |
+
objectFit="contain"
|
| 65 |
+
className="rounded-lg transition-transform duration-300 group-hover:scale-[1.02] w-full"
|
| 66 |
+
/>
|
| 67 |
+
|
| 68 |
+
{/* Overlay Info */}
|
| 69 |
+
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/0 to-black/0 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-3 sm:p-4 pointer-events-none">
|
| 70 |
+
<h3 className="text-white text-sm sm:text-base font-semibold truncate shadow-black drop-shadow-md">
|
| 71 |
+
{fav.mangaTitle}
|
| 72 |
+
</h3>
|
| 73 |
+
<p className="text-gray-300 text-xs font-medium shadow-black drop-shadow-md">
|
| 74 |
+
Página {fav.pageIndex + 1}
|
| 75 |
+
</p>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
{/* Remove Button */}
|
| 79 |
+
<button
|
| 80 |
+
onClick={(e) => handleRemove(e, fav.id)}
|
| 81 |
+
className="absolute top-2 right-2 p-2 bg-black/60 hover:bg-red-500/80 rounded-full text-white opacity-0 group-hover:opacity-100 transition-all duration-200 transform translate-y-[-10px] group-hover:translate-y-0 pointer-events-auto"
|
| 82 |
+
title="Quitar de favoritos"
|
| 83 |
+
>
|
| 84 |
+
<Trash2 className="w-4 h-4" />
|
| 85 |
+
</button>
|
| 86 |
+
</div>
|
| 87 |
+
))}
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
{lightboxImages.length > 0 && (
|
| 91 |
+
<ImageLightbox
|
| 92 |
+
images={lightboxImages}
|
| 93 |
+
initialIndex={lightboxIndex}
|
| 94 |
+
onClose={() => setLightboxImages([])}
|
| 95 |
+
/>
|
| 96 |
+
)}
|
| 97 |
+
</div>
|
| 98 |
+
);
|
| 99 |
+
}
|
src/components/HDComicViewer.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
|
| 2 |
-
import { ArrowLeft, Rows, Grid2X2, Grid3X3, ZoomIn, ZoomOut, RotateCcw } from 'lucide-react';
|
| 3 |
import { useState } from 'react';
|
| 4 |
import { Manga } from '../types/manga';
|
| 5 |
import { ImageLoader } from './ImageLoader';
|
| 6 |
import { ImageLightbox } from './ImageLightbox';
|
| 7 |
import { GlobalFooter } from './GlobalFooter';
|
| 8 |
import { LazyImageWrapper } from './LazyImageWrapper';
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
interface HDComicViewerProps {
|
|
@@ -24,6 +25,24 @@ export function HDComicViewer({ manga, onBack }: HDComicViewerProps) {
|
|
| 24 |
const [zoomLevel, setZoomLevel] = useState(1); // 1 = 100%
|
| 25 |
const [lightboxOpen, setLightboxOpen] = useState(false);
|
| 26 |
const [lightboxIndex, setLightboxIndex] = useState(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
if (!pages || pages.length === 0) {
|
| 29 |
return (
|
|
@@ -160,6 +179,13 @@ export function HDComicViewer({ manga, onBack }: HDComicViewerProps) {
|
|
| 160 |
/>
|
| 161 |
)}
|
| 162 |
</LazyImageWrapper>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
</div>
|
| 164 |
</div>
|
| 165 |
);
|
|
@@ -187,6 +213,13 @@ export function HDComicViewer({ manga, onBack }: HDComicViewerProps) {
|
|
| 187 |
className="w-full h-auto rounded-lg"
|
| 188 |
imgClassName="group-hover:scale-110"
|
| 189 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
</div>
|
| 191 |
);
|
| 192 |
})}
|
|
@@ -200,6 +233,8 @@ export function HDComicViewer({ manga, onBack }: HDComicViewerProps) {
|
|
| 200 |
images={pages} // Use direct URLs
|
| 201 |
initialIndex={lightboxIndex}
|
| 202 |
onClose={() => setLightboxOpen(false)}
|
|
|
|
|
|
|
| 203 |
/>
|
| 204 |
)}
|
| 205 |
</div>
|
|
|
|
| 1 |
|
| 2 |
+
import { ArrowLeft, Rows, Grid2X2, Grid3X3, ZoomIn, ZoomOut, RotateCcw, Heart } from 'lucide-react';
|
| 3 |
import { useState } from 'react';
|
| 4 |
import { Manga } from '../types/manga';
|
| 5 |
import { ImageLoader } from './ImageLoader';
|
| 6 |
import { ImageLightbox } from './ImageLightbox';
|
| 7 |
import { GlobalFooter } from './GlobalFooter';
|
| 8 |
import { LazyImageWrapper } from './LazyImageWrapper';
|
| 9 |
+
import { addFavorite, removeFavorite, isFavorite } from '../utils/favorites';
|
| 10 |
|
| 11 |
|
| 12 |
interface HDComicViewerProps {
|
|
|
|
| 25 |
const [zoomLevel, setZoomLevel] = useState(1); // 1 = 100%
|
| 26 |
const [lightboxOpen, setLightboxOpen] = useState(false);
|
| 27 |
const [lightboxIndex, setLightboxIndex] = useState(0);
|
| 28 |
+
const [favRefresh, setFavRefresh] = useState(0);
|
| 29 |
+
|
| 30 |
+
const toggleFavorite = (e: React.MouseEvent, pageUrl: string, index: number) => {
|
| 31 |
+
e.stopPropagation();
|
| 32 |
+
if (!manga) return;
|
| 33 |
+
const favId = `${manga.id}_${index}`;
|
| 34 |
+
if (isFavorite(manga.id, index)) {
|
| 35 |
+
removeFavorite(favId);
|
| 36 |
+
} else {
|
| 37 |
+
addFavorite({
|
| 38 |
+
mangaId: manga.id,
|
| 39 |
+
mangaTitle: manga.title,
|
| 40 |
+
pageUrl,
|
| 41 |
+
pageIndex: index
|
| 42 |
+
});
|
| 43 |
+
}
|
| 44 |
+
setFavRefresh(prev => prev + 1);
|
| 45 |
+
};
|
| 46 |
|
| 47 |
if (!pages || pages.length === 0) {
|
| 48 |
return (
|
|
|
|
| 179 |
/>
|
| 180 |
)}
|
| 181 |
</LazyImageWrapper>
|
| 182 |
+
<button
|
| 183 |
+
onClick={(e) => toggleFavorite(e, src, index)}
|
| 184 |
+
className={`absolute top-4 right-4 p-3 rounded-full transition-all duration-200 z-[40] ${isFavorite(manga.id, index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 185 |
+
title={isFavorite(manga.id, index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 186 |
+
>
|
| 187 |
+
<Heart className="w-6 h-6" fill={isFavorite(manga.id, index) ? "currentColor" : "none"} />
|
| 188 |
+
</button>
|
| 189 |
</div>
|
| 190 |
</div>
|
| 191 |
);
|
|
|
|
| 213 |
className="w-full h-auto rounded-lg"
|
| 214 |
imgClassName="group-hover:scale-110"
|
| 215 |
/>
|
| 216 |
+
<button
|
| 217 |
+
onClick={(e) => toggleFavorite(e, src, index)}
|
| 218 |
+
className={`absolute top-2 right-2 p-2 rounded-full transition-all duration-200 z-10 ${isFavorite(manga.id, index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 219 |
+
title={isFavorite(manga.id, index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 220 |
+
>
|
| 221 |
+
<Heart className="w-4 h-4" fill={isFavorite(manga.id, index) ? "currentColor" : "none"} />
|
| 222 |
+
</button>
|
| 223 |
</div>
|
| 224 |
);
|
| 225 |
})}
|
|
|
|
| 233 |
images={pages} // Use direct URLs
|
| 234 |
initialIndex={lightboxIndex}
|
| 235 |
onClose={() => setLightboxOpen(false)}
|
| 236 |
+
mangaId={manga.id}
|
| 237 |
+
mangaTitle={manga.title}
|
| 238 |
/>
|
| 239 |
)}
|
| 240 |
</div>
|
src/components/ImageLightbox.tsx
CHANGED
|
@@ -1,16 +1,20 @@
|
|
| 1 |
-
import { ChevronLeft, ChevronRight, X, ZoomIn, ZoomOut, BookOpen, Book } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useRef } from 'react';
|
| 3 |
import { ImageLoader } from './ImageLoader';
|
|
|
|
| 4 |
|
| 5 |
interface ImageLightboxProps {
|
| 6 |
images: string[];
|
| 7 |
initialIndex: number;
|
| 8 |
onClose: () => void;
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
-
export function ImageLightbox({ images, initialIndex, onClose }: ImageLightboxProps) {
|
| 12 |
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
| 13 |
const [isBookMode, setIsBookMode] = useState(false);
|
|
|
|
| 14 |
|
| 15 |
// -- Carousel State --
|
| 16 |
const [dragOffset, setDragOffset] = useState(0); // Pixels
|
|
@@ -198,23 +202,42 @@ export function ImageLightbox({ images, initialIndex, onClose }: ImageLightboxPr
|
|
| 198 |
|
| 199 |
if (!isBookMode) {
|
| 200 |
return (
|
| 201 |
-
<
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
);
|
| 212 |
} else {
|
| 213 |
const img2Index = getWrappedIndex(baseIndex + 1);
|
| 214 |
return (
|
| 215 |
<div className="flex w-full h-full items-center justify-center px-2 sm:px-10">
|
| 216 |
{/* Page 1 (Left) */}
|
| 217 |
-
<div className="flex-1 h-full flex items-center justify-end">
|
| 218 |
<ImageLoader
|
| 219 |
src={images[img1Index]}
|
| 220 |
alt={`Página ${img1Index + 1}`}
|
|
@@ -225,9 +248,26 @@ export function ImageLightbox({ images, initialIndex, onClose }: ImageLightboxPr
|
|
| 225 |
imgClassName="max-w-full max-h-screen object-contain select-none shadow-lg origin-right object-right transition-none"
|
| 226 |
showControls={true}
|
| 227 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</div>
|
| 229 |
{/* Page 2 (Right) */}
|
| 230 |
-
<div className="flex-1 h-full flex items-center justify-start">
|
| 231 |
<ImageLoader
|
| 232 |
src={images[img2Index]}
|
| 233 |
alt={`Página ${img2Index + 1}`}
|
|
@@ -238,6 +278,23 @@ export function ImageLightbox({ images, initialIndex, onClose }: ImageLightboxPr
|
|
| 238 |
imgClassName="max-w-full max-h-screen object-contain select-none shadow-lg origin-left object-left transition-none"
|
| 239 |
showControls={true}
|
| 240 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
</div>
|
| 242 |
</div>
|
| 243 |
);
|
|
|
|
| 1 |
+
import { ChevronLeft, ChevronRight, X, ZoomIn, ZoomOut, BookOpen, Book, Heart } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useRef } from 'react';
|
| 3 |
import { ImageLoader } from './ImageLoader';
|
| 4 |
+
import { addFavorite, removeFavorite, isFavorite } from '../utils/favorites';
|
| 5 |
|
| 6 |
interface ImageLightboxProps {
|
| 7 |
images: string[];
|
| 8 |
initialIndex: number;
|
| 9 |
onClose: () => void;
|
| 10 |
+
mangaId?: string;
|
| 11 |
+
mangaTitle?: string;
|
| 12 |
}
|
| 13 |
|
| 14 |
+
export function ImageLightbox({ images, initialIndex, onClose, mangaId, mangaTitle }: ImageLightboxProps) {
|
| 15 |
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
| 16 |
const [isBookMode, setIsBookMode] = useState(false);
|
| 17 |
+
const [favRefresh, setFavRefresh] = useState(0);
|
| 18 |
|
| 19 |
// -- Carousel State --
|
| 20 |
const [dragOffset, setDragOffset] = useState(0); // Pixels
|
|
|
|
| 202 |
|
| 203 |
if (!isBookMode) {
|
| 204 |
return (
|
| 205 |
+
<div className="relative w-full h-full flex items-center justify-center">
|
| 206 |
+
<ImageLoader
|
| 207 |
+
src={images[img1Index]}
|
| 208 |
+
alt={`Página ${img1Index + 1}`}
|
| 209 |
+
aspectRatio="auto"
|
| 210 |
+
objectFit="contain"
|
| 211 |
+
loading="lazy"
|
| 212 |
+
draggable={false}
|
| 213 |
+
imgClassName="max-w-full max-h-screen object-contain select-none shadow-2xl transition-none"
|
| 214 |
+
showControls={true}
|
| 215 |
+
/>
|
| 216 |
+
{mangaId && mangaTitle && (
|
| 217 |
+
<button
|
| 218 |
+
onClick={(e) => {
|
| 219 |
+
e.stopPropagation();
|
| 220 |
+
if (isFavorite(mangaId, img1Index)) {
|
| 221 |
+
removeFavorite(`${mangaId}_${img1Index}`);
|
| 222 |
+
} else {
|
| 223 |
+
addFavorite({ mangaId, mangaTitle, pageUrl: images[img1Index], pageIndex: img1Index });
|
| 224 |
+
}
|
| 225 |
+
setFavRefresh(p => p + 1);
|
| 226 |
+
}}
|
| 227 |
+
className={`absolute top-6 left-6 p-3 rounded-full transition-all duration-200 z-[60] ${isFavorite(mangaId, img1Index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 228 |
+
title={isFavorite(mangaId, img1Index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 229 |
+
>
|
| 230 |
+
<Heart className="w-6 h-6" fill={isFavorite(mangaId, img1Index) ? "currentColor" : "none"} />
|
| 231 |
+
</button>
|
| 232 |
+
)}
|
| 233 |
+
</div>
|
| 234 |
);
|
| 235 |
} else {
|
| 236 |
const img2Index = getWrappedIndex(baseIndex + 1);
|
| 237 |
return (
|
| 238 |
<div className="flex w-full h-full items-center justify-center px-2 sm:px-10">
|
| 239 |
{/* Page 1 (Left) */}
|
| 240 |
+
<div className="flex-1 h-full flex items-center justify-end relative">
|
| 241 |
<ImageLoader
|
| 242 |
src={images[img1Index]}
|
| 243 |
alt={`Página ${img1Index + 1}`}
|
|
|
|
| 248 |
imgClassName="max-w-full max-h-screen object-contain select-none shadow-lg origin-right object-right transition-none"
|
| 249 |
showControls={true}
|
| 250 |
/>
|
| 251 |
+
{mangaId && mangaTitle && (
|
| 252 |
+
<button
|
| 253 |
+
onClick={(e) => {
|
| 254 |
+
e.stopPropagation();
|
| 255 |
+
if (isFavorite(mangaId, img1Index)) {
|
| 256 |
+
removeFavorite(`${mangaId}_${img1Index}`);
|
| 257 |
+
} else {
|
| 258 |
+
addFavorite({ mangaId, mangaTitle, pageUrl: images[img1Index], pageIndex: img1Index });
|
| 259 |
+
}
|
| 260 |
+
setFavRefresh(p => p + 1);
|
| 261 |
+
}}
|
| 262 |
+
className={`absolute top-6 left-6 p-3 rounded-full transition-all duration-200 z-[60] ${isFavorite(mangaId, img1Index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 263 |
+
title={isFavorite(mangaId, img1Index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 264 |
+
>
|
| 265 |
+
<Heart className="w-5 h-5" fill={isFavorite(mangaId, img1Index) ? "currentColor" : "none"} />
|
| 266 |
+
</button>
|
| 267 |
+
)}
|
| 268 |
</div>
|
| 269 |
{/* Page 2 (Right) */}
|
| 270 |
+
<div className="flex-1 h-full flex items-center justify-start relative">
|
| 271 |
<ImageLoader
|
| 272 |
src={images[img2Index]}
|
| 273 |
alt={`Página ${img2Index + 1}`}
|
|
|
|
| 278 |
imgClassName="max-w-full max-h-screen object-contain select-none shadow-lg origin-left object-left transition-none"
|
| 279 |
showControls={true}
|
| 280 |
/>
|
| 281 |
+
{mangaId && mangaTitle && (
|
| 282 |
+
<button
|
| 283 |
+
onClick={(e) => {
|
| 284 |
+
e.stopPropagation();
|
| 285 |
+
if (isFavorite(mangaId, img2Index)) {
|
| 286 |
+
removeFavorite(`${mangaId}_${img2Index}`);
|
| 287 |
+
} else {
|
| 288 |
+
addFavorite({ mangaId, mangaTitle, pageUrl: images[img2Index], pageIndex: img2Index });
|
| 289 |
+
}
|
| 290 |
+
setFavRefresh(p => p + 1);
|
| 291 |
+
}}
|
| 292 |
+
className={`absolute top-6 right-6 p-3 rounded-full transition-all duration-200 z-[60] ${isFavorite(mangaId, img2Index) ? 'bg-[#ff4b4b]/20 text-[#ff4b4b]' : 'bg-black/50 text-white hover:bg-[#ff4b4b]/20 hover:text-[#ff4b4b]'}`}
|
| 293 |
+
title={isFavorite(mangaId, img2Index) ? "Quitar de favoritos" : "Añadir a favoritos"}
|
| 294 |
+
>
|
| 295 |
+
<Heart className="w-5 h-5" fill={isFavorite(mangaId, img2Index) ? "currentColor" : "none"} />
|
| 296 |
+
</button>
|
| 297 |
+
)}
|
| 298 |
</div>
|
| 299 |
</div>
|
| 300 |
);
|
src/components/NavigationDrawer.tsx
CHANGED
|
@@ -5,8 +5,8 @@ import { OnlyFansIcon } from './OnlyFansIcon';
|
|
| 5 |
import { GrokIcon } from './GrokIcon';
|
| 6 |
|
| 7 |
interface NavigationDrawerProps {
|
| 8 |
-
currentSection: 'flow' | 'patreon' | 'onlyfans' | 'grok';
|
| 9 |
-
onSectionChange: (section: 'flow' | 'patreon' | 'onlyfans' | 'grok') => void;
|
| 10 |
}
|
| 11 |
|
| 12 |
export function NavigationDrawer({ currentSection, onSectionChange }: NavigationDrawerProps) {
|
|
@@ -99,6 +99,26 @@ export function NavigationDrawer({ currentSection, onSectionChange }: Navigation
|
|
| 99 |
<GrokIcon className="w-5 h-5" />
|
| 100 |
Grok
|
| 101 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</div>
|
| 103 |
</div>
|
| 104 |
</>
|
|
|
|
| 5 |
import { GrokIcon } from './GrokIcon';
|
| 6 |
|
| 7 |
interface NavigationDrawerProps {
|
| 8 |
+
currentSection: 'flow' | 'patreon' | 'onlyfans' | 'grok' | 'favorites';
|
| 9 |
+
onSectionChange: (section: 'flow' | 'patreon' | 'onlyfans' | 'grok' | 'favorites') => void;
|
| 10 |
}
|
| 11 |
|
| 12 |
export function NavigationDrawer({ currentSection, onSectionChange }: NavigationDrawerProps) {
|
|
|
|
| 99 |
<GrokIcon className="w-5 h-5" />
|
| 100 |
Grok
|
| 101 |
</button>
|
| 102 |
+
|
| 103 |
+
<div className="text-xs font-semibold text-gray-500 uppercase tracking-wider mt-4 mb-2 px-2">
|
| 104 |
+
Personal
|
| 105 |
+
</div>
|
| 106 |
+
<button
|
| 107 |
+
onClick={() => {
|
| 108 |
+
onSectionChange('favorites');
|
| 109 |
+
setIsOpen(false);
|
| 110 |
+
}}
|
| 111 |
+
className={`flex items-center gap-3 w-full p-3 rounded-xl font-semibold transition-all active:scale-95 ${
|
| 112 |
+
currentSection === 'favorites'
|
| 113 |
+
? 'bg-[#ff4b4b]/10 text-[#ff4b4b] border border-[#ff4b4b]/20 hover:bg-[#ff4b4b]/20'
|
| 114 |
+
: 'text-gray-300 hover:bg-white/5 border border-transparent'
|
| 115 |
+
}`}
|
| 116 |
+
>
|
| 117 |
+
<svg className="w-5 h-5" fill={currentSection === 'favorites' ? 'currentColor' : 'none'} viewBox="0 0 24 24" stroke="currentColor">
|
| 118 |
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
| 119 |
+
</svg>
|
| 120 |
+
Favoritos
|
| 121 |
+
</button>
|
| 122 |
</div>
|
| 123 |
</div>
|
| 124 |
</>
|
src/utils/favorites.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface FavoriteImage {
|
| 2 |
+
id: string; // unique ID for the favorite
|
| 3 |
+
mangaId: string;
|
| 4 |
+
mangaTitle: string;
|
| 5 |
+
pageUrl: string;
|
| 6 |
+
pageIndex: number;
|
| 7 |
+
addedAt: number;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
const FAVORITES_KEY = 'twistedbrody_favorites';
|
| 11 |
+
|
| 12 |
+
export function getFavorites(): FavoriteImage[] {
|
| 13 |
+
try {
|
| 14 |
+
const data = localStorage.getItem(FAVORITES_KEY);
|
| 15 |
+
return data ? JSON.parse(data) : [];
|
| 16 |
+
} catch (err) {
|
| 17 |
+
console.error('Error loading favorites:', err);
|
| 18 |
+
return [];
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export function saveFavorites(favorites: FavoriteImage[]): void {
|
| 23 |
+
try {
|
| 24 |
+
localStorage.setItem(FAVORITES_KEY, JSON.stringify(favorites));
|
| 25 |
+
} catch (err) {
|
| 26 |
+
console.error('Error saving favorites:', err);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export function addFavorite(favorite: Omit<FavoriteImage, 'id' | 'addedAt'>): FavoriteImage {
|
| 31 |
+
const favorites = getFavorites();
|
| 32 |
+
const newFav: FavoriteImage = {
|
| 33 |
+
...favorite,
|
| 34 |
+
id: `${favorite.mangaId}_${favorite.pageIndex}`,
|
| 35 |
+
addedAt: Date.now()
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
// Prevent duplicates
|
| 39 |
+
if (!favorites.some(f => f.id === newFav.id)) {
|
| 40 |
+
favorites.push(newFav);
|
| 41 |
+
saveFavorites(favorites);
|
| 42 |
+
}
|
| 43 |
+
return newFav;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
export function removeFavorite(id: string): void {
|
| 47 |
+
const favorites = getFavorites();
|
| 48 |
+
const updated = favorites.filter(f => f.id !== id);
|
| 49 |
+
saveFavorites(updated);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
export function isFavorite(mangaId: string, pageIndex: number): boolean {
|
| 53 |
+
const favorites = getFavorites();
|
| 54 |
+
const id = `${mangaId}_${pageIndex}`;
|
| 55 |
+
return favorites.some(f => f.id === id);
|
| 56 |
+
}
|