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 206
Calculate collectible price in dutch sell #385
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ffe430c
Merge remote-tracking branch '0x/format-collectible-card-price-basic-…
unjapones d4b9d2e
Calculate current collect price in dutch auction.
unjapones ef8c897
Update 0x.js to get the fix in decodeDutchAuctionData.
unjapones 8761729
Merge branch 'format-collectible-card-price-basic-sell' into calculat…
unjapones d8e8018
Merge remote-tracking branch '0x/erc721' into calculate-collectible-p…
unjapones 69f56b9
Move collectible price chart to its own component.
unjapones b98dfcc
Rename collectible_price_char_card.
unjapones 59983b9
Merge remote-tracking branch '0x/erc721' into calculate-collectible-p…
unjapones de4f029
Improve default REACT_APP_COLLECTIBLE_NAME.
unjapones 36e825b
Use COLLECTIBLE_NAME in collectible_description.tsx.
unjapones 7eb6eef
Show formatted current price instead of collectible last price.
unjapones 58127f4
Fix minor text details in individual collectibe page.
unjapones b3313c6
Format price in trade_button.tsx.
unjapones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"0x.js": "^6.0.8", | ||
"0x.js": "^6.0.9", | ||
"@0x/connect": "^5.0.8", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: This library also had a release, should we update it? |
||
"@0x/web3-wrapper": "^6.0.6", | ||
"connected-react-router": "^6.2.2", | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because 0xProject/0x-monorepo#1814