-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
0a89d73
commit c8cbbf5
Showing
27 changed files
with
752 additions
and
79 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
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
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 was deleted.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
apps/web/src/components/Menu/AddressBookMenu/AddressBookMenu.tsx
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,127 @@ | ||
import { | ||
Box, | ||
Button, | ||
Center, | ||
Divider, | ||
Flex, | ||
Heading, | ||
IconButton, | ||
Text, | ||
VStack, | ||
useBreakpointValue, | ||
} from "@chakra-ui/react"; | ||
import { useDynamicDrawerContext, useDynamicModalContext } from "@umami/components"; | ||
import { type Contact } from "@umami/core"; | ||
import { useSortedContacts } from "@umami/state"; | ||
|
||
import { DeleteContactModal } from "./DeleteContactModal"; | ||
import { EditContactMenu } from "./EditContactMenu"; | ||
import { EditIcon, ThreeDotsIcon, TrashIcon } from "../../../assets/icons"; | ||
import { useColor } from "../../../styles/useColor"; | ||
import { ActionsDropdown } from "../../ActionsDropdown"; | ||
import { CopyAddressButton } from "../../CopyAddressButton"; | ||
import { EmptyMessage } from "../../EmptyMessage"; | ||
import { DrawerContentWrapper } from "../DrawerContentWrapper"; | ||
|
||
type ContactItemProps = { | ||
contact: Contact; | ||
}; | ||
|
||
const ContactItem = ({ contact }: ContactItemProps) => { | ||
const { openWith: openDrawer } = useDynamicDrawerContext(); | ||
const { openWith: openModal } = useDynamicModalContext(); | ||
const color = useColor(); | ||
|
||
const isLongAddress = useBreakpointValue({ base: false, md: true }); | ||
|
||
const actions = ( | ||
<Box> | ||
<Button | ||
data-testid="edit-network" | ||
onClick={e => { | ||
e.stopPropagation(); | ||
return openDrawer(<EditContactMenu contact={contact} />); | ||
}} | ||
variant="dropdownOption" | ||
> | ||
<EditIcon /> | ||
<Text color={color("900")} fontWeight="600"> | ||
Edit | ||
</Text> | ||
</Button> | ||
<Button | ||
data-testid="remove-network" | ||
onClick={() => openModal(<DeleteContactModal contact={contact} />)} | ||
variant="dropdownOption" | ||
> | ||
<TrashIcon /> | ||
<Text color={color("900")} fontWeight="600"> | ||
Remove | ||
</Text> | ||
</Button> | ||
</Box> | ||
); | ||
|
||
return ( | ||
<Center | ||
key={contact.pkh} | ||
alignItems="center" | ||
justifyContent="space-between" | ||
width="full" | ||
height="60px" | ||
data-testid="peer-row" | ||
> | ||
<Flex height="100%"> | ||
<Center alignItems="flex-start" flexDirection="column" gap="6px"> | ||
<Heading color={color("900")} size="lg"> | ||
{contact.name} | ||
</Heading> | ||
<CopyAddressButton address={contact.pkh} isLong={isLongAddress} /> | ||
</Center> | ||
</Flex> | ||
<ActionsDropdown actions={actions}> | ||
<IconButton color={color("500")} aria-label="Remove Peer" icon={<ThreeDotsIcon />} /> | ||
</ActionsDropdown> | ||
</Center> | ||
); | ||
}; | ||
|
||
export const AddressBookMenu = () => { | ||
const { openWith } = useDynamicDrawerContext(); | ||
const contacts = useSortedContacts(); | ||
|
||
return ( | ||
<DrawerContentWrapper title="Address book"> | ||
<Button | ||
width="fit-content" | ||
marginTop="18px" | ||
padding="0 24px" | ||
onClick={() => openWith(<EditContactMenu />)} | ||
variant="secondary" | ||
> | ||
Add Contact | ||
</Button> | ||
<Divider marginTop={{ base: "36px", lg: "40px" }} /> | ||
{contacts.length ? ( | ||
<VStack | ||
alignItems="flex-start" | ||
gap="24px" | ||
marginTop="24px" | ||
divider={<Divider />} | ||
spacing="0" | ||
> | ||
{contacts.map(contact => ( | ||
<ContactItem key={contact.pkh} contact={contact} /> | ||
))} | ||
</VStack> | ||
) : ( | ||
<EmptyMessage | ||
alignItems="flex-start" | ||
marginTop="40px" | ||
subtitle="Contacts" | ||
title="Contacts" | ||
/> | ||
)} | ||
</DrawerContentWrapper> | ||
); | ||
}; |
Oops, something went wrong.
c8cbbf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.