Skip to content

Commit 69b1241

Browse files
author
StellarStream Dev
committed
fix: resolve Badge dark theme colors, chart sort NaN bug, and use-ref TS error
1 parent 67dc4a1 commit 69b1241

3 files changed

Lines changed: 68 additions & 46 deletions

File tree

frontend/components/stream/balance-projection-chart.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ export function BalanceProjectionChart({ stream }: BalanceProjectionChartProps)
4040
const endTime = new Date(stream.endTime).getTime();
4141
const now = Date.now();
4242
const totalDuration = endTime - startTime;
43-
const points: { time: string; streamed: number; projected?: number }[] = [];
43+
type ChartPoint = {
44+
time: string;
45+
timeMs: number;
46+
streamed: number | null;
47+
projected: number | null;
48+
};
49+
const points: ChartPoint[] = [];
4450

4551
// Generate ~12 time points across the stream duration
4652
const intervals = 12;
@@ -58,12 +64,13 @@ export function BalanceProjectionChart({ stream }: BalanceProjectionChartProps)
5864
month: "short",
5965
day: "numeric",
6066
}),
61-
streamed: isPast ? expectedStreamed : undefined as unknown as number,
62-
projected: !isPast ? expectedStreamed : undefined,
67+
timeMs: t,
68+
streamed: isPast ? expectedStreamed : null,
69+
projected: !isPast ? expectedStreamed : null,
6370
});
6471
}
6572

66-
// Add current point
73+
// Add current point (always in the "past" so it renders on the streamed line)
6774
const currentElapsed = now - startTime;
6875
const currentStreamed = Math.min(
6976
currentElapsed * stream.ratePerSecond,
@@ -72,14 +79,13 @@ export function BalanceProjectionChart({ stream }: BalanceProjectionChartProps)
7279

7380
points.push({
7481
time: "Now",
82+
timeMs: now,
7583
streamed: currentStreamed,
84+
projected: null,
7685
});
7786

78-
// Sort by time
79-
return points.sort(
80-
(a, b) =>
81-
new Date(a.time).getTime() - new Date(b.time).getTime(),
82-
);
87+
// Sort by timestamp to ensure correct chronological order
88+
return points.sort((a, b) => a.timeMs - b.timeMs);
8389
}, [stream]);
8490

