| {i + 1} |
diff --git a/src/components/TvlChart/TvlChart.tsx b/src/components/TvlChart/TvlChart.tsx
index 2153e84..2284b25 100644
--- a/src/components/TvlChart/TvlChart.tsx
+++ b/src/components/TvlChart/TvlChart.tsx
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
-import { Box, Skeleton, Text, useBreakpointValue } from "@chakra-ui/react";
+import { Box, Skeleton, Text } from "@chakra-ui/react";
import {
AreaChart,
Area,
@@ -13,6 +13,14 @@ import {
const ACCENT = "#4ae292";
+// Issue #214: a fixed 180px is tall relative to viewport width on small
+// phones; shrink it below the sm breakpoint instead. Expressed as a
+// responsive CSS value (not useBreakpointValue) so the skeleton, empty
+// state and chart all resolve to the same height on first paint — the JS
+// breakpoint hook falls back to "sm" until hydration, which made the
+// skeleton render at 180px and then jump to 140px on phones.
+const CHART_HEIGHT = { base: "140px", sm: "180px" };
+
interface TvlDataPoint {
date: string;
tvl: string;
@@ -26,9 +34,6 @@ interface TvlChartProps {
export default function TvlChart({ poolId }: TvlChartProps) {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(true);
- // Issue #214: a fixed 180px is tall relative to viewport width on small
- // phones; shrink it below the sm breakpoint instead.
- const chartHeight = useBreakpointValue({ base: 140, sm: 180 }, { fallback: "sm" }) ?? 180;
useEffect(() => {
let cancelled = false;
@@ -50,13 +55,13 @@ export default function TvlChart({ poolId }: TvlChartProps) {
}, [poolId]);
if (loading) {
- return ;
+ return ;
}
if (data.length === 0) {
return (
-
-
-
-
-
-
-
-
- new Date(v).toLocaleDateString(undefined, {
- month: "short",
- day: "numeric",
- })
- }
- axisLine={false}
- tickLine={false}
- />
-
- v >= 1_000_000
- ? `$${(v / 1_000_000).toFixed(1)}M`
- : v >= 1_000
- ? `$${(v / 1_000).toFixed(0)}K`
- : `$${v}`
- }
- axisLine={false}
- tickLine={false}
- width={56}
- />
-
- new Date(String(label)).toLocaleDateString(undefined, {
- weekday: "short",
- month: "short",
- day: "numeric",
- })
- }
- formatter={(value) => [`$${Number(value).toLocaleString()}`, "TVL"]}
- />
-
-
-
+
+
+
+
+
+
+
+
+
+
+ new Date(v).toLocaleDateString(undefined, {
+ month: "short",
+ day: "numeric",
+ })
+ }
+ axisLine={false}
+ tickLine={false}
+ />
+
+ v >= 1_000_000
+ ? `$${(v / 1_000_000).toFixed(1)}M`
+ : v >= 1_000
+ ? `$${(v / 1_000).toFixed(0)}K`
+ : `$${v}`
+ }
+ axisLine={false}
+ tickLine={false}
+ width={56}
+ />
+
+ new Date(String(label)).toLocaleDateString(undefined, {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ })
+ }
+ formatter={(value) => [`$${Number(value).toLocaleString()}`, "TVL"]}
+ />
+
+
+
+
);
}
|