From 2a24f6f958865336b4d2c008c24b3a62a7acf0de Mon Sep 17 00:00:00 2001
From: Jessica Xiao <15721063+essj@users.noreply.github.com>
Date: Tue, 11 Feb 2025 20:16:24 -0700
Subject: [PATCH] feat: Market summary section
---
.../MarketSummary/MarketSummary.tsx | 11 ++++
.../MarketSummary/MarketSummaryCard.tsx | 65 +++++++++++++++++++
.../earn/components/MarketSummary/index.ts | 1 +
.../sections/TableSection/TableSection.tsx | 6 ++
4 files changed, 83 insertions(+)
create mode 100644 apps/flame-defi/app/earn/components/MarketSummary/MarketSummary.tsx
create mode 100644 apps/flame-defi/app/earn/components/MarketSummary/MarketSummaryCard.tsx
create mode 100644 apps/flame-defi/app/earn/components/MarketSummary/index.ts
diff --git a/apps/flame-defi/app/earn/components/MarketSummary/MarketSummary.tsx b/apps/flame-defi/app/earn/components/MarketSummary/MarketSummary.tsx
new file mode 100644
index 0000000..35ab13e
--- /dev/null
+++ b/apps/flame-defi/app/earn/components/MarketSummary/MarketSummary.tsx
@@ -0,0 +1,11 @@
+import { MarketSummaryCard } from "./MarketSummaryCard";
+
+export const MarketSummary = () => {
+ return (
+
+ {/* TODO: Use fetched values. */}
+
+
+
+ );
+};
diff --git a/apps/flame-defi/app/earn/components/MarketSummary/MarketSummaryCard.tsx b/apps/flame-defi/app/earn/components/MarketSummary/MarketSummaryCard.tsx
new file mode 100644
index 0000000..68d7230
--- /dev/null
+++ b/apps/flame-defi/app/earn/components/MarketSummary/MarketSummaryCard.tsx
@@ -0,0 +1,65 @@
+import { Skeleton } from "@repo/ui/shadcn-primitives";
+import Big from "big.js";
+import React, { useEffect, useState } from "react";
+import { FormattedNumber } from "react-intl";
+import { Card } from "../Card";
+
+interface MarketSummaryCardProps {
+ label: React.ReactNode;
+ value: number;
+}
+
+export const MarketSummaryCard = ({ label, value }: MarketSummaryCardProps) => {
+ const [count, setCount] = useState(null);
+
+ useEffect(() => {
+ let isMounted = true;
+
+ const counter = (minimum: number, maximum: number) => {
+ for (let count = minimum; count <= maximum; count++) {
+ setTimeout(() => {
+ if (isMounted) {
+ setCount(count);
+ }
+ }, 5000);
+ }
+ };
+
+ const minimum = value - 10000;
+ counter(minimum < 0 ? 0 : minimum, value);
+
+ return () => {
+ isMounted = false;
+ };
+ }, [value]);
+
+ return (
+
+ {label}
+
+
+ {/* Reserve space for animation to prevent card size increasing with counter value. */}
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/apps/flame-defi/app/earn/components/MarketSummary/index.ts b/apps/flame-defi/app/earn/components/MarketSummary/index.ts
new file mode 100644
index 0000000..bae18eb
--- /dev/null
+++ b/apps/flame-defi/app/earn/components/MarketSummary/index.ts
@@ -0,0 +1 @@
+export { MarketSummary } from "./MarketSummary";
diff --git a/apps/flame-defi/app/earn/sections/TableSection/TableSection.tsx b/apps/flame-defi/app/earn/sections/TableSection/TableSection.tsx
index 7f124bf..cd91ffa 100644
--- a/apps/flame-defi/app/earn/sections/TableSection/TableSection.tsx
+++ b/apps/flame-defi/app/earn/sections/TableSection/TableSection.tsx
@@ -1,4 +1,5 @@
import { Card } from "earn/components/Card";
+import { MarketSummary } from "earn/components/MarketSummary";
import { Table, TablePagination, TableSearch } from "earn/components/Table";
import { useTable } from "earn/hooks/useTable";
@@ -7,6 +8,11 @@ export const TableSection = () => {
return (