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

Remove change value #164

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
29 changes: 10 additions & 19 deletions src/pages/trade/ui/summary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ReactNode } from 'react';
import cn from 'clsx';
import { useAutoAnimate } from '@formkit/auto-animate/react';
import { Text } from '@penumbra-zone/ui/Text';
import { Skeleton } from '@/shared/ui/skeleton';
Expand Down Expand Up @@ -64,24 +63,16 @@ export const Summary = () => {
</Text>
</SummaryCard>
<SummaryCard title='24h Change' loading={isLoading}>
{data && 'noData' in data && (
{data && 'change' in data ? (
<Text detail color={getColor(data)}>
{getTextSign(data)}
{data.change.percent}%
</Text>
) : (
<Text detail color='text.primary'>
-
</Text>
)}
{data && 'change' in data && (
<div className={cn('flex items-center gap-1', getColor(data, false))}>
<Text detail>{round({ value: data.change.value, decimals: 6 })}</Text>
<span
className={cn('flex h-4 px-1 rounded-full text-success-dark', getColor(data, true))}
>
<Text detail>
{getTextSign(data)}
{data.change.percent}%
</Text>
</span>
</div>
)}
</SummaryCard>
<SummaryCard title='24h High' loading={isLoading}>
<Text detail color='text.primary'>
Expand Down Expand Up @@ -123,12 +114,12 @@ const getTextSign = (res: SummaryDataResponse) => {
return '';
};

const getColor = (res: SummaryDataResponse, isBg = false): string => {
const getColor = (res: SummaryDataResponse) => {
if (res.change.sign === 'positive') {
return isBg ? 'bg-success-light' : 'text-success-light';
return 'success.light';
}
if (res.change.sign === 'negative') {
return isBg ? 'bg-destructive-light' : 'text-destructive-light';
return 'destructive.light';
}
return isBg ? 'bg-neutral-light' : 'text-neutral-light';
return 'neutral.light';
};
1 change: 0 additions & 1 deletion src/shared/api/server/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export async function GET(req: NextRequest): Promise<NextResponse<SummaryRespons

const priceDiff = summary.price - summary.price_then;
const change = {
value: calculateDisplayPrice(priceDiff, baseAssetMetadata, quoteAssetMetadata),
sign: priceDiffLabel(priceDiff),
percent:
summary.price === 0
Expand Down
1 change: 0 additions & 1 deletion src/shared/api/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { JsonValue } from '@bufbuild/protobuf';

export interface ChangeData {
sign: 'positive' | 'negative' | 'neutral';
value: number;
percent: string;
}

Expand Down