Skip to content

Commit

Permalink
further progress on menu/navigation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mokelgit committed Sep 18, 2024
1 parent 64c32e4 commit fb94ef7
Show file tree
Hide file tree
Showing 7 changed files with 869 additions and 787 deletions.
14 changes: 5 additions & 9 deletions app/(layout)/fundamentals/[metric]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { track } from "@vercel/analytics/server";
import Link from "next/link";
import Icon from "@/components/layout/Icon";
import StableInsights from "@/components/layout/StableInsights";
import { MetricItem, metricItems } from "@/lib/metrics";

type Props = {
params: { metric: string };
Expand All @@ -27,9 +28,7 @@ const unitsMap = {
export async function generateMetadata({ params }: Props): Promise<Metadata> {
if (
!params.metric ||
navigationItems
.find((item) => item.label === "Fundamentals")
?.options.find((item) => item.urlKey === params.metric) === undefined
metricItems.find((item) => item.urlKey === params.metric) === undefined
) {
track("404 Error", {
location: "404 Error",
Expand All @@ -38,9 +37,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
return notFound();
}

const option = navigationItems
.find((item) => item.label === "Fundamentals")
?.options.find((item) => item.urlKey === params.metric);
const option = metricItems.find((item) => item.urlKey === params.metric);

if (option) {
const currentDate = new Date();
Expand Down Expand Up @@ -79,9 +76,8 @@ export default async function Layout({
}) {
const url = MetricsURLs[params.metric];

const pageData = navigationItems[1]?.options.find(
(item) => item.urlKey === params.metric,
)?.page ?? {
const pageData = metricItems.find((item) => item.urlKey === params.metric)
?.page ?? {
title: "",
description: "",
icon: "",
Expand Down
223 changes: 118 additions & 105 deletions app/(refactor)/refactor/components/layout/Chains/ChainChart.tsx

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions components/charts/ChainComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from "@/components/layout/Tooltip";
import Link from "next/link";
import { Sources } from "@/lib/datasources";
import { metricItems, MetricItem } from "@/lib/metrics";
import { metricItems, MetricItem, metricCategories } from "@/lib/metrics";
import { navigationItems, navigationCategories } from "@/lib/navigation";
import { useUIContext } from "@/contexts/UIContext";
import { useMediaQuery } from "usehooks-ts";
Expand Down Expand Up @@ -351,23 +351,23 @@ export default function ChainComponent({

if (!navItem || !navItem.category) return null;

return navigationCategories[navItem.category]
? navigationCategories[navItem.category].icon
return metricCategories[navItem.category]
? metricCategories[navItem.category].icon
: null;
},
[navigationItems],
[metricItems],
);

const getNavLabel = useCallback(
(key: string) => {
const navItem = metricItems[metric_index];
if (!navItem || !navItem.category) return null;

return navigationCategories[navItem.category]
? navigationCategories[navItem.category].label
return metricCategories[navItem.category]
? metricCategories[navItem.category].label
: null;
},
[navigationItems],
[metricItems],
);

const displayValues = useMemo(() => {
Expand Down
197 changes: 117 additions & 80 deletions components/layout/SidebarMenuGroup.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/layout/SingleChains/ChainChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ export default function ChainChart({
? metricCategories[metricItem.category].icon
: null;
},
[navigationItems],
[metricItems],
);

const lastPointLines = useMemo<{
Expand Down
1,172 changes: 587 additions & 585 deletions icons/gtp-figma-export.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions lib/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type NavigationItem = {
excludeFromSitemap?: boolean;
hide?: boolean;
showNew?: boolean;
url?: string;
}[];
href?: string;
};
Expand All @@ -58,6 +59,16 @@ export const navigationCategories = {
group: "fundamentals",
},

"blockspace-categories": {
label: "Categories",
icon: "gtp:package",
group: "blockspace",
},
contracts: {
label: "Contracts",
icon: "gtp:package",
group: "contracts",
},
developer: {
label: "Developer",
icon: "feather:code",
Expand Down Expand Up @@ -246,6 +257,7 @@ export const navigationItems: NavigationItem[] = [
key: "economics-overview",
rootKey: "economics",
urlKey: "economics",
url: "/economics",
},
{
label: "Fees Paid by Users",
Expand All @@ -261,6 +273,7 @@ export const navigationItems: NavigationItem[] = [
key: "fees",
rootKey: "metricsFeesPaidToEthereum",
urlKey: "fees-paid-by-users",
url: "/fundamentals/fees-paid-by-users",
},
{
label: "Rent Paid to L1",
Expand All @@ -276,6 +289,7 @@ export const navigationItems: NavigationItem[] = [
key: "rent_paid",
rootKey: "metricsRentPaid",
urlKey: "rent-paid",
url: "/fundamentals/rent-paid",
},
{
label: "Onchain Profit",
Expand All @@ -291,6 +305,7 @@ export const navigationItems: NavigationItem[] = [
key: "profit",
rootKey: "metricsEarnings",
urlKey: "profit",
url: "/fundamentals/profit",
},
{
label: "Fully Diluted Valuation",
Expand Down Expand Up @@ -328,6 +343,7 @@ export const navigationItems: NavigationItem[] = [
key: "fdv",
rootKey: "metricsFullyDilutedValuation",
urlKey: "fully-diluted-valuation",
url: "/fundamentals/fully-diluted-valuation",
},
{
label: "Market Cap",
Expand Down Expand Up @@ -367,6 +383,7 @@ export const navigationItems: NavigationItem[] = [
key: "market_cap",
rootKey: "marketCap",
urlKey: "market-cap",
url: "/fundamentals/market-cap",
},
],
},
Expand All @@ -377,6 +394,7 @@ export const navigationItems: NavigationItem[] = [
options: [
{
label: "Chain Overview",
category: "blockspace-categories",
page: {
title: "Chain Overview",
description: `We measure the gas fees spent and the number of transactions sent to smart contracts. We then map these smart contracts to distinct categories. The chart below breaks down the total blockspace of a chain into these categories. Each category is made up of multiple subcategories, which are listed in the mapping table below the chart.
Expand All @@ -391,6 +409,7 @@ export const navigationItems: NavigationItem[] = [
},
{
label: "Category Comparison",
category: "blockspace-categories",
page: {
title: "Category Comparison",
description:
Expand All @@ -401,6 +420,21 @@ export const navigationItems: NavigationItem[] = [
rootKey: "categoryComparison",
urlKey: "category-comparison",
},
{
label: "Contracts",
category: "contracts",
page: {
title: "Contracts",
description:
"The number of contracts created in the last 24 hours. Methodology and data is derived from L2Beat.com.",
icon: "gtp:contracts",
},
icon: "gtp:contracts",
key: "contracts",
rootKey: "contracts",
urlKey: "contracts",
url: "https://labels.growthepie.xyz/",
},
],
// href: "",
},
Expand Down

0 comments on commit fb94ef7

Please sign in to comment.