-
Notifications
You must be signed in to change notification settings - Fork 5
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(extension) add FOOR buy ADA button to Banxa [LW-5104],[LW-10213] #1016
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d6045aa
feat(extension): add buy ADA button and modal (WIP)
tommayeliog 6f67288
feat(extension): add buy ADA button and modal - scrollbar
tommayeliog 348f1bc
feat(extension): add buy ADA button and modal .env vars
tommayeliog 709be6f
feat(extension): buy ADA Banxa - fix PR comments
tommayeliog c3f1bc7
Merge branch 'main' into feat/LW-5104-foor-buy-ada-button-modal
tommayeliog 24cd31f
feat(extension): add PostHog events for Topup buy ADA
tommayeliog 1b9d076
Merge branch 'main' into feat/LW-5104-foor-buy-ada-button-modal
tommayeliog 02f5b6d
fix(extension): remove unnecessary PostHog action
tommayeliog ff1355d
Merge branch 'main' into feat/LW-5104-foor-buy-ada-button-modal
tommayeliog 480dd6f
refactor(extension): rename component for TopUpWallet
tommayeliog e481499
Merge branch 'main' into feat/LW-5104-foor-buy-ada-button-modal
tommayeliog 7e88172
feat(extension): foor buy ada via Banxa
tommayeliog 0f4a8e2
feat(extension): fix darkmode colour
tommayeliog 7d98bf6
feat(extension): fixing UI for Buy ADA card
tommayeliog 1de8843
feat(extension): remove Buy ADA card from popup sidebar on smaller re…
tommayeliog f217d20
feat(extension): show buy ADA only on Mainnet
tommayeliog 38da05f
feat(extension): by Ada Dialog - set default button Continue
tommayeliog 1749dd7
refactor(extension): fix test for AssetsPortfolio
tommayeliog 40145ee
Merge branch 'main' into feat/LW-5104-foor-buy-ada-button-modal
tommayeliog e314271
fix(ui): fix storybook call to action button
tommayeliog 6c0d6d9
Update apps/browser-extension-wallet/src/views/browser-view/component…
tommayeliog a356d56
Update apps/browser-extension-wallet/src/views/browser-view/component…
tommayeliog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 35 additions & 0 deletions
35
...er-extension-wallet/src/views/browser-view/components/TopUpWallet/TopUpWallet.module.scss
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,35 @@ | ||
@import '../../../../../../../packages/common/src/ui/styles/abstracts/mixins'; | ||
|
||
.card { | ||
align-self: stretch; | ||
} | ||
|
||
.titleBadge { | ||
align-self: start; | ||
border-radius: size_unit(2); | ||
background: var(--primary-gradient); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 0 size_unit(1); | ||
height: 20px; | ||
} | ||
.badgeCaption { | ||
color: var(--color-white, #fff) !important; | ||
} | ||
|
||
.scroll { | ||
@include scroll-bar-style; | ||
overflow: auto; | ||
height: 127px; | ||
padding: 0 4px; | ||
color: var(--light-mode-dark-grey, var(--dark-mode-light-grey, #6f7786)); | ||
} | ||
|
||
.disclaimerShort { | ||
color: var(--light-mode-mid-grey, var(--dark-mode-light-grey, #c0c0c0)) !important; | ||
} | ||
|
||
.disclaimerFullWrapper { | ||
text-align: center; | ||
} |
44 changes: 44 additions & 0 deletions
44
...wser-extension-wallet/src/views/browser-view/components/TopUpWallet/TopUpWalletButton.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,44 @@ | ||
import { tabs } from 'webextension-polyfill'; | ||
import { ReactComponent as AdaComponentTransparent } from '@lace/icons/dist/AdaComponentTransparent'; | ||
import React, { useRef, useState } from 'react'; | ||
import { Button } from '@lace/ui'; | ||
import { TopUpWalletDialog } from './TopUpWalletDialog'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { BANXA_LACE_URL } from './config'; | ||
import { useAnalyticsContext } from '@providers'; | ||
import { PostHogAction } from '@lace/common'; | ||
|
||
export const TopUpWalletButton = (): React.ReactElement => { | ||
const dialogTriggerReference = useRef<HTMLButtonElement>(null); | ||
const [open, setOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
const analytics = useAnalyticsContext(); | ||
|
||
return ( | ||
<> | ||
<Button.CallToAction | ||
icon={<AdaComponentTransparent />} | ||
label={t('browserView.assets.topupWallet.buyButton.caption')} | ||
onClick={() => { | ||
analytics.sendEventToPostHog(PostHogAction.TokenTokensTopYourWalletBuyAdaClick); | ||
setOpen(true); | ||
}} | ||
ref={dialogTriggerReference} | ||
/> | ||
|
||
<TopUpWalletDialog | ||
onCancel={() => { | ||
analytics.sendEventToPostHog(PostHogAction.TokenBuyAdaDisclaimerGoBackClick); | ||
setOpen(false); | ||
}} | ||
open={open} | ||
triggerRef={dialogTriggerReference} | ||
onConfirm={() => { | ||
analytics.sendEventToPostHog(PostHogAction.TokenBuyAdaDisclaimerContinueClick); | ||
tabs.create({ url: BANXA_LACE_URL }); | ||
setOpen(false); | ||
}} | ||
/> | ||
</> | ||
); | ||
}; |
33 changes: 33 additions & 0 deletions
33
...rowser-extension-wallet/src/views/browser-view/components/TopUpWallet/TopUpWalletCard.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,33 @@ | ||
import React from 'react'; | ||
import { Card, Flex, Text } from '@lace/ui'; | ||
import styles from './TopUpWallet.module.scss'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { TopUpWalletButton } from './TopUpWalletButton'; | ||
|
||
export const TopUpWalletCard = (): React.ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Card.Outlined className={styles.card}> | ||
<Flex flexDirection="column" mx="$20" my="$20" gap="$6" alignItems="stretch"> | ||
<div className={styles.titleBadge}> | ||
<Text.Label className={styles.badgeCaption} weight="$medium"> | ||
{t('browserView.assets.topupWallet.card.badge')} | ||
</Text.Label> | ||
</div> | ||
<Flex my="$10"> | ||
<Text.SubHeading weight="$bold">{t('browserView.assets.topupWallet.card.title')}</Text.SubHeading> | ||
</Flex> | ||
<Flex flexDirection="column" alignItems="stretch" gap="$16" mt="$10"> | ||
<Text.Body.Normal weight="$medium" color="secondary"> | ||
{t('browserView.assets.topupWallet.buyButton.title')} | ||
</Text.Body.Normal> | ||
<TopUpWalletButton /> | ||
<Text.Label weight="$medium" className={styles.disclaimerShort}> | ||
{t('browserView.assets.topupWallet.disclaimer.short')} | ||
</Text.Label> | ||
</Flex> | ||
</Flex> | ||
</Card.Outlined> | ||
); | ||
}; |
52 changes: 52 additions & 0 deletions
52
...wser-extension-wallet/src/views/browser-view/components/TopUpWallet/TopUpWalletDialog.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,52 @@ | ||
import React, { useCallback } from 'react'; | ||
import { Box, Dialog, Text, TextLink } from '@lace/ui'; | ||
import styles from './TopUpWallet.module.scss'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { tabs } from 'webextension-polyfill'; | ||
import { BANXA_HOMEPAGE_URL } from './config'; | ||
|
||
interface TopUpWalletDialogProps { | ||
open: boolean; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
triggerRef: React.RefObject<HTMLElement>; | ||
} | ||
export const TopUpWalletDialog = ({ | ||
open, | ||
onCancel, | ||
onConfirm, | ||
triggerRef | ||
}: TopUpWalletDialogProps): React.ReactElement => { | ||
const { t } = useTranslation(); | ||
const handleOpenTabBanxaHomepage = useCallback(() => { | ||
tabs.create({ url: BANXA_HOMEPAGE_URL }); | ||
}, []); | ||
|
||
return ( | ||
<Dialog.Root open={open} setOpen={onCancel} zIndex={1000} onCloseAutoFocusRef={triggerRef}> | ||
<Dialog.Title>{t('browserView.assets.topupWallet.modal.title')}</Dialog.Title> | ||
<Dialog.Description> | ||
<Box className={styles.disclaimerFullWrapper}> | ||
<Text.Body.Normal weight="$medium" color="secondary"> | ||
{t('browserView.assets.topupWallet.disclaimer.full.part1')} | ||
</Text.Body.Normal> | ||
<TextLink | ||
onClick={handleOpenTabBanxaHomepage} | ||
label={t('browserView.assets.topupWallet.disclaimer.full.banxaLinkCaption')} | ||
/> | ||
<Text.Body.Normal weight="$medium" color="secondary"> | ||
{t('browserView.assets.topupWallet.disclaimer.full.part2')} | ||
</Text.Body.Normal> | ||
<TextLink | ||
onClick={handleOpenTabBanxaHomepage} | ||
label={t('browserView.assets.topupWallet.disclaimer.full.banxaLinkCaption')} | ||
/> | ||
</Box> | ||
</Dialog.Description> | ||
<Dialog.Actions> | ||
<Dialog.Action cancel label={t('browserView.assets.topupWallet.modal.goBack')} onClick={onCancel} /> | ||
<Dialog.Action autoFocus label={t('browserView.assets.topupWallet.modal.continue')} onClick={onConfirm} /> | ||
</Dialog.Actions> | ||
</Dialog.Root> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
apps/browser-extension-wallet/src/views/browser-view/components/TopUpWallet/config.ts
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,3 @@ | ||
export const USE_FOOR_TOPUP = process.env.USE_FOOR_TOPUP === 'true'; | ||
export const BANXA_LACE_URL = process.env.BANXA_LACE_URL; | ||
export const BANXA_HOMEPAGE_URL = process.env.BANXA_HOMEPAGE_URL; |
2 changes: 2 additions & 0 deletions
2
apps/browser-extension-wallet/src/views/browser-view/components/TopUpWallet/index.ts
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 './TopUpWalletButton'; | ||
export * from './TopUpWalletCard'; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a button? Maybe we could leave
TopUpWallet
as a name because it's a feature with a button and dialog. You can come up with a better name ofc 😄On the other hand I'd probably leave the button/dialog separately and integrate the logic in some sort of
TopUpWalletCardContainer
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @przemyslaw-wlodek, yes, it's a button and a modal. It's not stated on the JIRA ticket but maybe at some point a new requirement will be added for the modal to be visible just once. Then Button will be much more relevant. TBO I don't know - maybe TopUpWalletButtonConfirmation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider
TopUpWallet
then 😃 WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @przemyslaw-wlodek, I'm not 100% sure :) but it just because the feature has been named with the same name (TopUpWallet), and this "button + modal" is just one of the components, however I'm happy to rename it.