This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): cleanup route summary display
- Loading branch information
Showing
5 changed files
with
65 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Flex } from 'rebass/styled-components' | ||
import { useIntl } from 'react-intl' | ||
import { CoinBig } from '@zap/utils/coin' | ||
import { getDisplayNodeName } from 'reducers/payment/utils' | ||
import { Truncate } from 'components/Util' | ||
import ArrowRight from 'components/Icon/ArrowRight' | ||
import messages from './messages' | ||
|
||
const HtlcHops = ({ hops, ...rest }) => { | ||
const { formatMessage, formatNumber } = useIntl() | ||
return ( | ||
<Flex {...rest} flexDirection="column"> | ||
{hops.map((hop, index) => { | ||
const displayName = getDisplayNodeName(hop) | ||
const hasFee = CoinBig(hop.feeMsat).gt(0) | ||
const isLast = index === hops.length - 1 | ||
const multiHop = hops.length > 1 | ||
return ( | ||
<Flex | ||
key={hop.pubKey} | ||
alignItems="center" | ||
className="hint--top-left" | ||
color={isLast ? null : 'grey'} | ||
data-hint={formatMessage( | ||
{ ...messages[hasFee ? 'htlc_hop_fee' : 'htlc_hop_no_fee'] }, | ||
{ hopFee: formatNumber(hop.feeMsat), cryptoUnitName: 'msat' } | ||
)} | ||
justifyContent="flex-end" | ||
my={1} | ||
> | ||
{multiHop && ( | ||
<Flex alignItems="center" color="gray" mx={2} opacity={isLast ? 1 : 0.5}> | ||
<ArrowRight /> | ||
</Flex> | ||
)} | ||
<Truncate maxlen={50} text={displayName} /> | ||
</Flex> | ||
) | ||
})} | ||
</Flex> | ||
) | ||
} | ||
|
||
HtlcHops.propTypes = { | ||
hops: PropTypes.array.isRequired, | ||
} | ||
|
||
export default HtlcHops |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export PaymentModal from './PaymentModal' | ||
export Route from './Route' | ||
export Htlc from './Htlc' | ||
export HtlcHops from './HtlcHops' |
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