Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mattupham/fe 1067 portfolio v3 update 0 change values to be green and up #3823

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions packages/web/components/assets/price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { api } from "~/utils/trpc";
import { Sparkline } from "../chart/sparkline";
import { CustomClasses } from "../types";

// 0.01%
const THRESHOLD = 0.0001;
// 0.1%
const THRESHOLD = 0.001;

/** Colored price change text with up/down arrow. */
export const PriceChange: FunctionComponent<
Expand All @@ -23,22 +23,18 @@ export const PriceChange: FunctionComponent<
value?: PricePretty;
} & CustomClasses
> = ({ priceChange, overrideTextClasses = "body1", className, value }) => {
const isBullish = priceChange.toDec().gt(new Dec(THRESHOLD));
const isBearish = priceChange.toDec().lt(new Dec(-THRESHOLD));
const isBullish = priceChange.toDec().gte(new Dec(THRESHOLD));
const isBearish = priceChange.toDec().lte(new Dec(-THRESHOLD));
const isFlat = !isBullish && !isBearish;

console.log("----");
console.log("priceChange.toDec(): ", priceChange.toDec().toString());
console.log("priceChange", priceChange.toDec().toString());

// remove negative symbol since we're using arrows
if (isBearish) {
priceChange = priceChange.mul(new RatePretty(-1));
value = value?.mul(new RatePretty(-1));
}

const priceChangeDisplay = priceChange
.maxDecimals(2)
.maxDecimals(1)
.inequalitySymbol(false)
.toString();

Expand Down Expand Up @@ -77,7 +73,7 @@ export const PriceChange: FunctionComponent<
>
{value !== undefined ? value.toString() + " " : null}

{isFlat ? "0.00%" : formattedPriceChangeDisplay}
{isFlat ? "0.0%" : formattedPriceChangeDisplay}
</div>
</div>
);
Expand Down
Loading