mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-09 04:18:05 +02:00
Clean up navigation menu
This commit is contained in:
parent
1e75dbd67a
commit
b7deb163fd
5
.changeset/smooth-kings-retire.md
Normal file
5
.changeset/smooth-kings-retire.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"nostrudel": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Clean up navigation menu
|
@ -1,29 +1,17 @@
|
|||||||
import { SettingsIcon } from "@chakra-ui/icons";
|
import { Avatar, Button, Flex, FlexProps, Heading, IconButton, LinkOverlay, Text } from "@chakra-ui/react";
|
||||||
import { Avatar, Button, Flex, FlexProps, Heading, IconButton, LinkOverlay, Text, VStack } from "@chakra-ui/react";
|
import { Link as RouterLink } from "react-router-dom";
|
||||||
import { Link as RouterLink, useNavigate } from "react-router-dom";
|
|
||||||
import { useCurrentAccount } from "../../hooks/use-current-account";
|
import { useCurrentAccount } from "../../hooks/use-current-account";
|
||||||
import accountService from "../../services/account";
|
import accountService from "../../services/account";
|
||||||
import { ConnectedRelays } from "../connected-relays";
|
import { ConnectedRelays } from "../connected-relays";
|
||||||
import {
|
import { EditIcon, LogoutIcon } from "../icons";
|
||||||
ChatIcon,
|
|
||||||
EditIcon,
|
|
||||||
FeedIcon,
|
|
||||||
LiveStreamIcon,
|
|
||||||
LogoutIcon,
|
|
||||||
MapIcon,
|
|
||||||
NotificationIcon,
|
|
||||||
ProfileIcon,
|
|
||||||
RelayIcon,
|
|
||||||
SearchIcon,
|
|
||||||
} from "../icons";
|
|
||||||
import ProfileLink from "./profile-link";
|
import ProfileLink from "./profile-link";
|
||||||
import AccountSwitcher from "./account-switcher";
|
import AccountSwitcher from "./account-switcher";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { PostModalContext } from "../../providers/post-modal-provider";
|
import { PostModalContext } from "../../providers/post-modal-provider";
|
||||||
import PublishLog from "../publish-log";
|
import PublishLog from "../publish-log";
|
||||||
|
import NavItems from "./nav-items";
|
||||||
|
|
||||||
export default function DesktopSideNav(props: Omit<FlexProps, "children">) {
|
export default function DesktopSideNav(props: Omit<FlexProps, "children">) {
|
||||||
const navigate = useNavigate();
|
|
||||||
const account = useCurrentAccount();
|
const account = useCurrentAccount();
|
||||||
const { openModal } = useContext(PostModalContext);
|
const { openModal } = useContext(PostModalContext);
|
||||||
|
|
||||||
@ -48,35 +36,9 @@ export default function DesktopSideNav(props: Omit<FlexProps, "children">) {
|
|||||||
</Flex>
|
</Flex>
|
||||||
<ProfileLink />
|
<ProfileLink />
|
||||||
<AccountSwitcher />
|
<AccountSwitcher />
|
||||||
<Button onClick={() => navigate("/")} leftIcon={<FeedIcon />}>
|
<NavItems />
|
||||||
Home
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/notifications")} leftIcon={<NotificationIcon />}>
|
|
||||||
Notifications
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/dm")} leftIcon={<ChatIcon />}>
|
|
||||||
Messages
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/search")} leftIcon={<SearchIcon />}>
|
|
||||||
Search
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/streams")} leftIcon={<LiveStreamIcon />}>
|
|
||||||
Streams
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/map")} leftIcon={<MapIcon />}>
|
|
||||||
Map
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/relays")} leftIcon={<RelayIcon />}>
|
|
||||||
Relays
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/profile")} leftIcon={<ProfileIcon />}>
|
|
||||||
Profile
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/settings")} leftIcon={<SettingsIcon />}>
|
|
||||||
Settings
|
|
||||||
</Button>
|
|
||||||
{account && (
|
{account && (
|
||||||
<Button onClick={() => accountService.logout()} leftIcon={<LogoutIcon />}>
|
<Button onClick={() => accountService.logout()} leftIcon={<LogoutIcon />} justifyContent="flex-start">
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
@ -11,26 +11,18 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
Text,
|
Text,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { Link as RouterLink, useNavigate } from "react-router-dom";
|
import { Link as RouterLink } from "react-router-dom";
|
||||||
|
|
||||||
import { ConnectedRelays } from "../connected-relays";
|
import { ConnectedRelays } from "../connected-relays";
|
||||||
import {
|
import { LogoutIcon } from "../icons";
|
||||||
HomeIcon,
|
|
||||||
LiveStreamIcon,
|
|
||||||
LogoutIcon,
|
|
||||||
MapIcon,
|
|
||||||
ProfileIcon,
|
|
||||||
RelayIcon,
|
|
||||||
SearchIcon,
|
|
||||||
SettingsIcon,
|
|
||||||
} from "../icons";
|
|
||||||
import { UserAvatar } from "../user-avatar";
|
import { UserAvatar } from "../user-avatar";
|
||||||
import { UserLink } from "../user-link";
|
import { UserLink } from "../user-link";
|
||||||
import AccountSwitcher from "./account-switcher";
|
import AccountSwitcher from "./account-switcher";
|
||||||
import { useCurrentAccount } from "../../hooks/use-current-account";
|
import { useCurrentAccount } from "../../hooks/use-current-account";
|
||||||
import accountService from "../../services/account";
|
import accountService from "../../services/account";
|
||||||
|
import NavItems from "./nav-items";
|
||||||
|
|
||||||
export default function MobileSideDrawer({ ...props }: Omit<DrawerProps, "children">) {
|
export default function MobileSideDrawer({ ...props }: Omit<DrawerProps, "children">) {
|
||||||
const navigate = useNavigate();
|
|
||||||
const account = useCurrentAccount();
|
const account = useCurrentAccount();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -38,7 +30,7 @@ export default function MobileSideDrawer({ ...props }: Omit<DrawerProps, "childr
|
|||||||
<DrawerOverlay />
|
<DrawerOverlay />
|
||||||
<DrawerContent>
|
<DrawerContent>
|
||||||
<DrawerCloseButton />
|
<DrawerCloseButton />
|
||||||
<DrawerHeader px="4" py="4">
|
<DrawerHeader px="2" py="4">
|
||||||
{account ? (
|
{account ? (
|
||||||
<Flex gap="2">
|
<Flex gap="2">
|
||||||
<UserAvatar pubkey={account.pubkey} size="sm" noProxy />
|
<UserAvatar pubkey={account.pubkey} size="sm" noProxy />
|
||||||
@ -54,29 +46,9 @@ export default function MobileSideDrawer({ ...props }: Omit<DrawerProps, "childr
|
|||||||
<DrawerBody padding={0} overflowY="auto" overflowX="hidden">
|
<DrawerBody padding={0} overflowY="auto" overflowX="hidden">
|
||||||
<AccountSwitcher />
|
<AccountSwitcher />
|
||||||
<Flex direction="column" gap="2" padding="2">
|
<Flex direction="column" gap="2" padding="2">
|
||||||
<Button onClick={() => navigate(`/`)} leftIcon={<HomeIcon />}>
|
<NavItems isInDrawer />
|
||||||
Home
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate(`/search`)} leftIcon={<SearchIcon />}>
|
|
||||||
Search
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/streams")} leftIcon={<LiveStreamIcon />}>
|
|
||||||
Streams
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/map")} leftIcon={<MapIcon />}>
|
|
||||||
Map
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/relays")} leftIcon={<RelayIcon />}>
|
|
||||||
Relays
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate(`/profile`)} leftIcon={<ProfileIcon />}>
|
|
||||||
Profile
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => navigate("/settings")} leftIcon={<SettingsIcon />}>
|
|
||||||
Settings
|
|
||||||
</Button>
|
|
||||||
{account ? (
|
{account ? (
|
||||||
<Button onClick={() => accountService.logout()} leftIcon={<LogoutIcon />}>
|
<Button onClick={() => accountService.logout()} leftIcon={<LogoutIcon />} justifyContent="flex-start">
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
|
56
src/components/layout/nav-items.tsx
Normal file
56
src/components/layout/nav-items.tsx
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import { AbsoluteCenter, Box, Button, Divider } from "@chakra-ui/react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import {
|
||||||
|
ChatIcon,
|
||||||
|
FeedIcon,
|
||||||
|
LiveStreamIcon,
|
||||||
|
MapIcon,
|
||||||
|
NotificationIcon,
|
||||||
|
ProfileIcon,
|
||||||
|
RelayIcon,
|
||||||
|
SearchIcon,
|
||||||
|
SettingsIcon,
|
||||||
|
} from "../icons";
|
||||||
|
|
||||||
|
export default function NavItems({ isInDrawer = false }: { isInDrawer?: boolean }) {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button onClick={() => navigate("/")} leftIcon={<FeedIcon />} justifyContent="flex-start">
|
||||||
|
Notes
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => navigate("/notifications")} leftIcon={<NotificationIcon />} justifyContent="flex-start">
|
||||||
|
Notifications
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => navigate("/dm")} leftIcon={<ChatIcon />} justifyContent="flex-start">
|
||||||
|
Messages
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => navigate("/search")} leftIcon={<SearchIcon />} justifyContent="flex-start">
|
||||||
|
Search
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => navigate("/relays")} leftIcon={<RelayIcon />} justifyContent="flex-start">
|
||||||
|
Relays
|
||||||
|
</Button>
|
||||||
|
<Box position="relative" py="4">
|
||||||
|
<Divider />
|
||||||
|
<AbsoluteCenter
|
||||||
|
backgroundColor={isInDrawer ? "var(--drawer-bg)" : "var(--chakra-colors-chakra-body-bg)"}
|
||||||
|
px="2"
|
||||||
|
>
|
||||||
|
Other Stuff
|
||||||
|
</AbsoluteCenter>
|
||||||
|
</Box>
|
||||||
|
<Button onClick={() => navigate("/streams")} leftIcon={<LiveStreamIcon />} justifyContent="flex-start">
|
||||||
|
Streams
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => navigate("/map")} leftIcon={<MapIcon />} justifyContent="flex-start">
|
||||||
|
Map
|
||||||
|
</Button>
|
||||||
|
<Divider my="2" />
|
||||||
|
<Button onClick={() => navigate("/settings")} leftIcon={<SettingsIcon />} justifyContent="flex-start">
|
||||||
|
Settings
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -1,27 +1,29 @@
|
|||||||
import { Box, Button, LinkBox, Text } from "@chakra-ui/react";
|
import { Box, Button, LinkBox, LinkOverlay } from "@chakra-ui/react";
|
||||||
import { Link as RouterLink, useLocation } from "react-router-dom";
|
import { Link as RouterLink, useLocation } from "react-router-dom";
|
||||||
import { UserAvatar } from "../user-avatar";
|
import { UserAvatar } from "../user-avatar";
|
||||||
import { useUserMetadata } from "../../hooks/use-user-metadata";
|
|
||||||
import { Bech32Prefix, normalizeToBech32 } from "../../helpers/nip19";
|
|
||||||
import { truncatedId } from "../../helpers/nostr/event";
|
|
||||||
import { useCurrentAccount } from "../../hooks/use-current-account";
|
import { useCurrentAccount } from "../../hooks/use-current-account";
|
||||||
|
import { UserDnsIdentityIcon } from "../user-dns-identity-icon";
|
||||||
|
import { useUserMetadata } from "../../hooks/use-user-metadata";
|
||||||
|
import { nip19 } from "nostr-tools";
|
||||||
|
import { getUserDisplayName } from "../../helpers/user-metadata";
|
||||||
|
|
||||||
function ProfileButton() {
|
function ProfileButton() {
|
||||||
const account = useCurrentAccount()!;
|
const account = useCurrentAccount()!;
|
||||||
const metadata = useUserMetadata(account.pubkey);
|
const metadata = useUserMetadata(account.pubkey);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LinkBox
|
<LinkBox borderRadius="lg" borderWidth={1} p="2" display="flex" gap="2" alignItems="center">
|
||||||
as={RouterLink}
|
<UserAvatar pubkey={account.pubkey} noProxy size="sm" />
|
||||||
to={`/u/${normalizeToBech32(account.pubkey, Bech32Prefix.Pubkey)}`}
|
|
||||||
display="flex"
|
|
||||||
gap="2"
|
|
||||||
overflow="hidden"
|
|
||||||
>
|
|
||||||
<UserAvatar pubkey={account.pubkey} noProxy />
|
|
||||||
<Box>
|
<Box>
|
||||||
<Text fontWeight="bold">{metadata?.name}</Text>
|
<LinkOverlay
|
||||||
<Text>{truncatedId(normalizeToBech32(account.pubkey) ?? "")}</Text>
|
as={RouterLink}
|
||||||
|
to={`/u/${nip19.npubEncode(account.pubkey)}`}
|
||||||
|
whiteSpace="nowrap"
|
||||||
|
fontWeight="bold"
|
||||||
|
fontSize="lg"
|
||||||
|
>
|
||||||
|
{getUserDisplayName(metadata, account.pubkey)}
|
||||||
|
</LinkOverlay>
|
||||||
</Box>
|
</Box>
|
||||||
</LinkBox>
|
</LinkBox>
|
||||||
);
|
);
|
||||||
|
@ -13,7 +13,6 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Tr,
|
Tr,
|
||||||
useColorMode,
|
useColorMode,
|
||||||
useToast,
|
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { TimelineLoader } from "../../../classes/timeline-loader";
|
import { TimelineLoader } from "../../../classes/timeline-loader";
|
||||||
import useSubject from "../../../hooks/use-subject";
|
import useSubject from "../../../hooks/use-subject";
|
||||||
@ -31,7 +30,6 @@ function EventRow({
|
|||||||
relays,
|
relays,
|
||||||
...props
|
...props
|
||||||
}: { event: NostrEvent; relays: string[] } & Omit<TableRowProps, "children">) {
|
}: { event: NostrEvent; relays: string[] } & Omit<TableRowProps, "children">) {
|
||||||
const toast = useToast();
|
|
||||||
const sub = useMemo(() => getEventRelays(event.id), [event.id]);
|
const sub = useMemo(() => getEventRelays(event.id), [event.id]);
|
||||||
const seenRelays = useSubject(sub);
|
const seenRelays = useSubject(sub);
|
||||||
|
|
||||||
@ -50,8 +48,6 @@ function EventRow({
|
|||||||
pub.onResult.subscribe((result) => {
|
pub.onResult.subscribe((result) => {
|
||||||
if (result.status) {
|
if (result.status) {
|
||||||
handleEventFromRelay(result.relay, event);
|
handleEventFromRelay(result.relay, event);
|
||||||
} else if (result.message) {
|
|
||||||
toast({ description: result.message, status: result.status ? "success" : "error" });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user