forked from aave/aave-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add HAL Notification Icon on supported market (aave#324)
Co-authored-by: Alex <[email protected]>
- Loading branch information
1 parent
6c382ff
commit 5e83157
Showing
26 changed files
with
219 additions
and
22 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
96 changes: 96 additions & 0 deletions
96
src/components/HelpModal/HealthFactorHelpModal/HALNotificationIcon.tsx
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,96 @@ | ||
import React from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import classNames from 'classnames'; | ||
import { CustomTooltip } from '@aave/aave-ui-kit'; | ||
|
||
import { useUserWalletDataContext } from '../../../libs/web3-data-provider'; | ||
import { useProtocolDataContext } from '../../../libs/protocol-data-provider'; | ||
import { CustomMarket } from '../../../ui-config/markets'; | ||
import { AdditionalItemProps } from '../../TextWithModal'; | ||
|
||
import messages from './messages'; | ||
import staticStyles from './style'; | ||
|
||
import bellGrayDark from './images/bellGrayDark.svg'; | ||
import bellGray from './images/bellGray.svg'; | ||
import bell from './images/bell.svg'; | ||
|
||
const marketToHALAaveVersionUrlParam = (market: CustomMarket): string | undefined => { | ||
const exhaustCases = (_: never) => undefined; | ||
switch (market) { | ||
case CustomMarket.proto_matic: | ||
return 'aavepolygon'; | ||
case CustomMarket.proto_avalanche: | ||
return 'aaveavalanche'; | ||
case CustomMarket.proto_mainnet: | ||
return 'aavev2'; | ||
|
||
case CustomMarket.proto_kovan: | ||
case CustomMarket.proto_mumbai: | ||
case CustomMarket.proto_fuji: | ||
case CustomMarket.amm_kovan: | ||
case CustomMarket.amm_mainnet: | ||
return undefined; | ||
|
||
default: | ||
return exhaustCases(market); | ||
} | ||
}; | ||
|
||
export default function HALNotificationIcon({ | ||
height, | ||
width, | ||
containerClassName, | ||
containerStyle, | ||
iconTheme, | ||
}: AdditionalItemProps) { | ||
const intl = useIntl(); | ||
const { currentAccount } = useUserWalletDataContext(); | ||
const { currentMarket } = useProtocolDataContext(); | ||
|
||
const supportedAaveVersion = marketToHALAaveVersionUrlParam(currentMarket); | ||
const urlString = React.useMemo(() => { | ||
const url = new URL('https://9000.hal.xyz/recipes/aave-track-your-health-factor'); | ||
url.searchParams.set('user', currentAccount); | ||
|
||
const aaveVersionParam = supportedAaveVersion; | ||
if (aaveVersionParam !== undefined) { | ||
url.searchParams.set('aaveversion', aaveVersionParam); | ||
} | ||
|
||
return url.toString(); | ||
}, [currentAccount, supportedAaveVersion]); | ||
|
||
const tooltipId = `${currentAccount}__healthFactor`; | ||
|
||
// Do not show the HAL Noticiation icon on unsupported markets. | ||
if (supportedAaveVersion === undefined) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<a | ||
href={urlString} | ||
target="_blank" | ||
rel="noreferrer" | ||
className={classNames(containerClassName, 'HALNotificationIcon')} | ||
style={containerStyle} | ||
data-tip={true} | ||
data-for={tooltipId} | ||
> | ||
<img | ||
src={iconTheme === 'dark' ? bellGrayDark : iconTheme === 'gray' ? bellGray : bell} | ||
alt="Notify Me" | ||
height={height + 2} | ||
width={width + 2} | ||
/> | ||
|
||
<CustomTooltip | ||
tooltipId={tooltipId} | ||
text={intl.formatMessage(messages.notificationIconTooltipText)} | ||
/> | ||
|
||
<style jsx={true}>{staticStyles}</style> | ||
</a> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
src/components/HelpModal/HealthFactorHelpModal/images/bellGray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
src/components/HelpModal/HealthFactorHelpModal/images/bellGrayDark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
import css from 'styled-jsx/css'; | ||
|
||
/*language=SCSS*/ | ||
const staticStyles = css` | ||
@import 'src/_mixins/vars'; | ||
@import 'src/_mixins/screen-size'; | ||
.HALNotificationIcon { | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
export default staticStyles; |
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
Oops, something went wrong.