-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client-web: fixes related to reading account from QR; add options to …
…copy event and user link
- Loading branch information
Showing
7 changed files
with
240 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { BECH32_PREFIX, encodeBech32 } from "@nostr-ts/common"; | ||
import { | ||
Icon, | ||
IconButton, | ||
Input, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalHeader, | ||
ModalOverlay, | ||
useDisclosure, | ||
} from "@chakra-ui/react"; | ||
import { QRCodeSVG } from "qrcode.react"; | ||
import QrcodeIcon from "mdi-react/QrcodeIcon"; | ||
|
||
interface QRCodeProps { | ||
kind: | ||
| BECH32_PREFIX.PublicKeys | ||
| BECH32_PREFIX.PrivateKeys | ||
| BECH32_PREFIX.Profile; | ||
value: string; | ||
size?: "xs" | "sm" | "md" | "lg" | "xl"; | ||
} | ||
|
||
const labels = [ | ||
{ | ||
kind: BECH32_PREFIX.PublicKeys, | ||
label: "Public Key", | ||
}, | ||
{ | ||
kind: BECH32_PREFIX.PrivateKeys, | ||
label: "Private Key", | ||
}, | ||
{ | ||
kind: BECH32_PREFIX.Profile, | ||
label: "Profile", | ||
}, | ||
]; | ||
|
||
export function QRCodeModal({ kind, value, size }: QRCodeProps) { | ||
(""); | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
|
||
const label = labels.find((l) => l.kind === kind)?.label || "Unknown"; | ||
const tlvItems = [ | ||
{ | ||
type: 0, | ||
value, | ||
}, | ||
]; | ||
const encoded = encodeBech32(kind, tlvItems); | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
icon={<Icon as={QrcodeIcon} />} | ||
onClick={isOpen ? onClose : onOpen} | ||
aria-label="QR" | ||
size={size || "md"} | ||
/> | ||
|
||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent width={380}> | ||
<ModalHeader>{label}</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<QRCodeSVG value={encoded} size={330} /> | ||
<Input value={encoded} mt={2} isReadOnly /> | ||
</ModalBody> | ||
</ModalContent> | ||
</Modal> | ||
</> | ||
); | ||
} |
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.