-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): View on Block Explorer Modal
- Loading branch information
1 parent
25973a1
commit 240cb8d
Showing
12 changed files
with
332 additions
and
3 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
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
56 changes: 56 additions & 0 deletions
56
...wallet_ui/components/desktop/popup-modals/view_on_block_explorer_modal/network_button.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,56 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
import * as React from 'react' | ||
|
||
// Types | ||
import { BraveWallet } from '../../../../constants/types' | ||
|
||
// Custom hooks | ||
import { useExplorer } from '../../../../common/hooks/explorer' | ||
|
||
// Utils | ||
import { getLocale } from '../../../../../common/locale' | ||
|
||
// Components | ||
import { CreateNetworkIcon } from '../../../shared/create-network-icon' | ||
|
||
// Styles | ||
import { Button, LaunchIcon } from './view_on_block_explorer_modal.style' | ||
import { Text, Row } from '../../../shared/style' | ||
|
||
interface Props { | ||
network: BraveWallet.NetworkInfo | ||
address: string | ||
} | ||
|
||
export const NetworkButton = (props: Props) => { | ||
const { network, address } = props | ||
|
||
// Hooks | ||
const onClickViewOnBlockExplorer = useExplorer(network) | ||
|
||
return ( | ||
<Button onClick={onClickViewOnBlockExplorer('address', address)}> | ||
<Row width='unset'> | ||
<CreateNetworkIcon | ||
network={network} | ||
marginRight={12} | ||
size='big' | ||
/> | ||
<Text | ||
isBold={true} | ||
textColor='primary' | ||
textSize='14px' | ||
> | ||
{getLocale('braveWalletNetworkExplorer').replace( | ||
'$1', | ||
network.chainName | ||
)} | ||
</Text> | ||
</Row> | ||
<LaunchIcon /> | ||
</Button> | ||
) | ||
} |
52 changes: 52 additions & 0 deletions
52
...s/desktop/popup-modals/view_on_block_explorer_modal/view_on_block_explorer_modal.style.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,52 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
import styled from 'styled-components' | ||
import * as leo from '@brave/leo/tokens/css/variables' | ||
import Icon from '@brave/leo/react/icon' | ||
|
||
// Shared Styled | ||
import { Row, WalletButton, Column, Text } from '../../../shared/style' | ||
|
||
export const StyledWrapper = styled(Column)` | ||
overflow: hidden; | ||
` | ||
|
||
export const AccountInfoRow = styled(Row)` | ||
background-color: ${leo.color.container.highlight}; | ||
border-radius: ${leo.radius.xl}; | ||
padding: 8px; | ||
` | ||
|
||
export const AddressText = styled(Text)` | ||
word-break: break-all; | ||
` | ||
|
||
export const Button = styled(WalletButton)` | ||
cursor: pointer; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
background: none; | ||
background-color: none; | ||
outline: none; | ||
border: none; | ||
border-radius: ${leo.radius.m}; | ||
width: 100%; | ||
padding: 16px; | ||
--icon-display: none; | ||
&:hover { | ||
background-color: ${leo.color.container.highlight}; | ||
--icon-display: block; | ||
} | ||
` | ||
|
||
export const LaunchIcon = styled(Icon).attrs({ | ||
name: 'launch' | ||
})` | ||
display: var(--icon-display); | ||
--leo-icon-size: 16px; | ||
color: ${leo.color.icon.interactive}; | ||
` |
118 changes: 118 additions & 0 deletions
118
...onents/desktop/popup-modals/view_on_block_explorer_modal/view_on_block_explorer_modal.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,118 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
import * as React from 'react' | ||
|
||
// Types | ||
import { BraveWallet } from '../../../../constants/types' | ||
|
||
// Queries | ||
import { | ||
useGetVisibleNetworksQuery // | ||
} from '../../../../common/slices/api.slice' | ||
|
||
// Utils | ||
import { getLocale } from '../../../../../common/locale' | ||
import { | ||
getNetworkId // | ||
} from '../../../../common/slices/entities/network.entity' | ||
|
||
// Components | ||
import { PopupModal } from '../../popup-modals/index' | ||
import { | ||
CreateAccountIcon // | ||
} from '../../../shared/create-account-icon/create-account-icon' | ||
import { NetworkButton } from './network_button' | ||
|
||
// Styles | ||
import { | ||
AccountInfoRow, | ||
StyledWrapper, | ||
AddressText | ||
} from './view_on_block_explorer_modal.style' | ||
import { Column, Text, Row, ScrollableColumn } from '../../../shared/style' | ||
|
||
interface Props { | ||
account: BraveWallet.AccountInfo | ||
onClose: () => void | ||
} | ||
|
||
export const ViewOnBlockExplorerModal = (props: Props) => { | ||
const { account, onClose } = props | ||
|
||
// Queries | ||
const { data: visibleNetworks = [] } = useGetVisibleNetworksQuery() | ||
|
||
// Memos | ||
const networksByAccountCoinType = React.useMemo(() => { | ||
return visibleNetworks.filter( | ||
(network) => network.coin === account.accountId.coin | ||
) | ||
}, [visibleNetworks, account]) | ||
|
||
return ( | ||
<PopupModal | ||
title={getLocale('braveWalletTransactionExplorer')} | ||
onClose={onClose} | ||
width='520px' | ||
> | ||
<StyledWrapper | ||
fullWidth={true} | ||
fullHeight={true} | ||
alignItems='flex-start' | ||
justifyContent='flex-start' | ||
padding='0px 16px 16px 16px' | ||
> | ||
<AccountInfoRow | ||
justifyContent='flex-start' | ||
marginBottom={16} | ||
> | ||
<CreateAccountIcon | ||
account={account} | ||
size='huge' | ||
marginRight={16} | ||
/> | ||
<Column alignItems='flex-start'> | ||
<Text | ||
isBold={true} | ||
textColor='primary' | ||
textSize='14px' | ||
> | ||
{account.name} | ||
</Text> | ||
<AddressText | ||
isBold={false} | ||
textColor='secondary' | ||
textSize='12px' | ||
textAlign='left' | ||
> | ||
{account.address} | ||
</AddressText> | ||
</Column> | ||
</AccountInfoRow> | ||
<Row | ||
padding='16px' | ||
justifyContent='flex-start' | ||
> | ||
<Text | ||
isBold={true} | ||
textColor='primary' | ||
textSize='14px' | ||
> | ||
{getLocale('braveWalletViewAddressOn')} | ||
</Text> | ||
</Row> | ||
<ScrollableColumn> | ||
{networksByAccountCoinType.map((network) => ( | ||
<NetworkButton | ||
key={getNetworkId(network)} | ||
network={network} | ||
address={account.accountId.address} | ||
/> | ||
))} | ||
</ScrollableColumn> | ||
</StyledWrapper> | ||
</PopupModal> | ||
) | ||
} |
Oops, something went wrong.