From 3e609f72360d57ff4244c543c9bdf227036a8b76 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 8 Jan 2025 00:16:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/NoteList/index.tsx | 45 +++++++++++++++++++--- src/components/SimpleMasonryGrid/index.tsx | 36 ----------------- 2 files changed, 39 insertions(+), 42 deletions(-) delete mode 100644 src/components/SimpleMasonryGrid/index.tsx diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 16549e3f..c1b77ffa 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -8,12 +8,11 @@ import { useScreenSize } from '@/providers/ScreenSizeProvider' import client from '@/services/client.service' import dayjs from 'dayjs' import { Event, Filter, kinds } from 'nostr-tools' -import { useEffect, useMemo, useRef, useState } from 'react' +import { ReactNode, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import PullToRefresh from 'react-simple-pull-to-refresh' import NoteCard from '../NoteCard' import PictureNoteCard from '../PictureNoteCard' -import SimpleMasonryGrid from '../SimpleMasonryGrid' const NORMAL_RELAY_LIMIT = 100 const ALGO_RELAY_LIMIT = 500 @@ -185,12 +184,10 @@ export default function NoteList({ )} {isPictures ? ( - ( - - ))} + events={events} /> ) : (
@@ -259,3 +256,39 @@ function ListModeSwitch({
) } + +function PictureNoteCardMasonry({ + events, + columnCount, + className +}: { + events: Event[] + columnCount: 2 | 3 + className?: string +}) { + const columns = useMemo(() => { + const newColumns: ReactNode[][] = Array.from({ length: columnCount }, () => []) + events.forEach((event, i) => { + newColumns[i % columnCount].push( + + ) + }) + return newColumns + }, [events]) + + return ( +
+ {columns.map((column, i) => ( +
+ {column} +
+ ))} +
+ ) +} diff --git a/src/components/SimpleMasonryGrid/index.tsx b/src/components/SimpleMasonryGrid/index.tsx deleted file mode 100644 index ac1419f6..00000000 --- a/src/components/SimpleMasonryGrid/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { cn } from '@/lib/utils' -import { useMemo, ReactNode } from 'react' - -export default function SimpleMasonryGrid({ - items, - columnCount, - className -}: { - items: ReactNode[] - columnCount: 2 | 3 - className?: string -}) { - const columns = useMemo(() => { - const newColumns: ReactNode[][] = Array.from({ length: columnCount }, () => []) - items.forEach((item, i) => { - newColumns[i % columnCount].push(item) - }) - return newColumns - }, [items]) - - return ( -
- {columns.map((column, i) => ( -
- {column} -
- ))} -
- ) -}