-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: tokenRates number => object with price, market cap and 24h change * feat: asset price component * feat: price colors * feat: asset prices in popup assets table * feat: change24h on balances * feat: adjust price colors * feat: asset price change in header of popup asset details * wip: chart * wip: chart * wip: asset price chart * wip: chart * fix: merge * feat: hover value management * chore: changeset * feat: chart adjustments * feat: asset details pages adjustments * feat: 1 block per token on asset details pages * fix: formatPrice * fix: dont render table header if no balance * chore: fix file name * fix: adjustments * chore: cleanup * fix: 25% margin at chart bottom to prevent overlap with buttons * fix: db migration for token rates * fix: comment * chore: delete unused file
- Loading branch information
Showing
32 changed files
with
2,487 additions
and
520 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,5 @@ | ||
--- | ||
"@talismn/balances": minor | ||
--- | ||
|
||
update to new tokenRates shape |
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,5 @@ | ||
--- | ||
"@talismn/token-rates": major | ||
--- | ||
|
||
BREAKING - add market cap and 24h change |
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,5 @@ | ||
--- | ||
"@talismn/util": minor | ||
--- | ||
|
||
formatPrice utility |
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
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,86 @@ | ||
import { bind } from "@react-rxjs/core" | ||
import { TokenId } from "@talismn/chaindata-provider" | ||
import { classNames, formatPrice } from "@talismn/util" | ||
import { FC } from "react" | ||
import { combineLatest, map } from "rxjs" | ||
import { Tooltip, TooltipContent, TooltipTrigger } from "talisman-ui" | ||
|
||
import { getTokenRates$, selectedCurrency$ } from "@ui/state" | ||
|
||
const [useDisplayAssetPrice] = bind((tokenId: TokenId | null | undefined) => | ||
combineLatest([getTokenRates$(tokenId), selectedCurrency$]).pipe( | ||
map(([rates, currency]) => { | ||
const rate = rates?.[currency] | ||
if (!rate) return null | ||
|
||
const compact = formatPrice(rate.price, currency, true) | ||
|
||
const full = formatPrice(rate.price, currency, false) | ||
|
||
const rawChange24h = rate.change24h | ||
? new Intl.NumberFormat(undefined, { | ||
minimumFractionDigits: 1, | ||
style: "percent", | ||
signDisplay: "always", | ||
}).format(rate.change24h / 100) | ||
: undefined | ||
|
||
// we dont want a sign (which is used for color check) if change displays as +0.0% or -0.0% | ||
const change24h = rawChange24h?.length | ||
? rawChange24h.slice(1) === "0.0%" | ||
? "0.0%" | ||
: rawChange24h | ||
: undefined | ||
|
||
return { | ||
compact, | ||
full, | ||
change24h, | ||
} | ||
}), | ||
), | ||
) | ||
|
||
export const AssetPrice: FC<{ | ||
tokenId: TokenId | null | undefined | ||
as?: "div" | "span" | ||
className?: string | ||
priceClassName?: string | ||
changeClassName?: string | ||
noTooltip?: boolean | ||
noChange?: boolean | ||
}> = ({ | ||
as: Container = "div", | ||
tokenId, | ||
noTooltip, | ||
noChange, | ||
className, | ||
priceClassName, | ||
changeClassName, | ||
}) => { | ||
const price = useDisplayAssetPrice(tokenId) | ||
|
||
if (!price) return null | ||
|
||
return ( | ||
<Tooltip placement="bottom-start"> | ||
<TooltipTrigger asChild> | ||
<Container className={classNames("whitespace-nowrap", className)}> | ||
<span className={priceClassName}>{price.compact} </span> | ||
{!noChange && price.change24h ? ( | ||
<span | ||
className={classNames( | ||
price.change24h.startsWith("+") && "text-price-up", | ||
price.change24h.startsWith("-") && "text-price-down", | ||
changeClassName, | ||
)} | ||
> | ||
{price.change24h} | ||
</span> | ||
) : null} | ||
</Container> | ||
</TooltipTrigger> | ||
{!noTooltip && <TooltipContent>{price.full}</TooltipContent>} | ||
</Tooltip> | ||
) | ||
} |
Oops, something went wrong.