codebybrody commited on
Commit
3a9b9e3
·
verified ·
1 Parent(s): 0163351

Upload 105 files

Browse files
package-lock.json CHANGED
@@ -21,7 +21,8 @@
21
  "react-dom": "^18.3.1",
22
  "react-markdown": "^10.1.0",
23
  "sharp": "^0.34.5",
24
- "sonner": "^2.0.7"
 
25
  },
26
  "devDependencies": {
27
  "@eslint/js": "^9.9.1",
@@ -9385,6 +9386,25 @@
9385
  "node": ">=12.0.0"
9386
  }
9387
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9388
  "node_modules/tailwindcss": {
9389
  "version": "3.4.19",
9390
  "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz",
 
21
  "react-dom": "^18.3.1",
22
  "react-markdown": "^10.1.0",
23
  "sharp": "^0.34.5",
24
+ "sonner": "^2.0.7",
25
+ "swiper": "^12.1.3"
26
  },
27
  "devDependencies": {
28
  "@eslint/js": "^9.9.1",
 
9386
  "node": ">=12.0.0"
9387
  }
9388
  },
9389
+ "node_modules/swiper": {
9390
+ "version": "12.1.3",
9391
+ "resolved": "https://registry.npmjs.org/swiper/-/swiper-12.1.3.tgz",
9392
+ "integrity": "sha512-XcWlVmkHFICI4fuoJKgbp8PscDcS4i7pBH8nwJRBi3dpQvhCySwsWRYm4bOf/BzKVWkHOYaFw7qz9uBSrY3oug==",
9393
+ "funding": [
9394
+ {
9395
+ "type": "patreon",
9396
+ "url": "https://www.patreon.com/swiperjs"
9397
+ },
9398
+ {
9399
+ "type": "open_collective",
9400
+ "url": "http://opencollective.com/swiper"
9401
+ }
9402
+ ],
9403
+ "license": "MIT",
9404
+ "engines": {
9405
+ "node": ">= 4.7.0"
9406
+ }
9407
+ },
9408
  "node_modules/tailwindcss": {
9409
  "version": "3.4.19",
9410
  "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz",
package.json CHANGED
@@ -26,7 +26,8 @@
26
  "react-dom": "^18.3.1",
27
  "react-markdown": "^10.1.0",
28
  "sharp": "^0.34.5",
29
- "sonner": "^2.0.7"
 
30
  },
31
  "devDependencies": {
32
  "@eslint/js": "^9.9.1",
 
26
  "react-dom": "^18.3.1",
27
  "react-markdown": "^10.1.0",
28
  "sharp": "^0.34.5",
29
+ "sonner": "^2.0.7",
30
+ "swiper": "^12.1.3"
31
  },
