Fluidité et ménage
- Catalogue : grille affichée par tranches de 60 au fil du défilement (sans revenir en haut quand une fiche change), images décodées en arrière-plan, avatars chargés à la demande - Réglage « couleur d'accent » retiré des réglages, de la synchro et des sauvegardes (n'existait plus) - CLAUDE.md à jour (adresse du site, état au 28 nov.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
8 files changed
+31
-18
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { genreLabel, subtypeLabel } from '../lib/genres'
|
||||
import { locale, t } from '../i18n'
|
||||
import { CheckSquare, Hash, Heart, Search, SlidersHorizontal, X } from 'lucide-react'
|
||||
import { useDeferredValue, useEffect, useMemo, useState } from 'react'
|
||||
import { useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { StatusDot } from '../components/Badges'
|
||||
import JournalView from '../components/JournalView'
|
||||
import ListsView from '../components/ListsView'
|
||||
@@ -31,6 +31,8 @@ interface Props {
|
||||
onAdd: () => void
|
||||
}
|
||||
|
||||
const GRID_STEP = 60
|
||||
|
||||
export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
const { items, lists } = useMedia()
|
||||
const [view, setView] = useState<'titles' | 'journal' | 'lists'>('titles')
|
||||
@@ -120,6 +122,18 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
}
|
||||
|
||||
// Fiches sélectionnées encore présentes (une fiche a pu être supprimée entre-temps)
|
||||
// Grille affichée par tranches : une grande bibliothèque ne dessine pas des centaines de cartes d'un coup
|
||||
const [gridCount, setGridCount] = useState(GRID_STEP)
|
||||
// Retour au début seulement quand la recherche ou les filtres changent (pas quand une fiche bouge : +1, note…)
|
||||
useEffect(() => setGridCount(GRID_STEP), [deferredQuery, types, status, genre, minRating, favOnly, tag, sort])
|
||||
const more = useRef<HTMLDivElement>(null)
|
||||
useEffect(() => {
|
||||
const el = more.current
|
||||
if (!el || gridCount >= results.length) return
|
||||
const io = new IntersectionObserver((e) => e[0]?.isIntersecting && setGridCount((n) => n + GRID_STEP), { rootMargin: '1200px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [gridCount, results.length])
|
||||
const selected = useMemo(() => (selection ? items.filter((i) => selection.has(i.id)) : []), [items, selection])
|
||||
const allShownSelected = selecting && results.length > 0 && results.every((i) => selection.has(i.id))
|
||||
|
||||
@@ -314,7 +328,7 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
/>
|
||||
) : (
|
||||
<div className="mt-3 grid grid-cols-2 gap-x-3.5 gap-y-6 sm:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-8">
|
||||
{results.map((item) => (
|
||||
{results.slice(0, gridCount).map((item) => (
|
||||
<SelectableCard
|
||||
key={item.id}
|
||||
title={item.title}
|
||||
@@ -328,6 +342,7 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{gridCount < results.length && <div ref={more} className="h-px" aria-hidden="true" />}
|
||||
{selecting && <SelectionBar selected={selected} onDone={exitSelection} />}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user