From 140b8a47bf25687e02d9df64e69c33926ecf30fc Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:30:52 +0700 Subject: [PATCH] wip: ui --- src-tauri/tauri.windows.conf.json | 2 +- src/app/space/components/toggle.tsx | 2 +- src/app/space/components/widgetList.tsx | 2 +- src/app/space/index.tsx | 19 +++--- src/shared/accounts/active.tsx | 34 +++------- src/shared/composer/modal.tsx | 5 +- src/shared/layouts/app.tsx | 2 +- src/shared/navigation.tsx | 87 ++++++++----------------- src/shared/notes/child.tsx | 6 +- src/shared/notes/kinds/file.tsx | 8 +-- src/shared/notes/kinds/unknown.tsx | 14 ++-- src/shared/notes/preview/link.tsx | 12 ++-- src/shared/notes/preview/video.tsx | 8 +-- src/shared/notes/stats.tsx | 34 +++++----- src/shared/titleBar.tsx | 9 ++- src/shared/user.tsx | 14 ++-- src/shared/widgets/local/thread.tsx | 6 +- src/shared/widgets/local/user.tsx | 7 +- src/shared/widgets/wrapper.tsx | 5 +- 19 files changed, 105 insertions(+), 171 deletions(-) diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index 8915cc8a..554c9651 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -27,7 +27,7 @@ "fileDropEnabled": true, "transparent": true, "windowEffects": { - "effects": ["mica"] + "effects": ["micaLight", "micaDark"] } } ] diff --git a/src/app/space/components/toggle.tsx b/src/app/space/components/toggle.tsx index 9f5c12bf..40ec8a19 100644 --- a/src/app/space/components/toggle.tsx +++ b/src/app/space/components/toggle.tsx @@ -9,7 +9,7 @@ export function ToggleWidgetList() { const setWidget = useWidgets((state) => state.setWidget); return ( -
+
diff --git a/src/app/space/components/widgetList.tsx b/src/app/space/components/widgetList.tsx index d502ff10..b8ee0b28 100644 --- a/src/app/space/components/widgetList.tsx +++ b/src/app/space/components/widgetList.tsx @@ -101,7 +101,7 @@ export function WidgetList({ params }: { params: Widget }) { ); return ( -
+
diff --git a/src/app/space/index.tsx b/src/app/space/index.tsx index a1318fd4..4280494b 100644 --- a/src/app/space/index.tsx +++ b/src/app/space/index.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect } from 'react'; +import { VList } from 'virtua'; import { ToggleWidgetList } from '@app/space/components/toggle'; import { WidgetList } from '@app/space/components/widgetList'; @@ -84,17 +85,17 @@ export function SpaceScreen() { }, [fetchWidgets]); return ( -
- {!widgets ? ( -
-
+
+ + {!widgets ? ( +
-
- ) : ( - widgets.map((widget) => renderItem(widget)) - )} - + ) : ( + widgets.map((widget) => renderItem(widget)) + )} + +
); } diff --git a/src/shared/accounts/active.tsx b/src/shared/accounts/active.tsx index 89fa8294..649e6598 100644 --- a/src/shared/accounts/active.tsx +++ b/src/shared/accounts/active.tsx @@ -4,16 +4,14 @@ import { Link } from 'react-router-dom'; import { useStorage } from '@libs/storage/provider'; -import { SettingsIcon } from '@shared/icons'; +import { HorizontalDotsIcon } from '@shared/icons'; import { Image } from '@shared/image'; -import { Logout } from '@shared/logout'; import { useActivities } from '@stores/activities'; import { useNostr } from '@utils/hooks/useNostr'; import { useProfile } from '@utils/hooks/useProfile'; import { sendNativeNotification } from '@utils/notification'; -import { displayNpub } from '@utils/shortenKey'; export function ActiveAccount() { const { db } = useStorage(); @@ -52,38 +50,22 @@ export function ActiveAccount() { if (status === 'loading') { return ( -
-
-
-
+
); } return ( -
- +
+ {db.account.npub} -
-
- {user?.name || user?.display_name || user?.displayName} -
-
- {user?.nip05 || displayNpub(db.account.pubkey, 12)} -
-
+ -
- - - - +
+
); diff --git a/src/shared/composer/modal.tsx b/src/shared/composer/modal.tsx index be1d78c1..3ef097d2 100644 --- a/src/shared/composer/modal.tsx +++ b/src/shared/composer/modal.tsx @@ -28,10 +28,9 @@ export function ComposerModal() { diff --git a/src/shared/layouts/app.tsx b/src/shared/layouts/app.tsx index dc9918a2..a20e45ce 100644 --- a/src/shared/layouts/app.tsx +++ b/src/shared/layouts/app.tsx @@ -5,7 +5,7 @@ import { Navigation } from '@shared/navigation'; export function AppLayout() { return ( -
+
diff --git a/src/shared/navigation.tsx b/src/shared/navigation.tsx index c545783f..ad88d6e5 100644 --- a/src/shared/navigation.tsx +++ b/src/shared/navigation.tsx @@ -1,13 +1,9 @@ -import { NavLink, useNavigate } from 'react-router-dom'; +import { NavLink } from 'react-router-dom'; import { twMerge } from 'tailwind-merge'; -import { useStorage } from '@libs/storage/provider'; - import { ActiveAccount } from '@shared/accounts/active'; import { ComposerModal } from '@shared/composer'; import { - ArrowLeftIcon, - ArrowRightIcon, ChatsIcon, CommunityIcon, ExploreIcon, @@ -18,148 +14,117 @@ import { export function Navigation() { return (
-
+
{({ isActive }) => ( <>
- -
{' '} -
- Home +
+
Home
)}
{({ isActive }) => ( <>
- -
{' '} -
- Chats +
+
Chats
)}
{({ isActive }) => ( <>
- -
{' '} -
- Groups +
+
Groups
)}
{({ isActive }) => ( <>
- -
{' '} -
- Relays +
+
Relays
)}
{({ isActive }) => ( <>
- -
{' '} -
- Explore +
+
Explore
)}
+
+ + +
); } diff --git a/src/shared/notes/child.tsx b/src/shared/notes/child.tsx index 9800d5ed..b1ae0adb 100644 --- a/src/shared/notes/child.tsx +++ b/src/shared/notes/child.tsx @@ -34,7 +34,7 @@ export function ChildNote({ id, root }: { id: string; root?: string }) { if (status === 'loading') { return ( <> -
+
@@ -46,7 +46,7 @@ export function ChildNote({ id, root }: { id: string; root?: string }) { const noteLink = `https://njump.me/${nip19.noteEncode(id)}`; return ( <> -
+
@@ -78,7 +78,7 @@ export function ChildNote({ id, root }: { id: string; root?: string }) { return ( <> -
+
diff --git a/src/shared/notes/kinds/file.tsx b/src/shared/notes/kinds/file.tsx index 866ae0cf..337e83cc 100644 --- a/src/shared/notes/kinds/file.tsx +++ b/src/shared/notes/kinds/file.tsx @@ -40,13 +40,7 @@ export function FileNote(props: { event?: NDKEvent }) { crossorigin="" className="player" > - - - + -
- - Unknown kind: {props.event.kind} +
+
+ + Kind: {props.event.kind} -

- Lume isn't fully support this kind +

+ Unsupport kind on newsfeed

-
+

{props.event.content.toString()}

diff --git a/src/shared/notes/preview/link.tsx b/src/shared/notes/preview/link.tsx index 48183240..98fb4348 100644 --- a/src/shared/notes/preview/link.tsx +++ b/src/shared/notes/preview/link.tsx @@ -31,7 +31,9 @@ export function LinkPreview({ urls }: { urls: string[] }) {

Can't fetch open graph, click to open webpage

- {domain.hostname} + + {domain.hostname} +
) : ( <> @@ -46,15 +48,17 @@ export function LinkPreview({ urls }: { urls: string[] }) { /> )}
-
+
{data.title}
{data.description && ( -

+

{data.description}

)} - {domain.hostname} + + {domain.hostname} +
)} diff --git a/src/shared/notes/preview/video.tsx b/src/shared/notes/preview/video.tsx index 4e9312b4..ee4ed266 100644 --- a/src/shared/notes/preview/video.tsx +++ b/src/shared/notes/preview/video.tsx @@ -18,13 +18,7 @@ export function VideoPreview({ urls }: { urls: string[] }) { muted={true} className="player" > - - - + -

- +

+
+
{compactNumber.format(data.reactions)} - {' '} - reactions -

- · -

- +

+
Reactions
+
+
+
{compactNumber.format(data.reposts)} - {' '} - reposts -

- · -

- +

+
Reposts
+
+
+
{compactNumber.format(data.zaps)} - {' '} - zaps -

+
+
Zaps
+
); } diff --git a/src/shared/titleBar.tsx b/src/shared/titleBar.tsx index 885c0688..b78495af 100644 --- a/src/shared/titleBar.tsx +++ b/src/shared/titleBar.tsx @@ -9,12 +9,11 @@ export function TitleBar({ id, title }: { id?: string; title: string }) { const remove = useWidgets((state) => state.removeWidget); return ( -
+
-

{title}

+

+ {title} +

{id ? (