add new note button to bottom nav

This commit is contained in:
hzrd149 2023-03-21 10:19:38 -06:00
parent 850e781dee
commit 1c473e5850
5 changed files with 49 additions and 26 deletions

View File

@ -233,3 +233,9 @@ export const CameraIcon = createIcon({
d: "M9.828 5l-2 2H4v12h16V7h-3.828l-2-2H9.828zM9 3h6l2 2h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h4l2-2zm3 15a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11zm0-2a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",
defaultProps,
});
export const PlusCircleIcon = createIcon({
displayName: "PlusCircleIcon",
d: "M11 11V7h2v4h4v2h-4v4h-2v-4H7v-2h4zm1 11C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16z",
defaultProps,
});

View File

@ -23,27 +23,27 @@ export const Page = ({ children }: { children: React.ReactNode }) => {
const isMobile = useIsMobile();
return (
<Container
size="lg"
display="flex"
flexDirection="column"
height="100%"
overflow="hidden"
position="relative"
padding="0"
>
<ReloadPrompt />
{isMobile && <MobileHeader />}
<Flex gap="4" grow={1} overflow="hidden">
{!isMobile && <DesktopSideNav />}
<Flex flexGrow={1} direction="column" overflow="hidden">
<ErrorBoundary>
<PostModalProvider>{children}</PostModalProvider>
</ErrorBoundary>
<PostModalProvider>
<Container
size="lg"
display="flex"
flexDirection="column"
height="100%"
overflow="hidden"
position="relative"
padding="0"
>
<ReloadPrompt />
{isMobile && <MobileHeader />}
<Flex gap="4" grow={1} overflow="hidden">
{!isMobile && <DesktopSideNav />}
<Flex flexGrow={1} direction="column" overflow="hidden">
<ErrorBoundary>{children}</ErrorBoundary>
</Flex>
{!isMobile && <FollowingSideNav />}
</Flex>
{!isMobile && <FollowingSideNav />}
</Flex>
{isMobile && <MobileBottomNav />}
</Container>
{isMobile && <MobileBottomNav />}
</Container>
</PostModalProvider>
);
};

View File

@ -1,10 +1,14 @@
import { ChatIcon } from "@chakra-ui/icons";
import { Flex, IconButton } from "@chakra-ui/react";
import { useContext } from "react";
import { useNavigate } from "react-router-dom";
import { FeedIcon, HomeIcon, NotificationIcon, SearchIcon, SettingsIcon } from "../icons";
import { useCurrentAccount } from "../../hooks/use-current-account";
import { PostModalContext } from "../../providers/post-modal-provider";
import { ChatIcon, HomeIcon, NotificationIcon, PlusCircleIcon, SearchIcon } from "../icons";
export default function MobileBottomNav() {
const { openModal } = useContext(PostModalContext);
const navigate = useNavigate();
const account = useCurrentAccount();
return (
<Flex flexShrink={0} gap="2" padding="2">
@ -16,6 +20,16 @@ export default function MobileBottomNav() {
flexGrow="1"
size="md"
/>
<IconButton
icon={<PlusCircleIcon fontSize="1.8em" />}
aria-label="New Note"
onClick={() => {
openModal();
}}
variant="solid"
colorScheme="brand"
isDisabled={account.readonly}
/>
<IconButton icon={<ChatIcon />} aria-label="Messages" onClick={() => navigate(`/dm`)} flexGrow="1" size="md" />
<IconButton
icon={<NotificationIcon />}

View File

@ -179,7 +179,7 @@ export const PostModal = ({ isOpen, onClose, initialDraft }: PostModalProps) =>
};
return (
<Modal isOpen={isOpen} onClose={onClose} size="4xl">
<Modal isOpen={isOpen} onClose={onClose} size="4xl" closeOnOverlayClick={false}>
<ModalOverlay />
<ModalContent>
<ModalBody padding={isMobile ? "2" : "4"}>{renderContent()}</ModalBody>

View File

@ -1,5 +1,6 @@
import { useDisclosure } from "@chakra-ui/react";
import React, { useCallback, useMemo, useState } from "react";
import { ErrorBoundary } from "../components/error-boundary";
import { PostModal } from "../components/post-modal";
import { DraftNostrEvent } from "../types/nostr-event";
@ -25,8 +26,10 @@ export const PostModalProvider = ({ children }: { children: React.ReactNode }) =
return (
<PostModalContext.Provider value={context}>
{isOpen && <PostModal isOpen initialDraft={draft} onClose={onClose} />}
{children}
<ErrorBoundary>
{isOpen && <PostModal isOpen initialDraft={draft} onClose={onClose} />}
{children}
</ErrorBoundary>
</PostModalContext.Provider>
);
};