Commit
•
428d2d6
1
Parent(s):
af52b22
make it more mobile friendly
Browse files- src/pages/index.tsx +51 -54
src/pages/index.tsx
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
import { Inter } from "next/font/google";
|
4 |
import ActivityCalendar from "react-activity-calendar";
|
5 |
-
import {
|
6 |
-
import { Tooltip as MuiTooltip } from '@mui/material';
|
7 |
|
8 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
interface ModelData {
|
11 |
createdAt: string;
|
@@ -18,18 +21,10 @@ interface Activity {
|
|
18 |
level: number;
|
19 |
}
|
20 |
|
21 |
-
export default function
|
22 |
const [calendarData, setCalendarData] = useState<Record<string, Activity[]>>({});
|
23 |
const [isLoading, setIsLoading] = useState(true);
|
24 |
|
25 |
-
const PROVIDERS_MAP: Record<string, { color: string; authors: string[] }> = {
|
26 |
-
"Mistral AI": { color: "#ff7000", authors: ["mistralai"] },
|
27 |
-
"Meta": { color: "#1877F2", authors: ["facebook", "meta-llama"] },
|
28 |
-
"OpenAI": { color: "#10A37F", authors: ["openai"] },
|
29 |
-
"Anthropic": { color: "#cc785c", authors: ["anthropic"] },
|
30 |
-
"Google": { color: "#DB4437", authors: ["google"] },
|
31 |
-
}
|
32 |
-
|
33 |
const generateCalendarData = (modelData: ModelData[]) => {
|
34 |
const data: Record<string, Activity[]> = Object.fromEntries(
|
35 |
Object.keys(PROVIDERS_MAP).map(provider => [provider, []])
|
@@ -38,9 +33,8 @@ export default function Home() {
|
|
38 |
const today = new Date();
|
39 |
const startDate = new Date(today);
|
40 |
startDate.setMonth(today.getMonth() - 11);
|
41 |
-
startDate.setDate(1);
|
42 |
|
43 |
-
// generate daily data for each provider
|
44 |
for (let d = new Date(startDate); d <= today; d.setDate(d.getDate() + 1)) {
|
45 |
const dateString = d.toISOString().split('T')[0];
|
46 |
|
@@ -108,43 +102,46 @@ export default function Home() {
|
|
108 |
}, []);
|
109 |
|
110 |
return (
|
111 |
-
<
|
112 |
-
<h1 className="text-5xl font-bold text-center">Open Source Heatmap</h1>
|
113 |
-
<p className="text-center
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
.
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
<
|
126 |
-
|
127 |
-
<
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
142 |
</div>
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
</
|
149 |
);
|
150 |
}
|
|
|
1 |
+
import React, { useState, useEffect } from 'react';
|
|
|
|
|
2 |
import ActivityCalendar from "react-activity-calendar";
|
3 |
+
import { Tooltip } from '@mui/material';
|
|
|
4 |
|
5 |
+
const PROVIDERS_MAP = {
|
6 |
+
"Mistral AI": { color: "#ff7000", authors: ["mistralai"] },
|
7 |
+
"Meta": { color: "#1877F2", authors: ["facebook", "meta-llama"] },
|
8 |
+
"OpenAI": { color: "#10A37F", authors: ["openai"] },
|
9 |
+
"Anthropic": { color: "#cc785c", authors: ["anthropic"] },
|
10 |
+
"Google": { color: "#DB4437", authors: ["google"] },
|
11 |
+
};
|
12 |
|
13 |
interface ModelData {
|
14 |
createdAt: string;
|
|
|
21 |
level: number;
|
22 |
}
|
23 |
|
24 |
+
export default function OpenSourceHeatmap() {
|
25 |
const [calendarData, setCalendarData] = useState<Record<string, Activity[]>>({});
|
26 |
const [isLoading, setIsLoading] = useState(true);
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
const generateCalendarData = (modelData: ModelData[]) => {
|
29 |
const data: Record<string, Activity[]> = Object.fromEntries(
|
30 |
Object.keys(PROVIDERS_MAP).map(provider => [provider, []])
|
|
|
33 |
const today = new Date();
|
34 |
const startDate = new Date(today);
|
35 |
startDate.setMonth(today.getMonth() - 11);
|
36 |
+
startDate.setDate(1);
|
37 |
|
|
|
38 |
for (let d = new Date(startDate); d <= today; d.setDate(d.getDate() + 1)) {
|
39 |
const dateString = d.toISOString().split('T')[0];
|
40 |
|
|
|
102 |
}, []);
|
103 |
|
104 |
return (
|
105 |
+
<div className="w-full max-w-screen-lg mx-auto p-4">
|
106 |
+
<h1 className="text-3xl lg:text-5xl mt-16 font-bold text-center mb-2">Open Source Heatmap</h1>
|
107 |
+
<p className="text-center text-sm mb-8">A heatmap for open source model releases.</p>
|
108 |
+
{isLoading ? (
|
109 |
+
<p className="text-center">Loading...</p>
|
110 |
+
) : (
|
111 |
+
<div className="space-y-8 mx-10">
|
112 |
+
{Object.entries(PROVIDERS_MAP)
|
113 |
+
.sort(([keyA], [keyB]) =>
|
114 |
+
calendarData[keyB].reduce((sum, day) => sum + day.count, 0) -
|
115 |
+
calendarData[keyA].reduce((sum, day) => sum + day.count, 0)
|
116 |
+
)
|
117 |
+
.map(([providerName, { color }]) => (
|
118 |
+
<div key={providerName} className="flex flex-col">
|
119 |
+
<h2 className="text-xl font-bold mb-2">{providerName}</h2>
|
120 |
+
<div className="w-full overflow-x-auto">
|
121 |
+
<div className="inline-block mx-auto">
|
122 |
+
<ActivityCalendar
|
123 |
+
data={calendarData[providerName]}
|
124 |
+
theme={{
|
125 |
+
dark: ['#161b22', color],
|
126 |
+
light: ['#e0e0e0', color],
|
127 |
+
}}
|
128 |
+
hideTotalCount
|
129 |
+
renderBlock={(block, activity) => (
|
130 |
+
<Tooltip
|
131 |
+
title={`${activity.count} models created on ${activity.date}`}
|
132 |
+
arrow
|
133 |
+
>
|
134 |
+
{block}
|
135 |
+
</Tooltip>
|
136 |
+
)}
|
137 |
+
/>
|
138 |
+
</div>
|
139 |
</div>
|
140 |
+
</div>
|
141 |
+
))
|
142 |
+
}
|
143 |
+
</div>
|
144 |
+
)}
|
145 |
+
</div>
|
146 |
);
|
147 |
}
|