Skip to content

Commit

Permalink
extract new component. add use effect
Browse files Browse the repository at this point in the history
  • Loading branch information
joeizang committed Oct 20, 2023
1 parent 3ee974d commit fc85598
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libs/remix-ui/run-tab/src/lib/components/account.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// eslint-disable-next-line no-use-before-define
import React, {useEffect, useState, useRef} from 'react'
import {FormattedMessage, useIntl} from 'react-intl'
import {CopyToClipboard} from '@remix-ui/clipboard'
import {AccountProps} from '../types'
import {PassphrasePrompt} from './passphrase'
import {CustomTooltip} from '@remix-ui/helper'
import CopyIcon from './copyToClipboard'

export function AccountUI(props: AccountProps) {
const {selectedAccount, loadedAccounts} = props.accounts
Expand Down Expand Up @@ -214,9 +214,10 @@ export function AccountUI(props: AccountProps) {
</option>
))}
</select>
<div style={{marginLeft: -5}}>
<CopyToClipboard tip={intl.formatMessage({id: 'udapp.copyAccount'})} content={selectedAccount} direction="top" />
</div>
<CopyIcon
selectedAccount={selectedAccount}
intl={intl}
/>
<CustomTooltip placement={'top-start'} tooltipClasses="text-nowrap" tooltipId="remixSignMsgTooltip" tooltipText={<FormattedMessage id="udapp.signMsgUsingAccount" />}>
<i id="remixRunSignMsg" data-id="settingsRemixRunSignMsg" className="mx-1 fas fa-edit udapp_icon" aria-hidden="true" onClick={signMessage}></i>
</CustomTooltip>
Expand Down
20 changes: 20 additions & 0 deletions libs/remix-ui/run-tab/src/lib/components/copyToClipboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import { CopyToClipboard } from '@remix-ui/clipboard'
import React, { useEffect, useState } from 'react'

export default function CopyIcon({ selectedAccount, intl}) {

useEffect(() => {
}, [selectedAccount])

return (
<div style={{marginLeft: -5}}>
<CopyToClipboard tip={intl.formatMessage({id: 'udapp.copyAccount'})} content={selectedAccount} direction="top" />
</div>
)
}
declare global {
interface Window {
ethereum: import('ethers').providers.ExternalProvider & any
}
}

0 comments on commit fc85598

Please sign in to comment.