From 8b83c51014f72aff3790f363da7604e5f3de422b Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 11 Sep 2023 11:48:27 +0300 Subject: [PATCH] feat(trading): improve connect wallet description (#4726) Co-authored-by: Matthew Russell --- .../connect-dialog-elements.tsx | 5 +- .../connect-dialog/connect-dialog.spec.tsx | 4 +- .../src/connect-dialog/connect-dialog.tsx | 123 +++++++++++++++--- 3 files changed, 105 insertions(+), 27 deletions(-) diff --git a/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx b/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx index 224e034fd..b078d9c3e 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx @@ -12,10 +12,7 @@ import { useVegaWallet } from '../use-vega-wallet'; export const ConnectDialogTitle = ({ children }: { children: ReactNode }) => { return ( -

+

{children}

); diff --git a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx index 68eb88b1c..dad85fbeb 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx @@ -111,7 +111,7 @@ describe('VegaConnectDialog', () => { rerender(generateJSX()); const list = await screen.findByTestId('connectors-list'); expect(list).toBeInTheDocument(); - expect(list.children).toHaveLength(3); + expect(list.children).toHaveLength(2); expect(screen.getByTestId('connector-jsonRpc')).toHaveTextContent( 'Use the Desktop App/CLI' ); @@ -122,7 +122,7 @@ describe('VegaConnectDialog', () => { mockBrowserWallet(); render(generateJSX()); const list = await screen.findByTestId('connectors-list'); - expect(list.children).toHaveLength(3); + expect(list.children).toHaveLength(2); expect(screen.getByTestId('connector-injected')).toHaveTextContent( 'Connect' ); diff --git a/libs/wallet/src/connect-dialog/connect-dialog.tsx b/libs/wallet/src/connect-dialog/connect-dialog.tsx index e3c0ed4dc..ab8050183 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.tsx @@ -224,28 +224,66 @@ const ConnectorList = ({ /> ); + const isItChrome = window.navigator.userAgent.includes('Chrome'); + const isItMozilla = + window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + const browserName = isItChrome + ? 'Chrome' + : isItMozilla + ? 'Firefox' + : 'your browser'; return ( <> {title} -

+

{t( 'Connect securely, deposit funds and approve or reject transactions with the Vega wallet' )}

-
-
+
+
{isBrowserWalletInstalled() ? ( - onSelect('injected')} + title={ + <> + {t('Vega Wallet')} + {' '} + {t('full featured')} + + } + description={t( + `Connect Vega Wallet extension + for %s to access all features including key + management and detailed transaction views from your + browser.`, + [browserName] + )} /> ) : ( - +
+

+ {t('Vega Wallet')} + {' '} + {t('full featured')} +

+

+ {t( + `Install Vega Wallet extension + for %s to access all features including key + management and detailed transaction views from your + browser.`, + [browserName] + )} +

+ +
)}
{connectors['snap'] !== undefined ? ( @@ -269,9 +307,19 @@ const ConnectorList = ({ /> ) : ( <> - + {t('Metamask Snap')} + {' '} + {t('quick start')} + + } + description={t( + `Connect directly via Metamask with the Vega Snap for single key support without advanced features.` + )} text={ <>
@@ -287,7 +335,7 @@ const ConnectorList = ({ }} /> {snapStatus === SnapStatus.NOT_SUPPORTED ? ( -

+

{t('No MetaMask version that supports snaps detected.')}{' '} {t('Learn more about')}{' '} @@ -300,20 +348,21 @@ const ConnectorList = ({

) : null}
+

{t('Advanced / Other options...')}

onSelect('view')} disabled={Boolean(pubKey)} /> -
-
- onSelect('jsonRpc')} - /> +
+ onSelect('jsonRpc')} + /> +
@@ -451,6 +500,38 @@ export const GetWalletButton = ({ ); }; +const ConnectionOptionWithDescription = ({ + disabled, + type, + text, + onClick, + icon, + description, + title, +}: { + type: WalletType; + text: string | ReactNode; + onClick: () => void; + disabled?: boolean; + icon?: ReactNode; + description?: string | ReactNode; + title?: string | ReactNode; +}) => { + return ( +
+

{title}

+

{description}

+ +
+ ); +}; + const ConnectionOption = ({ disabled, type, @@ -531,7 +612,7 @@ const CustomUrlInput = ({ onClick={() => onSelect('jsonRpc')} /> {isDesktopWalletRunning !== null && ( -

+

{isDesktopWalletRunning ? (