32
  "devDependencies": {
33
  "@eslint/js": "^9.9.1",
src/components/MangaCard.tsx CHANGED
@@ -1,10 +1,14 @@
1
- import { useState } from 'react';
2
  import { BookOpen, Edit2, Trash2, Check, Folder } from 'lucide-react';
3
  import { Manga } from '../types/manga';
4
  import { ImageLoader } from './ImageLoader';
5
  import { incrementMangaViews } from '../services/manga';
6
-
7
  import { getThumbnailUrl } from '../utils/imageUtils';
 
 
 
 
 
8
 
9
  interface MangaCardProps {
10
  id: string;
@@ -26,7 +30,38 @@ interface MangaCardProps {
26
 
27
  export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSelect, onEdit, onDelete, isCategoryPlusEnabled, isSelected, onMouseDown, onMouseEnter, folderItemCount, folderThumbnails }: MangaCardProps) {
28
  const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
 
29
  const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  const handleDeleteClick = (e: React.MouseEvent) => {
32
  e.stopPropagation();
@@ -69,15 +104,75 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
69
  <div className="w-full aspect-[2/3] relative flex items-center justify-center bg-gradient-to-br from-[#1a1a1a] to-[#2a2a2a] rounded-lg border-2 border-gray-800 transition-colors duration-300 overflow-hidden group-hover:border-purple-500/50">
70
  {folderThumbnails && folderThumbnails.length > 0 ? (
71
  <>
72
- <div className="absolute inset-0 w-full h-full">
73
- <ImageLoader
74
- src={getThumbnailUrl(folderThumbnails[0]) || ''}
75
- alt="Folder Cover"
76
- aspectRatio="2/3"
77
- objectFit="cover"
78
- className="w-full h-full"
79
- imgClassName="transition-transform duration-700 group-hover:scale-110 opacity-70"
80
- />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  </div>
82
  <div className="absolute inset-x-0 bottom-0 h-1/2 bg-gradient-to-t from-black/90 to-transparent pointer-events-none"></div>
83
 
 
1
+ import { useState, useEffect } from 'react';
2
  import { BookOpen, Edit2, Trash2, Check, Folder } from 'lucide-react';
3
  import { Manga } from '../types/manga';
4
  import { ImageLoader } from './ImageLoader';
5
  import { incrementMangaViews } from '../services/manga';
 
6
  import { getThumbnailUrl } from '../utils/imageUtils';
7
+ import { Swiper, SwiperSlide } from 'swiper/react';
8
+ import { EffectCreative } from 'swiper/modules';
9
+ import 'swiper/css';
10
+ import 'swiper/css/effect-creative';
11
+ import 'swiper/css/autoplay';
12
 
13
  interface MangaCardProps {
14
  id: string;
 
30
 
31
  export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSelect, onEdit, onDelete, isCategoryPlusEnabled, isSelected, onMouseDown, onMouseEnter, folderItemCount, folderThumbnails }: MangaCardProps) {
32
  const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
33
+ const [currentThumbIndex, setCurrentThumbIndex] = useState(0);
34
  const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
35
+ const [swiperInstance, setSwiperInstance] = useState<any>(null);
36
+ const [isZoomedIn, setIsZoomedIn] = useState(true);
37
+
38
+ useEffect(() => {
39
+ let interval: NodeJS.Timeout;
40
+
41
+ // Crossfade fallback for exactly 2 images
42
+ if (manga?.is_folder && folderThumbnails && folderThumbnails.length === 2) {
43
+ interval = setInterval(() => {
44
+ setCurrentThumbIndex((prev) => (prev + 1) % folderThumbnails.length);
45
+ }, 4000);
46
+ }
47
+
48
+ // Staggered zoom-slide-zoom animation for > 2 items
49
+ if (swiperInstance && manga?.is_folder && folderThumbnails && folderThumbnails.length > 2) {
50
+ interval = setInterval(() => {
51
+ setIsZoomedIn(false); // 1. Zoom out
52
+
53
+ setTimeout(() => {
54
+ swiperInstance.slideNext(600); // 2. Slide
55
+
56
+ setTimeout(() => {
57
+ setIsZoomedIn(true); // 3. Zoom in
58
+ }, 700); // Wait for slide to end
59
+ }, 400); // Wait for zoom out to end
60
+ }, 4500); // Cycle total
61
+ }
62
+
63
+ return () => clearInterval(interval);
64
+ }, [manga?.is_folder, folderThumbnails, swiperInstance]);
65
 
66
  const handleDeleteClick = (e: React.MouseEvent) => {
67
  e.stopPropagation();
 
104
  <div className="w-full aspect-[2/3] relative flex items-center justify-center bg-gradient-to-br from-[#1a1a1a] to-[#2a2a2a] rounded-lg border-2 border-gray-800 transition-colors duration-300 overflow-hidden group-hover:border-purple-500/50">
105
  {folderThumbnails && folderThumbnails.length > 0 ? (
106
  <>
107
+ <div className="absolute inset-0 w-full h-full bg-black flex items-center justify-center overflow-hidden pointer-events-none">
108
+ {folderThumbnails.length > 2 ? (
109
+ <Swiper
110
+ onSwiper={setSwiperInstance}
111
+ effect={'creative'}
112
+ grabCursor={false}
113
+ centeredSlides={true}
114
+ slidesPerView={1}
115
+ loop={folderThumbnails.length > 2}
116
+ allowTouchMove={false}
117
+ speed={600}
118
+ creativeEffect={{
119
+ limitProgress: 2,
120
+ prev: {
121
+ shadow: true,
122
+ translate: ['-65%', 0, -300],
123
+ rotate: [0, 45, 0],
124
+ },
125
+ next: {
126
+ shadow: true,
127
+ translate: ['65%', 0, -300],
128
+ rotate: [0, -45, 0],
129
+ },
130
+ }}
131
+ modules={[EffectCreative]}
132
+ className="w-full h-full flex items-center justify-center overflow-visible"
133
+ >
134
+ {folderThumbnails.map((thumb, index) => (
135
+ <SwiperSlide key={thumb + index} style={{ width: '100%', height: '100%' }} className="flex items-center justify-center overflow-visible">
136
+ {({ isActive }) => (
137
+ <div className={`w-full h-full transition-transform duration-[400ms] ease-in-out origin-center rounded-lg overflow-hidden shadow-2xl border-2 border-white/5 ${isActive && isZoomedIn ? 'scale-100' : 'scale-[0.80]'}`}>
138
+ <ImageLoader
139
+ src={getThumbnailUrl(thumb) || ''}
140
+ alt="Folder Cover"
141
+ aspectRatio="2/3"
142
+ objectFit="cover"
143
+ className="w-full h-full"
144
+ />
145
+ </div>
146
+ )}
147
+ </SwiperSlide>
148
+ ))}
149
+ </Swiper>
150
+ ) : folderThumbnails.length === 2 ? (
151
+ folderThumbnails.map((thumb, index) => (
152
+ <div
153
+ key={thumb + index}
154
+ className={`absolute inset-0 w-full h-full transition-all duration-[600ms] ease-out ${index === currentThumbIndex ? 'opacity-100 scale-100 blur-0 z-10' : 'opacity-0 scale-110 blur-md z-0'} pointer-events-none`}
155
+ >
156
+ <ImageLoader
157
+ src={getThumbnailUrl(thumb) || ''}
158
+ alt="Folder Cover"
159
+ aspectRatio="2/3"
160
+ objectFit="cover"
161
+ className="w-full h-full"
162
+ imgClassName="opacity-70"
163
+ />
164
+ </div>
165
+ ))
166
+ ) : (
167
+ <ImageLoader
168
+ src={getThumbnailUrl(folderThumbnails[0]) || ''}
169
+ alt="Folder Cover"
170
+ aspectRatio="2/3"
171
+ objectFit="cover"
172
+ className="w-full h-full"
173
+ imgClassName="transition-transform duration-700 group-hover:scale-110 opacity-70"
174
+ />
175
+ )}
176
  </div>
177
  <div className="absolute inset-x-0 bottom-0 h-1/2 bg-gradient-to-t from-black/90 to-transparent pointer-events-none"></div>
178
 
src/components/SearchResults.tsx CHANGED
@@ -30,32 +30,76 @@ interface SearchResultsProps {
30
 
31
  const ITEMS_PER_PAGE = 24;
32
 
33
- function getFolderThumbnails(folderId: string, mangas: Manga[], limit = 4, visited = new Set<string>()): string[] {
34
  if (visited.has(folderId)) return [];
35
  visited.add(folderId);
36
 
37
  const children = mangas.filter(m => m.folder_id === folderId);
38
- const thumbnails: string[] = [];
39
-
40
  for (const child of children) {
41
- if (thumbnails.length >= limit) break;
42
-
43
- if (child.thumbnail_url) {
44
- if (!thumbnails.includes(child.thumbnail_url)) {
45
- thumbnails.push(child.thumbnail_url);
 
 
 
46
  }
47
- } else if (child.is_folder) {
48
- const childThumbnails = getFolderThumbnails(child.id, mangas, limit - thumbnails.length, visited);
49
- for (const t of childThumbnails) {
50
- if (thumbnails.length >= limit) break;
51
- if (!thumbnails.includes(t)) {
52
- thumbnails.push(t);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
  }
55
  }
 
56
  }
57
 
58
- return thumbnails;
59
  }
60
 
61
  export function SearchResults({
 
30
 
31
  const ITEMS_PER_PAGE = 24;
32
 
33
+ function getAllFolderThumbnails(folderId: string, mangas: Manga[], visited = new Set<string>()): string[] {
34
  if (visited.has(folderId)) return [];
35
  visited.add(folderId);
36
 
37
  const children = mangas.filter(m => m.folder_id === folderId);
38
+ const result: string[] = [];
39
+
40
  for (const child of children) {
41
+ const image = child.thumbnail_url || child.cover_url;
42
+ if (image && !result.includes(image)) {
43
+ result.push(image);
44
+ }
45
+ if (child.is_folder) {
46
+ const childThumbs = getAllFolderThumbnails(child.id, mangas, visited);
47
+ for (const t of childThumbs) {
48
+ if (!result.includes(t)) result.push(t);
49
  }
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+
55
+ function getFolderThumbnails(folderId: string, mangas: Manga[], limit = 12): string[] {
56
+ const children = mangas.filter(m => m.folder_id === folderId);
57
+ const subFolders = children.filter(m => m.is_folder);
58
+ const directMangas = children.filter(m => !m.is_folder && (m.thumbnail_url || m.cover_url));
59
+
60
+ // Solo aplica ruleta si hay subcarpetas (según requerimiento)
61
+ if (subFolders.length === 0) {
62
+ if (directMangas.length > 0) {
63
+ const img = directMangas[0].thumbnail_url || directMangas[0].cover_url;
64
+ return img ? [img] : [];
65
+ }
66
+ return [];
67
+ }
68
+
69
+ // Recolectar todas las secuencias de miniaturas por cada subcarpeta
70
+ const subfolderThumbnails: string[][] = [];
71
+ for (const sf of subFolders) {
72
+ const sfThumbs = getAllFolderThumbnails(sf.id, mangas, new Set());
73
+ if (sfThumbs.length > 0) {
74
+ subfolderThumbnails.push(sfThumbs);
75
+ }
76
+ }
77
+
78
+ if (directMangas.length > 0) {
79
+ const directThumbs = directMangas.map(m => m.thumbnail_url || m.cover_url).filter(Boolean) as string[];
80
+ if (directThumbs.length > 0) subfolderThumbnails.push(directThumbs);
81
+ }
82
+
83
+ // Intercalar (1 de A, 1 de B, 1 de C, 2 de A, 2 de B...)
84
+ const result: string[] = [];
85
+ let added = true;
86
+ let index = 0;
87
+
88
+ while (added && result.length < limit) {
89
+ added = false;
90
+ for (const sfThumbs of subfolderThumbnails) {
91
+ if (result.length >= limit) break;
92
+ if (index < sfThumbs.length) {
93
+ if (!result.includes(sfThumbs[index])) {
94
+ result.push(sfThumbs[index]);
95
+ added = true;
96
  }
97
  }
98
  }
99
+ index++;
100
  }
101
 
102
+ return result;
103
  }
104
 
105
  export function SearchResults({