From 8fbcdf0564f256c844edfd4cabd0f308d191e65f Mon Sep 17 00:00:00 2001 From: mokelgit Date: Thu, 30 May 2024 15:14:55 -0400 Subject: [PATCH 1/6] Moving single chains components to single chains folder for organization --- app/(layout)/chains/[chain]/page.tsx | 4 +- .../layout/{ => SingleChains}/ChainChart.tsx | 258 ++++++++++-------- .../{ => SingleChains}/ChainSectionHead.tsx | 0 3 files changed, 139 insertions(+), 123 deletions(-) rename components/layout/{ => SingleChains}/ChainChart.tsx (92%) rename components/layout/{ => SingleChains}/ChainSectionHead.tsx (100%) diff --git a/app/(layout)/chains/[chain]/page.tsx b/app/(layout)/chains/[chain]/page.tsx index 409948e8..0d661686 100644 --- a/app/(layout)/chains/[chain]/page.tsx +++ b/app/(layout)/chains/[chain]/page.tsx @@ -4,7 +4,7 @@ import useSWR, { preload } from "swr"; import { useSWRConfig } from "swr"; import { MasterResponse } from "@/types/api/MasterResponse"; import { AllChains, AllChainsByKeys, AllChainsByUrlKey } from "@/lib/chains"; -import ChainChart from "@/components/layout/ChainChart"; +import ChainChart from "@/components/layout/SingleChains/ChainChart"; import Heading from "@/components/layout/Heading"; import Subheading from "@/components/layout/Subheading"; import { Icon } from "@iconify/react"; @@ -25,7 +25,7 @@ import { Chains, } from "@/types/api/ChainOverviewResponse"; import { getFundamentalsByKey } from "@/lib/navigation"; -import ChainSectionHead from "@/components/layout/ChainSectionHead"; +import ChainSectionHead from "@/components/layout/SingleChains/ChainSectionHead"; import { useMemo, useState, useEffect, useCallback, useRef } from "react"; import { useSessionStorage, useLocalStorage } from "usehooks-ts"; import { notFound } from "next/navigation"; diff --git a/components/layout/ChainChart.tsx b/components/layout/SingleChains/ChainChart.tsx similarity index 92% rename from components/layout/ChainChart.tsx rename to components/layout/SingleChains/ChainChart.tsx index 1f723940..37904c80 100644 --- a/components/layout/ChainChart.tsx +++ b/components/layout/SingleChains/ChainChart.tsx @@ -43,17 +43,21 @@ import { useUIContext } from "@/contexts/UIContext"; import { ChainURLs, MasterURL } from "@/lib/urls"; import { MasterResponse } from "@/types/api/MasterResponse"; import useSWR, { preload } from "swr"; -import ChartWatermark from "./ChartWatermark"; +import ChartWatermark from "@/components/layout/ChartWatermark"; import { ChainsData } from "@/types/api/ChainResponse"; import { IS_DEVELOPMENT, IS_PREVIEW, IS_PRODUCTION } from "@/lib/helpers"; -import ChainSectionHead from "@/components/layout/ChainSectionHead"; +import ChainSectionHead from "@/components/layout/SingleChains/ChainSectionHead"; import { TopRowContainer, TopRowChild, TopRowParent, } from "@/components/layout/TopRow"; import "@/app/highcharts.axis.css"; -import { Tooltip, TooltipContent, TooltipTrigger } from "./Tooltip"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/layout/Tooltip"; import { useSWRConfig } from "swr"; const COLORS = { @@ -289,7 +293,7 @@ export default function ChainChart({ Object.keys(item.metrics).forEach((key) => { maxUnixtimes.push( item.metrics[key].daily.data[ - item.metrics[key].daily.data.length - 1 + item.metrics[key].daily.data.length - 1 ][0], ); }); @@ -667,17 +671,20 @@ export default function ChainChart({ // if (series.name === item.chain_name) { return `
-
+
-
${prefix}
+
${prefix}
${parseFloat(value).toLocaleString("en-GB", { - minimumFractionDigits: decimals, - maximumFractionDigits: decimals, - })} -
${suffix}
+ minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + })} +
${suffix}
`; // } else { @@ -1050,12 +1057,12 @@ export default function ChainChart({ [ 0, AllChainsByKeys[data[0].chain_id].colors[theme ?? "dark"][0] + - "33", + "33", ], [ 1, AllChainsByKeys[data[0].chain_id].colors[theme ?? "dark"][1] + - "33", + "33", ], ], }, @@ -1255,16 +1262,16 @@ export default function ChainChart({ const seriesData = item.metrics[key]?.daily.types.includes("eth") ? showUsd ? item.metrics[key].daily.data.map((d) => [ - d[0], - d[item.metrics[key].daily.types.indexOf("usd")], - ]) + d[0], + d[item.metrics[key].daily.types.indexOf("usd")], + ]) : item.metrics[key].daily.data.map((d) => [ - d[0], - showGwei(key) - ? d[item.metrics[key].daily.types.indexOf("eth")] * - 1000000000 - : d[item.metrics[key].daily.types.indexOf("eth")], - ]) + d[0], + showGwei(key) + ? d[item.metrics[key].daily.types.indexOf("eth")] * + 1000000000 + : d[item.metrics[key].daily.types.indexOf("eth")], + ]) : item.metrics[key]?.daily.data.map((d) => [d[0], d[1]]); const seriesTypes = item.metrics[key]?.daily.types; @@ -1287,16 +1294,16 @@ export default function ChainChart({ data: item.metrics[key]?.daily.types.includes("eth") ? showUsd ? item.metrics[key].daily.data.map((d) => [ - d[0], - d[item.metrics[key].daily.types.indexOf("usd")], - ]) + d[0], + d[item.metrics[key].daily.types.indexOf("usd")], + ]) : item.metrics[key].daily.data.map((d) => [ - d[0], - showGwei(key) - ? d[item.metrics[key].daily.types.indexOf("eth")] * - 1000000000 - : d[item.metrics[key].daily.types.indexOf("eth")], - ]) + d[0], + showGwei(key) + ? d[item.metrics[key].daily.types.indexOf("eth")] * + 1000000000 + : d[item.metrics[key].daily.types.indexOf("eth")], + ]) : item.metrics[key]?.daily.data.map((d) => [d[0], d[1]]), showInLegend: false, marker: { @@ -1322,13 +1329,13 @@ export default function ChainChart({ [ 0, AllChainsByKeys[item.chain_id].colors[ - theme ?? "dark" + theme ?? "dark" ][0] + "33", ], [ 1, AllChainsByKeys[item.chain_id].colors[ - theme ?? "dark" + theme ?? "dark" ][1] + "33", ], ], @@ -1477,16 +1484,18 @@ export default function ChainChart({ `}
Compare to
{compChain && (
@@ -1569,10 +1581,11 @@ export default function ChainChart({
@@ -1752,8 +1766,8 @@ export default function ChainChart({ .map((key, i) => { const isAllZeroValues = data[0].metrics[key] ? data[0].metrics[key].daily.data.every( - (d) => d[1] === 0, - ) + (d) => d[1] === 0, + ) : false; if (!Object.keys(data[0].metrics).includes(key)) @@ -1792,54 +1806,56 @@ export default function ChainChart({ {Object.keys(data[0].metrics).includes( key, ) && ( - - )} + + )}
{!zoomed ? (key === "market_cap" || - key === "txcosts") && ( -
- ) + >
+ ) : (key === "profit" || key === "txcosts") && - intervalShown && ( -
-
- {new Date( - intervalShown.min, - ).toLocaleDateString("en-GB", { - timeZone: "UTC", - month: "short", - day: "numeric", - year: "numeric", - })} -
-
- {new Date( - intervalShown.max, - ).toLocaleDateString("en-GB", { - timeZone: "UTC", - month: "short", - day: "numeric", - year: "numeric", - })} + > +
+ {new Date( + intervalShown.min, + ).toLocaleDateString("en-GB", { + timeZone: "UTC", + month: "short", + day: "numeric", + year: "numeric", + })} +
+
+ {new Date( + intervalShown.max, + ).toLocaleDateString("en-GB", { + timeZone: "UTC", + month: "short", + day: "numeric", + year: "numeric", + })} +
-
- )} + )}
) : (
@@ -1892,10 +1908,10 @@ export default function ChainChart({ ...options.chart, animation: isAnimate ? { - duration: 500, - delay: 0, - easing: "easeOutQuint", - } + duration: 500, + delay: 0, + easing: "easeOutQuint", + } : false, index: enabledFundamentalsKeys.indexOf(key), margin: zoomed ? zoomedMargin : defaultMargin, @@ -1953,7 +1969,7 @@ export default function ChainChart({ if (chart.series.length > 0) { const lastPoint = chart.series[0].points[ - chart.series[0].points.length - 1 + chart.series[0].points.length - 1 ]; if (lastPoint && lastPoint.plotY) { primaryLineEndPos = @@ -1963,7 +1979,7 @@ export default function ChainChart({ if (chart.series.length > 1) { const lastPoint = chart.series[1].points[ - chart.series[1].points.length - 1 + chart.series[1].points.length - 1 ]; if ( lastPoint && @@ -1985,7 +2001,7 @@ export default function ChainChart({ (series, seriesIndex) => { const lastPoint = series.points[ - series.points.length - 1 + series.points.length - 1 ]; if (!lastPoint || !lastPoint.plotY) @@ -2120,7 +2136,7 @@ export default function ChainChart({ stroke: AllChainsByKeys[series.name] .colors[ - theme ?? "dark" + theme ?? "dark" ][0], "stroke-width": 1, "stroke-dasharray": 2, @@ -2188,7 +2204,7 @@ export default function ChainChart({ .circle( linesXPos, chart.plotTop - - (seriesIndex === 0 ? 24 : 0), + (seriesIndex === 0 ? 24 : 0), 3, ) .attr({ diff --git a/components/layout/ChainSectionHead.tsx b/components/layout/SingleChains/ChainSectionHead.tsx similarity index 100% rename from components/layout/ChainSectionHead.tsx rename to components/layout/SingleChains/ChainSectionHead.tsx From af166cca8f98fcf488289b9ea0714f3e93a21ed3 Mon Sep 17 00:00:00 2001 From: mokelgit Date: Thu, 30 May 2024 15:23:49 -0400 Subject: [PATCH 2/6] improved shadow behavior --- app/(layout)/chains/[chain]/page.tsx | 4 ++-- components/layout/SingleChains/ChainSectionHead.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/(layout)/chains/[chain]/page.tsx b/app/(layout)/chains/[chain]/page.tsx index 0d661686..c110da1f 100644 --- a/app/(layout)/chains/[chain]/page.tsx +++ b/app/(layout)/chains/[chain]/page.tsx @@ -753,8 +753,8 @@ const Chain = ({ params }: { params: any }) => { isMobile ? "opacity-0" : isSidebarOpen - ? "xl:opacity-0 md:opacity-100 " - : "lg:opacity-0 md:opacity-100" + ? "2xl:opacity-0 md:opacity-100 " + : "xl:opacity-0 md:opacity-100" }`} style={{ background: diff --git a/components/layout/SingleChains/ChainSectionHead.tsx b/components/layout/SingleChains/ChainSectionHead.tsx index 7f6c4334..1b841620 100644 --- a/components/layout/SingleChains/ChainSectionHead.tsx +++ b/components/layout/SingleChains/ChainSectionHead.tsx @@ -89,8 +89,8 @@ const ChainSectionHead = ({ : "xl:opacity-0 md:opacity-100" : title === "Technology" ? isSidebarOpen - ? "xl:opacity-0 md:opacity-100 " - : "lg:opacity-0 md:opacity-100" + ? "2xl:opacity-0 md:opacity-100 " + : "xl:opacity-0 md:opacity-100" : "" }`} style={{ From dd53d3cda57107ece352b73aa0f340860e482897 Mon Sep 17 00:00:00 2001 From: mokelgit Date: Thu, 30 May 2024 16:28:53 -0400 Subject: [PATCH 3/6] further progress on category metrics bar rework --- components/layout/CategoryBar.tsx | 180 ++++++++++++++++++++++++++ components/layout/CategoryMetrics.tsx | 83 ++---------- 2 files changed, 193 insertions(+), 70 deletions(-) create mode 100644 components/layout/CategoryBar.tsx diff --git a/components/layout/CategoryBar.tsx b/components/layout/CategoryBar.tsx new file mode 100644 index 00000000..a2143b73 --- /dev/null +++ b/components/layout/CategoryBar.tsx @@ -0,0 +1,180 @@ +import Container from "./Container"; +import { + useMemo, + useState, + useEffect, + useRef, + ReactNode, + useCallback, +} from "react"; +import { Icon } from "@iconify/react"; +import { CategoryComparisonResponseData } from "@/types/api/CategoryComparisonResponse"; + +const CategoryBar = ({ + data, + categories, + querySubcategories, + selectedCategory, + setSelectedCategory, + checkSubcategory, + formatSubcategories, + checkAllSelected, + handleSelectAllSubcategories, + handleToggleSubcategory, +}: { + data: CategoryComparisonResponseData; + categories: any; + querySubcategories: Object | undefined; + selectedCategory: string; + setSelectedCategory: React.Dispatch>; + checkSubcategory: (category: string, subcategory: string) => boolean; + formatSubcategories: (str: string) => string; + checkAllSelected: (category: string) => boolean; + handleSelectAllSubcategories: (category: string) => void; + handleToggleSubcategory: (category: string, subcategory: string) => void; +}) => { + const [openSub, setOpenSub] = useState(querySubcategories ? true : false); + + return ( + +
+ {Object.keys(categories).map((category, i) => + categories[category] !== "Categories" ? ( +
{ + if (selectedCategory === category) { + setOpenSub(!openSub); + } + + setSelectedCategory(category); + }} + style={{ + transition: "min-width 0.5s", + minWidth: + selectedCategory === category && openSub ? "500px" : "10px", + }} + > +
+

{categories[category]}

+
+
+ {category !== "unlabeled" && category !== "native_transfers" ? ( +
{ + handleSelectAllSubcategories(category); + e.stopPropagation(); + }} + > +
Select All Subcategories
+
+ +
+
+ ) : null} + {category !== "unlabeled" && category !== "native_transfers" ? ( + data[category].subcategories.list.map((subcategory) => ( + + )) + ) : ( +
+ +

+ {" "} + There are currently no subcategories for the given + category.{" "} +

+
+ )} +
+
{ + setOpenSub(!openSub); + }} + > + +
+
+ ) : ( +
+
+ {categories[category]} +
+
Subcategories
+
+ ), + )} +
+
+ ); +}; + +export default CategoryBar; diff --git a/components/layout/CategoryMetrics.tsx b/components/layout/CategoryMetrics.tsx index b44956ab..9745f96a 100644 --- a/components/layout/CategoryMetrics.tsx +++ b/components/layout/CategoryMetrics.tsx @@ -27,6 +27,7 @@ import { MasterResponse } from "@/types/api/MasterResponse"; import ChainAnimations from "./ChainAnimations"; import { useUIContext } from "@/contexts/UIContext"; import ContractLabelModal from "./ContractLabelModal"; +import CategoryBar from "@/components/layout/CategoryBar"; import { TopRowContainer, @@ -1141,76 +1142,18 @@ export default function CategoryMetrics({ */}
{IS_PREVIEW || IS_DEVELOPMENT ? ( - -
- {Object.keys(categories).map((category, i) => - categories[category] !== "Categories" ? ( -
{ - if (selectedCategory === category) { - setOpenSub(!openSub); - } - - setSelectedCategory(category); - }} - style={{ - transition: "min-width 0.5s", - minWidth: - selectedCategory === category && openSub - ? "500px" - : "10px", - }} - > -
-

{categories[category]}

-
-
{ - setOpenSub(!openSub); - }} - > - -
-
- ) : ( -
-
- {categories[category]} -
-
Subcategories
-
- ), - )} -
-
+ ) : (
Date: Fri, 31 May 2024 11:06:38 -0400 Subject: [PATCH 4/6] updated handling for hottest contract on single chains page --- app/(layout)/chains/[chain]/page.tsx | 86 +++++++++++++++++++++++----- types/api/ChainResponse.ts | 2 +- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/app/(layout)/chains/[chain]/page.tsx b/app/(layout)/chains/[chain]/page.tsx index c110da1f..ef5e976c 100644 --- a/app/(layout)/chains/[chain]/page.tsx +++ b/app/(layout)/chains/[chain]/page.tsx @@ -720,20 +720,78 @@ const Chain = ({ params }: { params: any }) => {
Hottest Contract
-
- {chainData - ? `${ - chainData.hottest_contract - ? `${ - chainData.hottest_contract.data[0] - ? chainData.hottest_contract.data[0][1] + - " - " + - chainData.hottest_contract.data[0][2] - : "N/A" - }` - : "N/A" - }` - : "N/A"} +
{ + if ( + !chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf("name") + ] + ) { + navigator.clipboard.writeText( + chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf( + "address", + ) + ], + ); + } + }} + > + {chainData ? ( + chainData.hottest_contract ? ( + chainData.hottest_contract.data[0] ? ( + <> + + {chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf( + "name", + ) + ] || + chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf( + "address", + ) + ]} + + + {chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf( + "project_name", + ) + ] + ? "-" + : ""}{" "} + + + { + chainData.hottest_contract.data[0][ + chainData.hottest_contract.types.indexOf( + "project_name", + ) + ] + } + + + ) : ( + "N/A" + ) + ) : ( + "N/A" + ) + ) : ( + "N/A" + )}
diff --git a/types/api/ChainResponse.ts b/types/api/ChainResponse.ts index 5bf9f935..9f285df7 100644 --- a/types/api/ChainResponse.ts +++ b/types/api/ChainResponse.ts @@ -14,7 +14,7 @@ export interface ChainsData { }; hottest_contract: { data: any[][]; - types: any[][]; + types: any[]; }; } export interface Metrics { From a409d892d66790ddc548a93f0796d9ba32ceed92 Mon Sep 17 00:00:00 2001 From: mokelgit Date: Fri, 31 May 2024 11:51:57 -0400 Subject: [PATCH 5/6] further progress on category bar --- components/layout/CategoryBar.tsx | 47 +++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/components/layout/CategoryBar.tsx b/components/layout/CategoryBar.tsx index a2143b73..8d0b4a52 100644 --- a/components/layout/CategoryBar.tsx +++ b/components/layout/CategoryBar.tsx @@ -38,8 +38,8 @@ const CategoryBar = ({ return (
{Object.keys(categories).map((category, i) => @@ -59,24 +59,61 @@ const CategoryBar = ({ setSelectedCategory(category); }} style={{ - transition: "min-width 0.5s", + transition: "min-width 0.65s", minWidth: selectedCategory === category && openSub ? "500px" : "10px", + + borderLeft: "0.5px dotted var(--dark-active-text, #CDD8D3)", + background: + selectedCategory === category + ? "#5A6462" + : `linear-gradient( + 90deg, + rgba(16, 20, 19, ${ + 0.3 - (i / (Object.keys(categories).length - 1)) * 0.2 + }) 0%, + #101413 15.10%, + rgba(16, 20, 19, ${ + 0.06 + (i / Object.keys(categories).length) * 0.94 + }) 48.96%, + #101413 86.98%, + rgba(16, 20, 19, ${ + 0.3 - (i / (Object.keys(categories).length - 1)) * 0.2 + }) 100% + )`, }} >

{categories[category]}

Date: Fri, 31 May 2024 12:25:41 -0400 Subject: [PATCH 6/6] fixed issue switching from single chains to blockspace overview with 1d timespan --- app/(layout)/blockspace/chain-overview/[category]/page.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/(layout)/blockspace/chain-overview/[category]/page.tsx b/app/(layout)/blockspace/chain-overview/[category]/page.tsx index 6511ac33..441657e4 100644 --- a/app/(layout)/blockspace/chain-overview/[category]/page.tsx +++ b/app/(layout)/blockspace/chain-overview/[category]/page.tsx @@ -74,6 +74,12 @@ const ChainOverview = ({ params }: { params: any }) => { icon: "", }; + useEffect(() => { + if (selectedTimespan === "1d") { + setSelectedTimespan("7d"); + } + }, []); + const chainFilter = useMemo(() => { const filteredChains: Chains = Object.keys(AllChainsByKeys) .filter((chain) => {