From 8b1c2ebe3ff132d7abd8e4c7aad46c56684b7a6c Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 27 Aug 2025 21:56:46 +0800 Subject: [PATCH] feat: update layout --- index.html | 2 +- src/PageManager.tsx | 61 +----- src/components/BottomNavigationBar/index.tsx | 2 +- src/components/KindFilter/index.tsx | 4 +- src/components/NewNotesButton/index.tsx | 22 +- src/components/NoteList/index.tsx | 4 +- src/components/ProfileList/index.tsx | 2 +- src/components/Sidebar/SidebarItem.tsx | 4 +- src/components/Sidebar/index.tsx | 2 +- src/components/Tabs/index.tsx | 2 +- src/components/Titlebar/index.tsx | 5 +- src/index.css | 22 +- src/layouts/PrimaryPageLayout/index.tsx | 26 ++- src/layouts/SecondaryPageLayout/index.tsx | 17 +- src/pages/primary/MePage/index.tsx | 14 +- src/pages/primary/NoteListPage/FeedButton.tsx | 6 +- src/pages/primary/NoteListPage/index.tsx | 2 +- .../secondary/GeneralSettingsPage/index.tsx | 2 +- src/pages/secondary/HomePage/index.tsx | 5 +- src/pages/secondary/LoadingPage/index.tsx | 14 -- src/pages/secondary/NotePage/index.tsx | 14 +- .../OthersRelaySettingsPage/index.tsx | 2 +- .../secondary/PostSettingsPage/index.tsx | 2 +- .../secondary/ProfileEditorPage/index.tsx | 206 +++++++++--------- src/pages/secondary/ProfilePage/index.tsx | 28 +-- src/pages/secondary/RelayPage/index.tsx | 1 + .../secondary/RelaySettingsPage/index.tsx | 2 +- src/pages/secondary/TranslationPage/index.tsx | 2 +- src/pages/secondary/WalletPage/index.tsx | 2 +- tailwind.config.js | 3 + 30 files changed, 230 insertions(+), 250 deletions(-) delete mode 100644 src/pages/secondary/LoadingPage/index.tsx diff --git a/index.html b/index.html index 962bd40..2873956 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@ - + diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 1926ace..c7a0c23 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -1,5 +1,4 @@ import Sidebar from '@/components/Sidebar' -import { Separator } from '@/components/ui/separator' import { cn } from '@/lib/utils' import NoteListPage from '@/pages/primary/NoteListPage' import HomePage from '@/pages/secondary/HomePage' @@ -15,6 +14,7 @@ import { useRef, useState } from 'react' +import BottomNavigationBar from './components/BottomNavigationBar' import TooManyRelaysAlertDialog from './components/TooManyRelaysAlertDialog' import ExplorePage from './pages/primary/ExplorePage' import MePage from './pages/primary/MePage' @@ -90,12 +90,10 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { } ]) const [secondaryStack, setSecondaryStack] = useState([]) - const [isShared, setIsShared] = useState(false) const { isSmallScreen } = useScreenSize() const ignorePopStateRef = useRef(false) useEffect(() => { - const hasHistoryState = !!history.state if (['/npub1', '/nprofile1'].some((prefix) => window.location.pathname.startsWith(prefix))) { window.history.replaceState( null, @@ -115,12 +113,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { } window.history.pushState(null, '', window.location.href) if (window.location.pathname !== '/') { - if ( - ['/users', '/notes', '/relays'].some((path) => window.location.pathname.startsWith(path)) && - !hasHistoryState - ) { - setIsShared(true) - } const url = window.location.pathname + window.location.search + window.location.hash setSecondaryStack((prevStack) => { if (isCurrentPage(prevStack, url)) return prevStack @@ -248,7 +240,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { if (secondaryStack.length === 1) { // back to home page window.history.replaceState(null, '', '/') - setIsShared(false) setSecondaryStack([]) } else { window.history.go(-1) @@ -301,6 +292,7 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { {element} ))} + @@ -308,39 +300,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { ) } - if (isShared && secondaryStack.length > 0) { - return ( - - - -
- {secondaryStack.map((item, index) => ( -
- {item.component} -
- ))} -
-
-
-
- ) - } - return ( -
+
- -
-
+
+
{primaryPages.map(({ name, element }) => (
))}
-
+
{secondaryStack.map((item, index) => (
{item.component}
))} -
+
diff --git a/src/components/BottomNavigationBar/index.tsx b/src/components/BottomNavigationBar/index.tsx index 668f073..574721b 100644 --- a/src/components/BottomNavigationBar/index.tsx +++ b/src/components/BottomNavigationBar/index.tsx @@ -8,7 +8,7 @@ export default function BottomNavigationBar() { return (
{ console.log(checked) @@ -166,7 +166,7 @@ export default function KindFilter({ return ( {trigger} - + {content} diff --git a/src/components/NewNotesButton/index.tsx b/src/components/NewNotesButton/index.tsx index 359c1a0..a782d5e 100644 --- a/src/components/NewNotesButton/index.tsx +++ b/src/components/NewNotesButton/index.tsx @@ -2,6 +2,7 @@ import { Button } from '@/components/ui/button' import { SimpleUserAvatar } from '@/components/UserAvatar' import { cn } from '@/lib/utils' import { useScreenSize } from '@/providers/ScreenSizeProvider' +import { ArrowUp } from 'lucide-react' import { Event } from 'nostr-tools' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' @@ -32,34 +33,25 @@ export default function NewNotesButton({
)} diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index e1c0a8c..a4bbc68 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -209,7 +209,7 @@ const NoteList = forwardRef( setEvents((oldEvents) => [...newEvents, ...oldEvents]) setNewEvents([]) setTimeout(() => { - scrollToTop() + scrollToTop('smooth') }, 0) } @@ -218,7 +218,7 @@ const NoteList = forwardRef( {filteredNewEvents.length > 0 && ( )} -
+
{ setRefreshCount((count) => count + 1) diff --git a/src/components/ProfileList/index.tsx b/src/components/ProfileList/index.tsx index f46e7b4..2d28889 100644 --- a/src/components/ProfileList/index.tsx +++ b/src/components/ProfileList/index.tsx @@ -35,7 +35,7 @@ export default function ProfileList({ pubkeys }: { pubkeys: string[] }) { }, [visiblePubkeys, pubkeys]) return ( -
+
{visiblePubkeys.map((pubkey, index) => ( ))} diff --git a/src/components/Sidebar/SidebarItem.tsx b/src/components/Sidebar/SidebarItem.tsx index 9aca743..aff2d7a 100644 --- a/src/components/Sidebar/SidebarItem.tsx +++ b/src/components/Sidebar/SidebarItem.tsx @@ -12,8 +12,8 @@ const SidebarItem = forwardRef< return (