This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new component SurplusComponent * Added calculation for trade surplus getTradeSurplus * Added surplus to fills table * Refactored OrderSurplusDisplay to use SurplusComponent * Fixed issue with surplus tooltip * Removed buy amount value by mistake 😅
- Loading branch information
1 parent
31e5607
commit 052a822
Showing
5 changed files
with
111 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import styled, { css, FlattenSimpleInterpolation } from 'styled-components' | ||
import { formatPercentage, Surplus } from 'utils' | ||
import { TokenErc20 } from '@gnosis.pm/dex-js' | ||
import { TokenAmount } from 'components/token/TokenAmount' | ||
|
||
const Percentage = styled.span` | ||
color: ${({ theme }): string => theme.green}; | ||
` | ||
|
||
const Amount = styled.span<{ showHiddenSection: boolean; strechHiddenSection?: boolean }>` | ||
display: ${({ showHiddenSection }): string => (showHiddenSection ? 'flex' : 'none')}; | ||
${({ strechHiddenSection }): FlattenSimpleInterpolation | false | undefined => | ||
strechHiddenSection && | ||
css` | ||
width: 3.4rem; | ||
display: inline-block; | ||
justify-content: end; | ||
`} | ||
` | ||
|
||
export type SurplusComponentProps = { | ||
surplus: Surplus | null | ||
token: TokenErc20 | null | ||
showHidden?: boolean | ||
className?: string | ||
} | ||
|
||
export const SurplusComponent: React.FC<SurplusComponentProps> = (props) => { | ||
const { surplus, token, showHidden, className } = props | ||
|
||
if (!surplus || !token) { | ||
return null | ||
} | ||
|
||
const { percentage, amount } = surplus | ||
|
||
return ( | ||
<div className={className}> | ||
<Percentage>{formatPercentage(percentage)}</Percentage> | ||
<Amount showHiddenSection={!!showHidden}> | ||
<TokenAmount amount={amount} token={token} /> | ||
</Amount> | ||
</div> | ||
) | ||
} |
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
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