-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update version, split chains * add unread counter
- Loading branch information
1 parent
45b9d81
commit d855773
Showing
20 changed files
with
211 additions
and
109 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+133 KB
...pter-npm-0.83.0-0ac1951e74-3ed2ac30be.zip → ...pter-npm-0.85.1-80fcc73749-1d53d9dd5f.zip
Binary file not shown.
Binary file renamed
BIN
+18 KB
...tils-npm-0.83.0-7f82213bca-9198e742ea.zip → ...tils-npm-0.85.1-7e14e76776-fd40cee58f.zip
Binary file not shown.
Binary file renamed
BIN
+106 KB
...core-npm-0.83.0-bf88384e1c-67d0925829.zip → ...core-npm-0.85.1-b88964e016-5c873a1835.zip
Binary file not shown.
Binary file removed
BIN
-53.2 KB
.yarn/cache/@notifi-network-notifi-frontend-client-npm-0.83.0-f516e59800-6d16d31b7f.zip
Binary file not shown.
Binary file added
BIN
+53.4 KB
.yarn/cache/@notifi-network-notifi-frontend-client-npm-0.85.1-976ec6b4c6-65b9d928c9.zip
Binary file not shown.
Binary file removed
BIN
-114 KB
.yarn/cache/@notifi-network-notifi-graphql-npm-0.83.0-d837c0be16-bc26986c43.zip
Binary file not shown.
Binary file added
BIN
+114 KB
.yarn/cache/@notifi-network-notifi-graphql-npm-0.85.1-731a2e2b32-ecea5c6037.zip
Binary file not shown.
Binary file removed
BIN
-518 KB
.yarn/cache/@notifi-network-notifi-react-card-npm-0.83.0-277a746fb9-9256009aab.zip
Binary file not shown.
Binary file added
BIN
+522 KB
.yarn/cache/@notifi-network-notifi-react-card-npm-0.85.2-0a38e612fc-6b891354ab.zip
Binary file not shown.
Binary file renamed
BIN
+61.8 KB
...ooks-npm-0.83.0-6d9091fe5f-4f2fd36df2.zip → ...ooks-npm-0.85.1-e9352d49ab-f2d95e15de.zip
Binary file not shown.
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,62 @@ | ||
import { lazy, Suspense } from 'react'; | ||
import { | ||
Button, | ||
Popover, | ||
PopoverTrigger, | ||
PopoverContent, | ||
useDisclosure, | ||
} from '@chakra-ui/react'; | ||
import { | ||
NotificationsIcon, | ||
} from '@snx-v2/icons'; | ||
import { safeImport } from '@synthetixio/safe-import'; | ||
import './notifibutton.css'; | ||
import { useUnreadState } from '@notifi-network/notifi-react-card'; | ||
|
||
const NotifiCard = lazy(() => safeImport(() => import('@snx-v2/Notifi'))); | ||
|
||
export const NotifiButton: React.FC = () => { | ||
|
||
const notifiModal = useDisclosure(); | ||
const { hasUnreadNotification, unreadNotificationCount } = useUnreadState(); | ||
|
||
return ( | ||
<Popover | ||
closeOnBlur={false} | ||
onClose={notifiModal.onClose} | ||
isOpen={notifiModal.isOpen} | ||
> | ||
<PopoverTrigger> | ||
<Button | ||
ml={2} | ||
height={10} | ||
width={10} | ||
bg="navy.900" | ||
borderColor="gray.900" | ||
borderWidth="1px" | ||
borderRadius="4px" | ||
_hover={{ | ||
bg: 'blackAlpha.400', | ||
cursor: 'pointer', | ||
}} | ||
onClick={notifiModal.onOpen} | ||
> | ||
<NotificationsIcon color="white" /> | ||
{hasUnreadNotification && ( | ||
<div className='notifi-unread-counter'> | ||
<div> | ||
{unreadNotificationCount > 99 ? '99' : unreadNotificationCount} | ||
</div> | ||
</div> | ||
)} | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent border="none" width="333px"> | ||
<Suspense fallback={null}> | ||
<NotifiCard onClose={notifiModal.onClose} /> | ||
</Suspense> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
|
||
} |
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,42 @@ | ||
import { arrayify } from '@ethersproject/bytes'; | ||
import { NotifiContext } from '@notifi-network/notifi-react-card'; | ||
import React, { PropsWithChildren, useContext } from 'react'; | ||
import { ContractContext } from '@snx-v2/ContractContext'; | ||
import { SignerContext } from '@snx-v2/SignerContext'; | ||
import { NetworkIdByName } from '@snx-v2/useSynthetixContracts'; | ||
|
||
const isTestnet = (networkId: null | number) => { | ||
if (networkId === NetworkIdByName['mainnet-ovm'] || networkId === NetworkIdByName['mainnet']) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
|
||
export const NotifiContextWrapper: React.FC<PropsWithChildren<{}>> = ({children}: PropsWithChildren<{}>) => { | ||
const { networkId, walletAddress } = useContext(ContractContext); | ||
const signer = useContext(SignerContext); | ||
if (signer === null || walletAddress === null || networkId === null) { | ||
// account is required | ||
return null; | ||
} | ||
const isL2 = networkId === NetworkIdByName['mainnet-ovm']; | ||
const isMainnet = !isTestnet(networkId); | ||
const walletBlockchain = isL2 ? 'OPTIMISM' : 'ETHEREUM'; | ||
|
||
const env = isMainnet ? 'Production' : 'Development'; | ||
|
||
return ( | ||
<NotifiContext | ||
dappAddress="synthetix" | ||
env={env} | ||
signMessage={async (message: Uint8Array) => { | ||
const result = await signer.signMessage(message); | ||
return arrayify(result); | ||
}} | ||
walletPublicKey={walletAddress} | ||
walletBlockchain={walletBlockchain} | ||
> | ||
{children} | ||
</NotifiContext> | ||
); | ||
}; |
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,2 @@ | ||
export * from './NotifiButton'; | ||
export * from './NotifiContextWrapper'; |
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,17 @@ | ||
.notifi-unread-counter { | ||
position: absolute; | ||
top: 0.2rem; | ||
bottom: 0; | ||
left: 1.2rem; | ||
right: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 0.7rem; | ||
color: #000; | ||
text-align: center; | ||
width: 1.05rem; | ||
height: 1.05rem; | ||
background-color: #82F7C5; | ||
border-radius: 50px; | ||
} |
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,13 @@ | ||
{ | ||
"name": "@snx-v2/NotifiButton", | ||
"private": true, | ||
"main": "index.ts", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"@chakra-ui/react": "^2.5.0", | ||
"@notifi-network/notifi-react-card": "^0.85.2", | ||
"@snx-v2/icons": "workspace:*", | ||
"@synthetixio/safe-import": "workspace:*", | ||
"react": "^18.2.0" | ||
} | ||
} |
Oops, something went wrong.