-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed
BIN
+381 KB
apps/desktop/public/columns/[email protected] → ...ktop/public/columns/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Column, useColumnContext } from "@lume/ark"; | ||
import { ColumnIcon } from "@lume/icons"; | ||
import { IColumn } from "@lume/types"; | ||
import { COL_TYPES } from "@lume/utils"; | ||
|
||
|
@@ -8,11 +7,7 @@ export function Default({ column }: { column: IColumn }) { | |
|
||
return ( | ||
<Column.Root> | ||
<Column.Header | ||
id={column.id} | ||
title="Add columns" | ||
icon={<ColumnIcon className="size-4" />} | ||
/> | ||
<Column.Header id={column.id} title="Add columns" /> | ||
<div className="h-full px-3 mt-3 flex flex-col gap-3 overflow-y-auto scrollbar-none"> | ||
<div className="h-11 flex items-center gap-5"> | ||
<button | ||
|
@@ -87,6 +82,39 @@ export function Default({ column }: { column: IColumn }) { | |
</button> | ||
</div> | ||
</div> | ||
<div className="flex flex-col rounded-xl overflow-hidden bg-neutral-50 dark:bg-neutral-950 ring-1 ring-neutral-100 dark:ring-neutral-900"> | ||
<div className="h-[100px] w-full px-3 pt-3"> | ||
<img | ||
src="/columns/trending-notes.jpg" | ||
srcSet="/columns/[email protected] 2x" | ||
alt="trendingNotes" | ||
loading="lazy" | ||
decoding="async" | ||
className="w-full h-auto object-cover rounded-lg" | ||
/> | ||
</div> | ||
<div className="h-16 shrink-0 px-3 flex items-center justify-between"> | ||
<div> | ||
<h1 className="font-semibold">Trending Notes</h1> | ||
<p className="max-w-[18rem] truncate text-sm text-neutral-600 dark:text-neutral-500"> | ||
What is trending on Nostr? | ||
</p> | ||
</div> | ||
<button | ||
type="button" | ||
onClick={() => { | ||
addColumn({ | ||
kind: COL_TYPES.trendingNotes, | ||
title: "", | ||
content: "", | ||
}); | ||
}} | ||
className="shrink-0 w-16 h-8 rounded-lg text-sm font-semibold bg-neutral-100 dark:bg-neutral-900 text-blue-500 hover:bg-neutral-200 dark:hover:bg-neutral-800 inline-flex items-center justify-center" | ||
> | ||
Add | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</Column.Root> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@columns/trending-notes", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "./src/index.tsx", | ||
"dependencies": { | ||
"@lume/ark": "workspace:^", | ||
"@lume/icons": "workspace:^", | ||
"@lume/ui": "workspace:^", | ||
"@lume/utils": "workspace:^", | ||
"@nostr-dev-kit/ndk": "^2.3.3", | ||
"@tanstack/react-query": "^5.17.19", | ||
"react": "^18.2.0", | ||
"react-router-dom": "^6.21.3", | ||
"sonner": "^1.3.1", | ||
"virtua": "^0.21.1" | ||
}, | ||
"devDependencies": { | ||
"@lume/tailwindcss": "workspace:^", | ||
"@lume/tsconfig": "workspace:^", | ||
"@lume/types": "workspace:^", | ||
"@types/react": "^18.2.48", | ||
"tailwind": "^4.0.0", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { TextNote, useArk } from "@lume/ark"; | ||
import { LoaderIcon } from "@lume/icons"; | ||
import { type NDKEvent, type NostrEvent } from "@nostr-dev-kit/ndk"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { fetch } from "@tauri-apps/plugin-http"; | ||
import { useEffect, useMemo, useRef } from "react"; | ||
import { CacheSnapshot, VList, VListHandle } from "virtua"; | ||
|
||
export function HomeRoute({ colKey }: { colKey: string }) { | ||
const ark = useArk(); | ||
const ref = useRef<VListHandle>(); | ||
const cacheKey = `${colKey}-vlist`; | ||
|
||
const [offset, cache] = useMemo(() => { | ||
const serialized = sessionStorage.getItem(cacheKey); | ||
if (!serialized) return []; | ||
return JSON.parse(serialized) as [number, CacheSnapshot]; | ||
}, []); | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: [colKey], | ||
queryFn: async ({ signal }: { signal: AbortSignal }) => { | ||
const res = await fetch("https://api.nostr.band/v0/trending/notes", { | ||
signal, | ||
}); | ||
|
||
if (!res) throw new Error("Failed to fetch trending notes"); | ||
|
||
const data = await res.json(); | ||
const events = data.notes.map((item: { event: NostrEvent }) => | ||
ark.getNDKEvent(item.event), | ||
); | ||
|
||
return events as NDKEvent[]; | ||
}, | ||
refetchOnMount: false, | ||
refetchOnWindowFocus: false, | ||
}); | ||
|
||
useEffect(() => { | ||
if (!ref.current) return; | ||
const handle = ref.current; | ||
|
||
if (offset) { | ||
handle.scrollTo(offset); | ||
} | ||
|
||
return () => { | ||
sessionStorage.setItem( | ||
cacheKey, | ||
JSON.stringify([handle.scrollOffset, handle.cache]), | ||
); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="w-full h-full"> | ||
<VList ref={ref} cache={cache} overscan={2} className="flex-1 px-3"> | ||
{isLoading ? ( | ||
<div className="w-full flex h-16 items-center justify-center gap-2 px-3 py-1.5"> | ||
<LoaderIcon className="size-5 animate-spin" /> | ||
</div> | ||
) : ( | ||
data.map((item) => ( | ||
<TextNote key={item.id} event={item} className="mt-3" /> | ||
)) | ||
)} | ||
</VList> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Column } from "@lume/ark"; | ||
import { IColumn } from "@lume/types"; | ||
import { EventRoute, UserRoute } from "@lume/ui"; | ||
import { HomeRoute } from "./home"; | ||
|
||
export function TrendingNotes({ column }: { column: IColumn }) { | ||
const colKey = `trending-notes-${column.id}`; | ||
|
||
return ( | ||
<Column.Root> | ||
<Column.Header | ||
id={column.id} | ||
queryKey={[colKey]} | ||
title="Trending Notes" | ||
/> | ||
<Column.Content> | ||
<Column.Route path="/" element={<HomeRoute colKey={colKey} />} /> | ||
<Column.Route path="/events/:id" element={<EventRoute />} /> | ||
<Column.Route path="/users/:id" element={<UserRoute />} /> | ||
</Column.Content> | ||
</Column.Root> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import sharedConfig from "@lume/tailwindcss"; | ||
|
||
const config = { | ||
content: ["./src/**/*.{js,ts,jsx,tsx}"], | ||
presets: [sharedConfig], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@lume/tsconfig/base.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.