8591
const CustomTooltip = ({

frontend/components/ui/Badge.tsx

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
1-
'use client';
1+
"use client";
22

3-
import React from 'react';
4-
import { cn } from '@/lib/utils';
3+
import React from "react";
4+
import { cn } from "@/lib/utils";
55

66
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
7-
variant?: 'default' | 'success' | 'warning' | 'error' | 'info' | 'neutral';
8-
size?: 'sm' | 'md' | 'lg';
7+
variant?: "default" | "success" | "warning" | "error" | "info" | "neutral";
8+
size?: "sm" | "md" | "lg";
99
outline?: boolean;
1010
dot?: boolean;
1111
}
1212

1313
/**
14-
* Badge component for status indicators
14+
* Badge component for status indicators — moon-theme (dark) optimized.
1515
* @example
1616
* <Badge variant="success">Active</Badge>
1717
* <Badge variant="error" outline>Failed</Badge>
1818
*/
1919
export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
20-
({ variant = 'default', size = 'md', outline = false, dot = false, className, children, ...props }, ref) => {
20+
(
21+
{
22+
variant = "default",
23+
size = "md",
24+
outline = false,
25+
dot = false,
26+
className,
27+
children,
28+
...props
29+
},
30+
ref,
31+
) => {
2132
const variantStyles = {
2233
default: outline
23-
? 'bg-transparent text-neutral-700 border border-neutral-300'
24-
: 'bg-neutral-200 text-neutral-800',
34+
? "bg-transparent text-white/40 border border-white/10"
35+
: "bg-white/10 text-white/70",
2536
success: outline
26-
? 'bg-transparent text-green-700 border border-green-300'
27-
: 'bg-green-100 text-green-800',
37+
? "bg-transparent text-emerald-400 border border-emerald-500/30"
38+
: "bg-emerald-500/10 text-emerald-400",
2839
warning: outline
29-
? 'bg-transparent text-amber-700 border border-amber-300'
30-
: 'bg-amber-100 text-amber-800',
40+
? "bg-transparent text-amber-400 border border-amber-500/30"
41+
: "bg-amber-500/10 text-amber-400",
3142
error: outline
32-
? 'bg-transparent text-red-700 border border-red-300'
33-
: 'bg-red-100 text-red-800',
43+
? "bg-transparent text-red-400 border border-red-500/30"
44+
: "bg-red-500/10 text-red-400",
3445
info: outline
35-
? 'bg-transparent text-sky-700 border border-sky-300'
36-
: 'bg-sky-100 text-sky-800',
46+
? "bg-transparent text-sky-400 border border-sky-500/30"
47+
: "bg-sky-500/10 text-sky-400",
3748
neutral: outline
38-
? 'bg-transparent text-neutral-600 border border-neutral-300'
39-
: 'bg-neutral-100 text-neutral-700',
49+
? "bg-transparent text-white/30 border border-white/10"
50+
: "bg-white/5 text-white/50",
4051
};
4152

4253
const sizeStyles = {
43-
sm: 'px-2 py-0.5 text-xs font-medium',
44-
md: 'px-2.5 py-0.5 text-sm font-medium',
45-
lg: 'px-3 py-1 text-base font-medium',
54+
sm: "px-2 py-0.5 text-[10px] font-medium",
55+
md: "px-2.5 py-0.5 text-xs font-medium",
56+
lg: "px-3 py-1 text-sm font-medium",
4657
};
4758

48-
const baseStyles = 'inline-flex items-center gap-1.5 rounded-full whitespace-nowrap';
59+
const baseStyles =
60+
"inline-flex items-center gap-1.5 rounded-full whitespace-nowrap";
4961

5062
return (
5163
<span
@@ -56,24 +68,28 @@ export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
5668
{dot && (
5769
<span
5870
className={cn(
59-
'inline-block rounded-full',
60-
variant === 'success'
61-
? 'bg-green-600'
62-
: variant === 'warning'
63-
? 'bg-amber-600'
64-
: variant === 'error'
65-
? 'bg-red-600'
66-
: variant === 'info'
67-
? 'bg-sky-600'
68-
: 'bg-neutral-600',
69-
size === 'sm' ? 'w-1.5 h-1.5' : size === 'lg' ? 'w-2.5 h-2.5' : 'w-2 h-2'
71+
"inline-block rounded-full",
72+
variant === "success"
73+
? "bg-emerald-400"
74+
: variant === "warning"
75+
? "bg-amber-400"
76+
: variant === "error"
77+
? "bg-red-400"
78+
: variant === "info"
79+
? "bg-sky-400"
80+
: "bg-white/30",
81+
size === "sm"
82+
? "h-1.5 w-1.5"
83+
: size === "lg"
84+
? "h-2.5 w-2.5"
85+
: "h-2 w-2",
7086
)}
7187
/>
7288
)}
7389
{children}
7490
</span>
7591
);
76-
}
92+
},
7793
);
7894

79-
Badge.displayName = 'Badge';
95+
Badge.displayName = "Badge";

frontend/lib/hooks/use-transaction-feed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const useTransactionFeed = (): UseTransactionFeedReturn => {
4747
const [socket, setSocket] = useState<Socket | null>(null);
4848
const reconnectTimeoutRef = useRef<NodeJS.Timeout | null>(null);
4949

50-
const attemptReconnectRef = useRef<(attempt?: number) => void>();
50+
const attemptReconnectRef = useRef<((attempt?: number) => void) | null>(null);
5151

5252
/**
5353
* Attempt to reconnect with exponential back-off.

0 commit comments

Comments
 (0)