-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Zach Couchman <[email protected]> Co-authored-by: Charlie McKenzie <[email protected]> Co-authored-by: Andrea Rampin <[email protected]>
- Loading branch information
1 parent
52f329c
commit ad7267e
Showing
21 changed files
with
696 additions
and
171 deletions.
There are no files selected for viewing
28 changes: 15 additions & 13 deletions
28
packages/checkout/widgets-lib/src/components/Footer/FooterButton.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
69 changes: 69 additions & 0 deletions
69
packages/checkout/widgets-lib/src/components/Transactions/ChangeWallet.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,69 @@ | ||
import { | ||
Box, Button, Caption, Divider, EllipsizedText, Logo, | ||
} from '@biom3/react'; | ||
import { useContext } from 'react'; | ||
import { BridgeContext } from 'widgets/bridge/context/BridgeContext'; | ||
import { isMetaMaskProvider, isPassportProvider } from 'lib/providerUtils'; | ||
import { UserJourney, useAnalytics } from 'context/analytics-provider/SegmentAnalyticsProvider'; | ||
import { BridgeWidgetViews } from 'context/view-context/BridgeViewContextTypes'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { headingStyles } from './ChangeWalletStyles'; | ||
|
||
export interface ChangeWalletProps { | ||
onChangeWalletClick: () => void; | ||
} | ||
|
||
export function ChangeWallet({ | ||
onChangeWalletClick, | ||
}: ChangeWalletProps) { | ||
const { t } = useTranslation(); | ||
const { bridgeState: { from } } = useContext(BridgeContext); | ||
const { track } = useAnalytics(); | ||
const walletAddress = from?.walletAddress || ''; | ||
const isMetaMask = isMetaMaskProvider(from?.web3Provider); | ||
const isPassport = isPassportProvider(from?.web3Provider); | ||
|
||
const handleChangeWalletClick = () => { | ||
track({ | ||
userJourney: UserJourney.BRIDGE, | ||
screen: BridgeWidgetViews.TRANSACTIONS, | ||
controlType: 'Button', | ||
control: 'Pressed', | ||
|
||
}); | ||
onChangeWalletClick(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box sx={headingStyles}> | ||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 'base.spacing.x1' }}> | ||
{isMetaMask && !isPassport && <Logo logo="MetaMaskSymbol" sx={{ width: 'base.icon.size.400' }} />} | ||
{!isMetaMask && isPassport && ( | ||
<Logo | ||
logo="PassportSymbolOutlined" | ||
sx={ | ||
{ | ||
width: 'base.icon.size.400', | ||
pr: 'base.spacing.x1', | ||
} | ||
} | ||
/> | ||
)} | ||
<Caption><EllipsizedText leftSideLength={6} rightSideLength={4} text={walletAddress} /></Caption> | ||
</Box> | ||
<Button size="small" variant="secondary" onClick={handleChangeWalletClick}> | ||
{t('views.TRANSACTIONS.changeWallet.buttonText')} | ||
</Button> | ||
</Box> | ||
<Divider | ||
size="small" | ||
sx={{ | ||
pb: 'base.spacing.x2', | ||
color: 'base.color.translucent.emphasis.300', | ||
opacity: 0.1, | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/checkout/widgets-lib/src/components/Transactions/ChangeWalletStyles.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,7 @@ | ||
export const headingStyles = { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
p: 'base.spacing.x2', | ||
}; |
70 changes: 13 additions & 57 deletions
70
packages/checkout/widgets-lib/src/components/Transactions/EmptyStateNotConnected.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 |
---|---|---|
@@ -1,69 +1,25 @@ | ||
import { Body, Box, Button } from '@biom3/react'; | ||
import { Checkout, WalletProviderName } from '@imtbl/checkout-sdk'; | ||
import { WalletDrawer } from 'widgets/bridge/components/WalletDrawer'; | ||
import { useMemo, useState } from 'react'; | ||
import { UserJourney, useAnalytics } from 'context/analytics-provider/SegmentAnalyticsProvider'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { containerStyle } from './EmptyStateNotConnectedStyles'; | ||
|
||
type EmptyStateNotConnectedProps = { | ||
checkout: Checkout, | ||
updateProvider: (walletProviderName: WalletProviderName) => Promise<void>, | ||
openWalletDrawer: () => void | ||
}; | ||
|
||
export function EmptyStateNotConnected({ checkout, updateProvider }: EmptyStateNotConnectedProps) { | ||
const { track } = useAnalytics(); | ||
export function EmptyStateNotConnected({ openWalletDrawer }: EmptyStateNotConnectedProps) { | ||
const { t } = useTranslation(); | ||
|
||
const [showWalletDrawer, setShowWalletDrawer] = useState(false); | ||
|
||
const walletOptions = useMemo(() => { | ||
const options = [WalletProviderName.METAMASK]; | ||
if (checkout.passport) { | ||
options.push(WalletProviderName.PASSPORT); | ||
} | ||
return options; | ||
}, [checkout]); | ||
|
||
const handleProviderSelected = async (walletProviderName: WalletProviderName) => { | ||
track({ | ||
userJourney: UserJourney.BRIDGE, | ||
screen: 'EmptyStateNotConnected', | ||
control: 'WalletProvider', | ||
controlType: 'Select', | ||
extras: { | ||
walletProviderName, | ||
}, | ||
}); | ||
await updateProvider(walletProviderName); | ||
}; | ||
|
||
const openWalletDrawer = () => setShowWalletDrawer(true); | ||
|
||
return ( | ||
<> | ||
<Box sx={containerStyle}> | ||
<Body sx={{ mb: 'base.spacing.x8' }}>{t('views.TRANSACTIONS.status.emptyState.notConnected.body')}</Body> | ||
<Button | ||
variant="secondary" | ||
size="medium" | ||
testId="transactions-connect-wallet-button" | ||
onClick={openWalletDrawer} | ||
> | ||
{t('views.TRANSACTIONS.status.emptyState.notConnected.buttonText')} | ||
</Button> | ||
</Box> | ||
<WalletDrawer | ||
testId="select-wallet-drawer" | ||
drawerText={{ | ||
heading: t('views.TRANSACTIONS.walletSelection.heading'), | ||
}} | ||
showWalletSelectorTarget={false} | ||
walletOptions={walletOptions} | ||
showDrawer={showWalletDrawer} | ||
setShowDrawer={(show: boolean) => { setShowWalletDrawer(show); }} | ||
onWalletItemClick={handleProviderSelected} | ||
/> | ||
</> | ||
<Box sx={containerStyle}> | ||
<Body sx={{ mb: 'base.spacing.x8' }}>{t('views.TRANSACTIONS.status.emptyState.notConnected.body')}</Body> | ||
<Button | ||
variant="secondary" | ||
size="medium" | ||
testId="transactions-connect-wallet-button" | ||
onClick={openWalletDrawer} | ||
> | ||
{t('views.TRANSACTIONS.status.emptyState.notConnected.buttonText')} | ||
</Button> | ||
</Box> | ||
); | ||
} |
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.