This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from 0xProject/calculate-collectible-price-in…
…-dutch-sell Calculate collectible price in dutch sell
- Loading branch information
Showing
10 changed files
with
233 additions
and
142 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
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
127 changes: 127 additions & 0 deletions
127
src/components/erc721/marketplace/dutch_auction_price_chart_card.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,127 @@ | ||
import { BigNumber } from '0x.js'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { ETH_DECIMALS } from '../../../common/constants'; | ||
import { themeBreakPoints } from '../../../themes/commons'; | ||
import { getCollectiblePrice } from '../../../util/collectibles'; | ||
import { getDutchAuctionData, isDutchAuction } from '../../../util/orders'; | ||
import { convertTimeInSecondsToDaysAndHours } from '../../../util/time_utils'; | ||
import { tokenAmountInUnits } from '../../../util/tokens'; | ||
import { Collectible } from '../../../util/types'; | ||
import { Card } from '../../common/card'; | ||
|
||
import { CollectibleDescriptionInnerTitle } from './collectible_description'; | ||
|
||
const PriceChartContainer = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
@media (min-width: ${themeBreakPoints.xl}) { | ||
flex-direction: row; | ||
} | ||
`; | ||
|
||
const PriceChartPriceAndTime = styled.div` | ||
margin-bottom: 25px; | ||
max-width: 150px; | ||
padding-right: 15px; | ||
padding-top: 25px; | ||
@media (min-width: ${themeBreakPoints.xl}) { | ||
margin-bottom: 0; | ||
} | ||
`; | ||
|
||
export const PriceChartTitle = styled.h5` | ||
color: ${props => props.theme.componentsTheme.cardTitleColor}; | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 1.2; | ||
margin: 0 0 6px; | ||
`; | ||
|
||
export const PriceChartValue = styled.p` | ||
color: #00ae99; | ||
font-size: 14px; | ||
line-height: 1.2; | ||
margin: 0 0 35px; | ||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
`; | ||
|
||
const PriceChartValueNeutral = styled(PriceChartValue)` | ||
color: ${props => props.theme.componentsTheme.cardTitleColor}; | ||
`; | ||
|
||
const PriceChartGraphWrapper = styled.div` | ||
flex-grow: 1; | ||
padding-bottom: 15px; | ||
@media (min-width: ${themeBreakPoints.xl}) { | ||
max-width: 365px; | ||
} | ||
`; | ||
|
||
const PriceChartGraph = styled.div` | ||
background-color: #f5f5f5; | ||
height: 148px; | ||
margin: 0 0 15px; | ||
width: 100%; | ||
`; | ||
|
||
const PriceChartGraphValues = styled.div` | ||
align-items: center; | ||
display: flex; | ||
justify-content: space-between; | ||
`; | ||
|
||
interface Props { | ||
collectible: Collectible; | ||
} | ||
|
||
export const DutchAuctionPriceChartCard = (props: Props) => { | ||
const { collectible } = props; | ||
const { order } = collectible; | ||
if (order === null || !isDutchAuction(order)) { | ||
return null; | ||
} | ||
|
||
const { makerAssetData, expirationTimeSeconds } = order; | ||
const { beginAmount, beginTimeSeconds } = getDutchAuctionData(makerAssetData); | ||
const price = getCollectiblePrice(collectible) as BigNumber; | ||
const { days, hours } = convertTimeInSecondsToDaysAndHours(expirationTimeSeconds.minus(beginTimeSeconds)); | ||
return ( | ||
<Card> | ||
<CollectibleDescriptionInnerTitle>Price Chart</CollectibleDescriptionInnerTitle> | ||
<PriceChartContainer> | ||
<PriceChartPriceAndTime> | ||
<PriceChartTitle>Current Price</PriceChartTitle> | ||
<PriceChartValue>{tokenAmountInUnits(price, ETH_DECIMALS)} ETH</PriceChartValue> | ||
<PriceChartTitle>Time Remaining</PriceChartTitle> | ||
<PriceChartValue>{`${days} Days ${hours} Hrs`}</PriceChartValue> | ||
</PriceChartPriceAndTime> | ||
<PriceChartGraphWrapper> | ||
<PriceChartGraph /> | ||
<PriceChartGraphValues> | ||
<div> | ||
<PriceChartTitle>Start Price</PriceChartTitle> | ||
<PriceChartValueNeutral> | ||
{tokenAmountInUnits(beginAmount, ETH_DECIMALS)} ETH | ||
</PriceChartValueNeutral> | ||
</div> | ||
<div> | ||
<PriceChartTitle>End Price</PriceChartTitle> | ||
<PriceChartValueNeutral> | ||
{tokenAmountInUnits(order.takerAssetAmount, ETH_DECIMALS)} ETH | ||
</PriceChartValueNeutral> | ||
</div> | ||
</PriceChartGraphValues> | ||
</PriceChartGraphWrapper> | ||
</PriceChartContainer> | ||
</Card> | ||
); | ||
}; |
Oops, something went wrong.