Commit 1e254364 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

feat: injected -> browser wallet w/ icon updates (#6155)

* feat: injected -> browser wallet w/ icon updates

* update tests
parent ee2dc1ee
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import INJECTED_ICON_URL from 'assets/images/arrow-right.svg'
import METAMASK_ICON_URL from 'assets/images/metamask.png' import METAMASK_ICON_URL from 'assets/images/metamask.png'
import INJECTED_DARK_ICON_URL from 'assets/svg/browser-wallet-dark.svg'
import INJECTED_LIGHT_ICON_URL from 'assets/svg/browser-wallet-light.svg'
import { ConnectionType, injectedConnection } from 'connection' import { ConnectionType, injectedConnection } from 'connection'
import { getConnectionName } from 'connection/utils' import { getConnectionName } from 'connection/utils'
import { useIsDarkMode } from 'state/user/hooks'
import Option from './Option' import Option from './Option'
const INJECTED_PROPS = {
color: '#010101',
icon: INJECTED_ICON_URL,
id: 'injected',
}
const METAMASK_PROPS = { const METAMASK_PROPS = {
color: '#E8831D', color: '#E8831D',
icon: METAMASK_ICON_URL, icon: METAMASK_ICON_URL,
...@@ -37,9 +33,12 @@ export function MetaMaskOption({ tryActivation }: { tryActivation: (connector: C ...@@ -37,9 +33,12 @@ export function MetaMaskOption({ tryActivation }: { tryActivation: (connector: C
export function InjectedOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { export function InjectedOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) {
const isActive = injectedConnection.hooks.useIsActive() const isActive = injectedConnection.hooks.useIsActive()
const isDarkMode = useIsDarkMode()
return ( return (
<Option <Option
{...INJECTED_PROPS} color="#010101"
icon={isDarkMode ? INJECTED_DARK_ICON_URL : INJECTED_LIGHT_ICON_URL}
id="injected"
isActive={isActive} isActive={isActive}
header={getConnectionName(ConnectionType.INJECTED, false)} header={getConnectionName(ConnectionType.INJECTED, false)}
onClick={() => tryActivation(injectedConnection.connector)} onClick={() => tryActivation(injectedConnection.connector)}
......
...@@ -75,15 +75,15 @@ const SubHeader = styled.div` ...@@ -75,15 +75,15 @@ const SubHeader = styled.div`
font-size: 12px; font-size: 12px;
` `
const IconWrapper = styled.div<{ size?: number | null }>` const IconWrapper = styled.div`
${flexColumnNoWrap}; ${flexColumnNoWrap};
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding-right: 12px; padding-right: 12px;
& > img, & > img,
span { span {
height: ${({ size }) => (size ? size + 'px' : '28px')}; height: 40px;
width: ${({ size }) => (size ? size + 'px' : '28px')}; width: 40px;
} }
${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToMedium` ${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToMedium`
align-items: flex-end; align-items: flex-end;
...@@ -93,7 +93,6 @@ const IconWrapper = styled.div<{ size?: number | null }>` ...@@ -93,7 +93,6 @@ const IconWrapper = styled.div<{ size?: number | null }>`
export default function Option({ export default function Option({
link = null, link = null,
clickable = true, clickable = true,
size,
onClick = null, onClick = null,
color, color,
header, header,
...@@ -104,7 +103,6 @@ export default function Option({ ...@@ -104,7 +103,6 @@ export default function Option({
}: { }: {
link?: string | null link?: string | null
clickable?: boolean clickable?: boolean
size?: number | null
onClick?: null | (() => void) onClick?: null | (() => void)
color: string color: string
header: React.ReactNode header: React.ReactNode
...@@ -129,7 +127,7 @@ export default function Option({ ...@@ -129,7 +127,7 @@ export default function Option({
> >
<OptionCardLeft> <OptionCardLeft>
<HeaderText color={color}> <HeaderText color={color}>
<IconWrapper size={size}> <IconWrapper>
<img src={icon} alt="Icon" /> <img src={icon} alt="Icon" />
</IconWrapper> </IconWrapper>
{header} {header}
......
...@@ -74,7 +74,7 @@ it('loads Wallet Modal on desktop with generic Injected', async () => { ...@@ -74,7 +74,7 @@ it('loads Wallet Modal on desktop with generic Injected', async () => {
jest.spyOn(connectionUtils, 'getIsCoinbaseWallet').mockReturnValue(false) jest.spyOn(connectionUtils, 'getIsCoinbaseWallet').mockReturnValue(false)
render(<WalletModal pendingTransactions={[]} confirmedTransactions={[]} />) render(<WalletModal pendingTransactions={[]} confirmedTransactions={[]} />)
expect(screen.getByText('Browser Wallet')).toBeInTheDocument() expect(screen.getByText('Browser wallet')).toBeInTheDocument()
expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument() expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument()
expect(screen.getByText('WalletConnect')).toBeInTheDocument() expect(screen.getByText('WalletConnect')).toBeInTheDocument()
expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3) expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3)
......
...@@ -63,7 +63,7 @@ export function getConnectionName( ...@@ -63,7 +63,7 @@ export function getConnectionName(
) { ) {
switch (connectionType) { switch (connectionType) {
case ConnectionType.INJECTED: case ConnectionType.INJECTED:
return hasMetaMaskExtension ? 'MetaMask' : 'Browser Wallet' return hasMetaMaskExtension ? 'MetaMask' : 'Browser wallet'
case ConnectionType.COINBASE_WALLET: case ConnectionType.COINBASE_WALLET:
return 'Coinbase Wallet' return 'Coinbase Wallet'
case ConnectionType.WALLET_CONNECT: case ConnectionType.WALLET_CONNECT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment