Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create modal for lightning and npub #1655

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import { useProjectAtom, useWalletAtom } from '../../../../../../hooks/useProjec
import { FollowButton } from '../../components'
import { CreatorEditButton } from '../../components/CreatorEditButton'
import { CreatorSocial } from './components/CreatorSocial'
import { LightningAddress } from './components/LightningAddress'
import { NpubDisplay } from './components/NpubDisplay'
import { LightningAddressModal } from './components/LightningAddressModal'
import { ShareProjectButton } from './components/ShareProjectButton'

export const Header = () => {
Expand Down Expand Up @@ -160,10 +159,7 @@ export const Header = () => {
</H1>

<HStack w="full" flexWrap={'wrap'}>
<HStack spacing={0.5} maxWidth="full">
<LightningAddress name={`${project.name}`} isGeyser />
<NpubDisplay npub={project?.keys?.nostrKeys.publicKey.npub} />
</HStack>
<LightningAddressModal name={`${project.name}`} npub={project?.keys?.nostrKeys.publicKey.npub} />
sajald77 marked this conversation as resolved.
Show resolved Hide resolved
<CreatorSocial />
</HStack>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, ButtonProps, Tooltip, useDisclosure } from '@chakra-ui/react'
import { Button, ButtonProps, HStack, Icon } from '@chakra-ui/react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { PiLightning } from 'react-icons/pi'
import { PiCopy, PiLightning } from 'react-icons/pi'

import { Body } from '../../../../../../../../../shared/components/typography'
import { copyTextToClipboard } from '../../../../../../../../../utils'
Expand All @@ -13,10 +13,9 @@ interface ILightningQR extends ButtonProps {

export const GEYSER_DOMAIN_POSTFIX = '@geyser.fund'
sajald77 marked this conversation as resolved.
Show resolved Hide resolved

export const LightningAddress = ({ name, isGeyser, ...rest }: ILightningQR) => {
export const LightningAddress = ({ name, isGeyser = true, ...rest }: ILightningQR) => {
const { t } = useTranslation()
const [copy, setCopy] = useState(false)
const { isOpen, onOpen, onClose } = useDisclosure()

const handleAddressCopy = () => {
let toCopy = name
Expand All @@ -28,39 +27,39 @@ export const LightningAddress = ({ name, isGeyser, ...rest }: ILightningQR) => {
setCopy(true)
setTimeout(() => {
setCopy(false)
onClose()
}, 2000)
}

return (
<>
<Tooltip
label={copy ? t('Copied!') : t('Copy Lightning Address / Nostr identifier (NIP-05)')}
placement="top"
closeOnClick={false}
isOpen={isOpen}
<HStack w="full">
<Button
id="lightning-address"
size="md"
variant={copy ? 'solid' : 'soft'}
colorScheme="primary1"
leftIcon={<Icon as={PiLightning} fontSize={'18px'} />}
onClick={handleAddressCopy}
{...rest}
>
<Button
id="lightning-address"
size="sm"
variant="soft"
colorScheme="primary1"
leftIcon={<PiLightning />}
onClick={handleAddressCopy}
onMouseEnter={onOpen}
onMouseLeave={onClose}
{...rest}
>
<Body size="sm" medium isTruncated flex={1}>
{name}
<Body size="md" medium isTruncated>
{name}
</Body>
{isGeyser && (
<Body size="md" medium>
{GEYSER_DOMAIN_POSTFIX}
</Body>
{isGeyser && (
<Body size="sm" medium>
{GEYSER_DOMAIN_POSTFIX}
</Body>
)}
</Button>
</Tooltip>
</>
)}
</Button>
<Button
minWidth={24}
sajald77 marked this conversation as resolved.
Show resolved Hide resolved
size="md"
variant="solid"
colorScheme="primary1"
rightIcon={<PiCopy />}
onClick={handleAddressCopy}
>
{copy ? t('Copied') : t('Copy')}
</Button>
</HStack>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Button, ButtonProps, ListItem, UnorderedList, VStack } from '@chakra-ui/react'
import { useTranslation } from 'react-i18next'
import { PiLightning } from 'react-icons/pi'

import { Modal } from '@/shared/components/layouts'
import { useModal } from '@/shared/hooks'

import { Body } from '../../../../../../../../../shared/components/typography'
import { LightningAddress } from './LightningAddress'
import { NpubDisplay } from './NpubDisplay'

interface LightningAddressModalProps extends ButtonProps {
name: string
npub?: string
}

export const GEYSER_DOMAIN_POSTFIX = '@geyser.fund'
sajald77 marked this conversation as resolved.
Show resolved Hide resolved

export const LightningAddressModal = ({ name, npub, ...rest }: LightningAddressModalProps) => {
const { t } = useTranslation()

const lightningAddressModal = useModal()

return (
<>
<Button
id="lightning-address"
size="sm"
variant="soft"
colorScheme="primary1"
leftIcon={<PiLightning fontSize={'16px'} />}
onClick={lightningAddressModal.onOpen}
{...rest}
>
<Body size="sm" medium isTruncated flex={1}>
{name}
</Body>

<Body size="sm" medium>
{GEYSER_DOMAIN_POSTFIX}
</Body>
</Button>

<Modal
size="lg"
{...lightningAddressModal}
title={t('Lightning address & NPUB')}
bodyProps={{ as: VStack, gap: 6 }}
>
<VStack w="full" spacing={3}>
<VStack w="full" alignItems={'start'} spacing={0}>
<Body size="sm">{t('A Lightning Address is an email-like identifier for receiving Bitcoin.')}</Body>
<UnorderedList>
<ListItem>
<Body size="sm">
{t(
'Add this Lightning Address to your Nostr profile for this project to get “zapped” (tipped) directly by other users',
)}
</Body>
</ListItem>
<ListItem>
<Body size="sm">
{t('Share your Geyser Lightning address with anyone, and they can fund you through it instantly.')}
</Body>
</ListItem>
</UnorderedList>
</VStack>
<LightningAddress flex={1} name={name} />
</VStack>
{npub && (
<VStack w="full" spacing={3}>
<Body size="sm">
{t(
"Nostr npub is your project's unique identifier on the censorship-resistant, decentralized Nostr social network.",
)}
</Body>

<NpubDisplay npub={npub} />
</VStack>
)}
</Modal>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ButtonProps, IconButton, Tooltip, useDisclosure } from '@chakra-ui/react'
import { Button, ButtonProps, HStack } from '@chakra-ui/react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { PiCopy } from 'react-icons/pi'

import { Body } from '@/shared/components/typography'

import { NostrIcon } from '../../../../../../../../../shared/components/icons'
import { copyTextToClipboard } from '../../../../../../../../../utils'
Expand All @@ -13,7 +16,6 @@ interface NpubDisplayProps extends ButtonProps {
export const NpubDisplay = ({ npub, iconOnly, ...rest }: NpubDisplayProps) => {
const { t } = useTranslation()
const [copy, setCopy] = useState(false)
const { isOpen, onOpen, onClose } = useDisclosure()

const handleCopyPubkey = () => {
copyTextToClipboard(npub)
Expand All @@ -24,26 +26,35 @@ export const NpubDisplay = ({ npub, iconOnly, ...rest }: NpubDisplayProps) => {
setCopy(true)
setTimeout(() => {
setCopy(false)
onClose()
}, 2000)
}

return (
<Tooltip label={copy ? t('Copied!') : t('Copy')} placement="top-start" closeOnClick={false} isOpen={isOpen}>
<IconButton
size="sm"
<HStack w="full">
<Button
size="md"
aria-label="nostr-icon"
variant="soft"
colorScheme="primary1"
onMouseEnter={onOpen}
onMouseLeave={onClose}
_hover={{ bgColor: copy ? 'primary1.9' : undefined }}
icon={<NostrIcon height="16px" width="16px" />}
variant={copy ? 'solid' : 'soft'}
colorScheme="violet"
leftIcon={<NostrIcon height="18px" width="18px" />}
onClick={handleOnCopy}
{...rest}
>
{}
</IconButton>
</Tooltip>
<Body size="md" medium isTruncated flex={1}>
{npub}
</Body>
</Button>
<Button
minWidth={24}
sajald77 marked this conversation as resolved.
Show resolved Hide resolved
size="md"
variant="solid"
colorScheme="primary1"
rightIcon={<PiCopy />}
onClick={handleOnCopy}
isTruncated
>
{copy ? t('Copied') : t('Copy')}
</Button>
</HStack>
)
}