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: sbtc modal #1945

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file added public/sbtc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/app/_components/PageWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { SBTCModal } from '@/common/components/modals/SBTCModal';

Check warning on line 3 in src/app/_components/PageWrapper.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/_components/PageWrapper.tsx#L3

Added line #L3 was not covered by tests
import { useColorModeValue } from '@chakra-ui/react';
import styled from '@emotion/styled';
import { ReactNode } from 'react';
Expand Down Expand Up @@ -77,7 +78,8 @@
<IncidentsStatusBarWithErrorBoundary />
<CMSStatusBars statusBarContent={statusBarContent} />
</Flex>
<NakamotoModal />
{/* <NakamotoModal /> */}
<SBTCModal />
<WrapperWithBg>
<Flex
mx="auto"
Expand Down
26 changes: 13 additions & 13 deletions src/common/components/modals/Nakamoto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
export function NakamotoModal() {
const [isOpen, setIsOpen] = useState(false);

// useEffect(() => {
// const nakamotoModalShown = localStorage.getItem('nakamoto3MainnetModalShown');
// try {
// const dismissQueryParam = new URLSearchParams(window.location.search).get('dismiss');
// // to run performance testing without the modal
// if (dismissQueryParam === 'nakamoto') {
// return;
// }
// } catch (e) {}
// if (!nakamotoModalShown || nakamotoModalShown === 'false') {
// setIsOpen(true);
// }
// }, []);
useEffect(() => {
const nakamotoModalShown = localStorage.getItem('nakamoto3MainnetModalShown');
try {
const dismissQueryParam = new URLSearchParams(window.location.search).get('dismiss');

Check warning on line 26 in src/common/components/modals/Nakamoto.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/Nakamoto.tsx#L23-L26

Added lines #L23 - L26 were not covered by tests
// to run performance testing without the modal
if (dismissQueryParam === 'nakamoto') {
return;

Check warning on line 29 in src/common/components/modals/Nakamoto.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/Nakamoto.tsx#L29

Added line #L29 was not covered by tests
}
} catch (e) {}
if (!nakamotoModalShown || nakamotoModalShown === 'false') {
setIsOpen(true);

Check warning on line 33 in src/common/components/modals/Nakamoto.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/Nakamoto.tsx#L33

Added line #L33 was not covered by tests
}
}, []);

const handleClose = () => {
localStorage.setItem('nakamoto3MainnetModalShown', 'true');
Expand Down
91 changes: 91 additions & 0 deletions src/common/components/modals/SBTCModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import {
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalOverlay,
Stack,
} from '@chakra-ui/react';
import { ArrowUpRight } from '@phosphor-icons/react';
import { useQueryClient } from '@tanstack/react-query';
import { useEffect, useState } from 'react';

Check warning on line 11 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L8-L11

Added lines #L8 - L11 were not covered by tests

import { Icon } from '../../..//ui/Icon';
import { ButtonLink } from '../../../ui/ButtonLink';
import { Flex } from '../../../ui/Flex';
import { Image } from '../../../ui/Image';
import { Modal } from '../../../ui/Modal';
import { Text } from '../../../ui/Text';
import { TextLink } from '../../../ui/TextLink';

Check warning on line 19 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L13-L19

Added lines #L13 - L19 were not covered by tests

export function SBTCModal() {
const [isOpen, setIsOpen] = useState(false);

Check warning on line 22 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L21-L22

Added lines #L21 - L22 were not covered by tests

useEffect(() => {
const sbtcModalShown = localStorage.getItem('sbtcModalShown');
try {
const dismissQueryParam = new URLSearchParams(window.location.search).get('dismiss');

Check warning on line 27 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L24-L27

Added lines #L24 - L27 were not covered by tests
// to run performance testing without the modal
if (dismissQueryParam === 'sbtc') {
return;

Check warning on line 30 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L30

Added line #L30 was not covered by tests
}
} catch (e) {}
if (!sbtcModalShown || sbtcModalShown === 'false') {
setIsOpen(true);

Check warning on line 34 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L34

Added line #L34 was not covered by tests
}
}, []);

const handleClose = () => {
localStorage.setItem('sbtcModalShown', 'true');
setIsOpen(false);

Check warning on line 40 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L38-L40

Added lines #L38 - L40 were not covered by tests
};

const queryClient = useQueryClient();

Check warning on line 43 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L43

Added line #L43 was not covered by tests

return (
<Modal title={'sBTC'} isOpen={isOpen} onClose={() => handleClose()}>

Check warning on line 46 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L46

Added line #L46 was not covered by tests
<ModalOverlay />
<ModalContent width={'762px'} maxWidth={'full'}>
<ModalCloseButton
_focus={{
boxShadow: 'none',
}}
/>
<ModalBody pt={12}>
<Stack alignItems={'center'} gap={6}>
<Text fontSize={'4xl'} textAlign={'center'}>
✨ sBTC is here ✨
</Text>
<Image src={'/sbtc.png'} alt={'sBTC'} />
<Text>sBTC is live! You can now put your Bitcoin to work in DeFi apps.</Text>
<ButtonLink
variant={'primary'}
href={'https://app.stacks.co/'}
onClick={() => {
handleClose();
void queryClient.clear();

Check warning on line 66 in src/common/components/modals/SBTCModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/common/components/modals/SBTCModal.tsx#L64-L66

Added lines #L64 - L66 were not covered by tests
}}
_hover={{ textDecoration: 'none' }}
bg="accent.stacks-500"
>
Mint sBTC
</ButtonLink>
<ModalFooter borderTop={'1px'} width={'full'} justifyContent={'center'}>
<Flex alignItems="center" gap={1}>
<TextLink
color="accent.stacks-500"
href={'https://www.stacks.co/sbtc'}
fontSize={'sm'}
target={'_blank'}
>
Learn more about sBTC
</TextLink>
<Icon as={ArrowUpRight} size={3} color="accent.stacks-500" />
</Flex>
</ModalFooter>
</Stack>
</ModalBody>
</ModalContent>
</Modal>
);
}
Loading