From 1758588250e5096dc9f73301e1da7e2fb2dca7af Mon Sep 17 00:00:00 2001 From: ghzhost Date: Fri, 4 Sep 2026 23:42:32 +0000 Subject: [PATCH] fix(tvl-chart): add theme-aware colors for Recharts tooltips and axes (closes #312) --- src/components/TvlChart/TvlChart.tsx | 37 ++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/TvlChart/TvlChart.tsx b/src/components/TvlChart/TvlChart.tsx index 99c900a..c5642e4 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, useBreakpointValue, useColorModeValue } from "@chakra-ui/react"; import { AreaChart, Area, @@ -12,7 +12,8 @@ import { } from "recharts"; import { sorobanService } from "@/lib/soroban"; -const ACCENT = "#4ae292"; +const ACCENT_DARK = "#4ae292"; +const ACCENT_LIGHT = "#0f7a4e"; interface TvlDataPoint { date: string; @@ -31,6 +32,12 @@ export default function TvlChart({ poolId }: TvlChartProps) { // phones; shrink it below the sm breakpoint instead. const chartHeight = useBreakpointValue({ base: 140, sm: 180 }, { fallback: "sm" }) ?? 180; + const accentColor = useColorModeValue(ACCENT_LIGHT, ACCENT_DARK); + const axisTickColor = useColorModeValue("#6b7280", "#A2A2A2"); + const tooltipBg = useColorModeValue("#ffffff", "#171717"); + const tooltipBorder = useColorModeValue("#e2e8f0", "#333333"); + const tooltipText = useColorModeValue("#171717", "#ffffff"); + useEffect(() => { let cancelled = false; setLoading(true); @@ -77,13 +84,13 @@ export default function TvlChart({ poolId }: TvlChartProps) { - - + + new Date(v).toLocaleDateString(undefined, { month: "short", @@ -94,7 +101,7 @@ export default function TvlChart({ poolId }: TvlChartProps) { tickLine={false} /> v >= 1_000_000 ? `$${(v / 1_000_000).toFixed(1)}M` @@ -108,10 +115,20 @@ export default function TvlChart({ poolId }: TvlChartProps) { /> new Date(String(label)).toLocaleDateString(undefined, { @@ -125,11 +142,11 @@ export default function TvlChart({ poolId }: TvlChartProps) {