-
Notifications
You must be signed in to change notification settings - Fork 32
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
a3bfeb1
commit 2506bc4
Showing
11 changed files
with
2,612 additions
and
270 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { FC, MouseEventHandler } from 'react'; | ||
import { PairingTypes } from '@useelven/core'; | ||
import { Stack, Box, Text, Heading, IconButton } from '@chakra-ui/react'; | ||
import { CloseIcon } from '@chakra-ui/icons'; | ||
|
||
interface WalletConnectPairingsProps { | ||
pairings: PairingTypes.Struct[]; | ||
login: (topic: string) => Promise<void>; | ||
remove: (topic: string) => Promise<void>; | ||
} | ||
|
||
export const WalletConnectPairings: FC<WalletConnectPairingsProps> = ({ | ||
pairings, | ||
login, | ||
remove, | ||
}) => { | ||
const handleLogin = (topic: string) => () => { | ||
login(topic); | ||
}; | ||
|
||
const handleRemove = | ||
(topic: string): MouseEventHandler<HTMLButtonElement> | undefined => | ||
(e) => { | ||
e.stopPropagation(); | ||
remove(topic); | ||
}; | ||
|
||
return ( | ||
<Stack> | ||
{pairings?.length > 0 && ( | ||
<Heading size="md" mt={4}> | ||
Existing pairings: | ||
</Heading> | ||
)} | ||
{pairings.map((pairing) => ( | ||
<Box | ||
bgColor="elvenTools.white" | ||
py={2} | ||
px={4} | ||
pr={8} | ||
borderRadius="md" | ||
key={pairing.topic} | ||
cursor="pointer" | ||
onClick={handleLogin(pairing.topic)} | ||
userSelect="none" | ||
position="relative" | ||
> | ||
<IconButton | ||
position="absolute" | ||
top={2} | ||
right={2} | ||
aria-label="remove-pairing" | ||
color="elvenTools.dark.base" | ||
h={6} | ||
minW={6} | ||
icon={<CloseIcon boxSize={2} />} | ||
onClick={handleRemove(pairing.topic)} | ||
/> | ||
<Text fontSize="lg" color="elvenTools.dark.base"> | ||
{pairing.peerMetadata?.name} | ||
</Text> | ||
{pairing.peerMetadata?.url ? ( | ||
<Text fontSize="xs" color="elvenTools.dark.base"> | ||
({pairing.peerMetadata.url}) | ||
</Text> | ||
) : null} | ||
</Box> | ||
))} | ||
</Stack> | ||
); | ||
}; |
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
Oops, something went wrong.