diff --git a/src/components/ImageCarousel/index.tsx b/src/components/ImageCarousel/index.tsx index b891e281..40d77471 100644 --- a/src/components/ImageCarousel/index.tsx +++ b/src/components/ImageCarousel/index.tsx @@ -1,5 +1,7 @@ import { Carousel, CarouselApi, CarouselContent, CarouselItem } from '@/components/ui/carousel' +import { isTouchDevice } from '@/lib/common' import { TImageInfo } from '@/types' +import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react' import { useEffect, useState } from 'react' import Lightbox from 'yet-another-react-lightbox' import Zoom from 'yet-another-react-lightbox/plugins/zoom' @@ -40,16 +42,23 @@ export function ImageCarousel({ } return ( - <> +
- + {images.map((image, index) => ( - - handlePhotoClick(e, index)} /> + + handlePhotoClick(e, index)} + /> ))} + {!isTouchDevice() && ( + + )} {images.length > 1 && ( )} @@ -67,7 +76,7 @@ export function ImageCarousel({ styles={{ toolbar: { paddingTop: '2.25rem' } }} /> {isNsfw && } - +
) } @@ -85,10 +94,41 @@ function CarouselDot({ {Array.from({ length: total }).map((_, index) => (
onClick(index)} /> ))}
) } + +function ArrowButton({ + total, + currentIndex, + onClick +}: { + total: number + currentIndex: number + onClick: (index: number) => void +}) { + return ( +
+
+ + +
+
+ ) +} diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 71455f6b..a83035e4 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -30,7 +30,7 @@ export default function NoteList({ className?: string }) { const { t } = useTranslation() - const { isSmallScreen } = useScreenSize() + const { isLargeScreen } = useScreenSize() const { signEvent, checkLogin } = useNostr() const { areAlgoRelays } = useFetchRelayInfos([...relayUrls]) const [refreshCount, setRefreshCount] = useState(0) @@ -180,7 +180,7 @@ export default function NoteList({ {isPictures ? ( ) : ( @@ -268,7 +268,7 @@ function PictureNoteCardMasonry({ ) }) return newColumns - }, [events]) + }, [events, columnCount]) return (
0 +} diff --git a/src/pages/secondary/NotePage/index.tsx b/src/pages/secondary/NotePage/index.tsx index 34ff444d..03904d5f 100644 --- a/src/pages/secondary/NotePage/index.tsx +++ b/src/pages/secondary/NotePage/index.tsx @@ -12,14 +12,12 @@ import { useFetchEvent } from '@/hooks' import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' import { getParentEventId, getRootEventId, isPictureEvent } from '@/lib/event' import { toNote } from '@/lib/link' -import { useScreenSize } from '@/providers/ScreenSizeProvider' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import NotFoundPage from '../NotFoundPage' export default function NotePage({ id, index }: { id?: string; index?: number }) { const { t } = useTranslation() - const { isSmallScreen } = useScreenSize() const { event, isFetching } = useFetchEvent(id) const parentEventId = useMemo(() => getParentEventId(event), [event]) const rootEventId = useMemo(() => getRootEventId(event), [event]) @@ -35,7 +33,7 @@ export default function NotePage({ id, index }: { id?: string; index?: number }) } if (!event) return - if (isPictureEvent(event) && isSmallScreen) { + if (isPictureEvent(event)) { return ( diff --git a/src/providers/ScreenSizeProvider.tsx b/src/providers/ScreenSizeProvider.tsx index 6ae9a27d..034c6008 100644 --- a/src/providers/ScreenSizeProvider.tsx +++ b/src/providers/ScreenSizeProvider.tsx @@ -5,6 +5,7 @@ type TScreenSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' type TScreenSizeContext = { screenSize: TScreenSize isSmallScreen: boolean + isLargeScreen: boolean } const ScreenSizeContext = createContext(undefined) @@ -20,6 +21,7 @@ export const useScreenSize = () => { export function ScreenSizeProvider({ children }: { children: React.ReactNode }) { const [screenSize, setScreenSize] = useState('sm') const isSmallScreen = useMemo(() => screenSize === 'sm', [screenSize]) + const isLargeScreen = useMemo(() => ['2xl'].includes(screenSize), [screenSize]) useEffect(() => { const handleResize = () => { @@ -47,7 +49,8 @@ export function ScreenSizeProvider({ children }: { children: React.ReactNode }) {children}