Skip to content

Commit c219c8c

Browse files
site by ai
1 parent 15a6854 commit c219c8c

File tree

2 files changed

+104
-12
lines changed

2 files changed

+104
-12
lines changed

ui/react-example/src/index.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,38 @@
117117
animation: pulseGlow 3s ease-in-out infinite;
118118
}
119119

120+
/* Number count up animation */
121+
@keyframes countUp {
122+
from {
123+
opacity: 0;
124+
transform: translateY(10px) scale(0.8);
125+
}
126+
to {
127+
opacity: 1;
128+
transform: translateY(0) scale(1);
129+
}
130+
}
131+
132+
.animate-count-up {
133+
animation: countUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
134+
}
135+
136+
/* Shimmer effect for loading */
137+
@keyframes shimmer {
138+
0% {
139+
background-position: -200px 0;
140+
}
141+
100% {
142+
background-position: 200px 0;
143+
}
144+
}
145+
146+
.animate-shimmer {
147+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
148+
background-size: 200px 100%;
149+
animation: shimmer 1.5s infinite;
150+
}
151+
120152
.diff-symbol {
121153
position: relative;
122154
color: #aeaeae !important;

ui/react-example/src/views/Main/MainContent.tsx

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,68 @@ import {
1717
Group,
1818
Grid,
1919
} from "@mantine/core";
20-
import { IconBrandReact, IconBrandSolidjs, IconBrandSvelte, IconBrandVue, IconSparkles } from "@tabler/icons-react";
21-
import { useMemo, useState } from "react";
20+
import {
21+
IconBrandReact,
22+
IconBrandSolidjs,
23+
IconBrandSvelte,
24+
IconBrandVue,
25+
IconSparkles,
26+
IconStar,
27+
IconDownload,
28+
} from "@tabler/icons-react";
29+
import { useMemo, useState, useEffect } from "react";
2230

2331
import { MainContentDiffAdvance, MainContentDiffConfig, MainContentDiffExample } from "../../components/MainContent";
2432

2533
import type { DiffFile } from "@git-diff-view/react";
2634

35+
interface StatsData {
36+
stars: number;
37+
downloads: number;
38+
loading: boolean;
39+
}
40+
41+
const formatNumber = (num: number): string => {
42+
if (num >= 1000000) return (num / 1000000).toFixed(1) + "M";
43+
if (num >= 1000) return (num / 1000).toFixed(1) + "K";
44+
return num.toString();
45+
};
46+
2747
export const MainContent = () => {
2848
const theme = useMantineTheme();
2949

3050
const [d, setD] = useState<DiffFile>();
51+
const [stats, setStats] = useState<StatsData>({ stars: 0, downloads: 0, loading: true });
3152

3253
const { colorScheme } = useMantineColorScheme();
3354

3455
const color = useMemo(() => alpha(getThemeColor("yellow", theme), 0.5), [theme]);
3556

57+
useEffect(() => {
58+
const fetchStats = async () => {
59+
try {
60+
// Fetch GitHub stars
61+
const githubRes = await fetch("https://api.github.com/repos/MrWangJustToDo/git-diff-view");
62+
const githubData = await githubRes.json();
63+
64+
// Fetch NPM downloads (last month)
65+
const npmRes = await fetch("https://api.npmjs.org/downloads/point/last-month/@git-diff-view/core");
66+
const npmData = await npmRes.json();
67+
68+
setStats({
69+
stars: githubData.stargazers_count || 0,
70+
downloads: npmData.downloads || 0,
71+
loading: false,
72+
});
73+
} catch (error) {
74+
console.error("Failed to fetch stats:", error);
75+
setStats({ stars: 0, downloads: 0, loading: false });
76+
}
77+
};
78+
79+
fetchStats();
80+
}, []);
81+
3682
return (
3783
<Box className="min-h-screen">
3884
<Container size="xl">
@@ -43,15 +89,27 @@ export const MainContent = () => {
4389
<div className="absolute -inset-8 rounded-full bg-gradient-to-r from-blue-500/20 via-purple-500/20 to-pink-500/20 blur-3xl" />
4490
)}
4591
<div className="relative">
46-
<Badge
47-
size="lg"
48-
variant="gradient"
49-
gradient={{ from: "blue", to: "cyan", deg: 90 }}
50-
leftSection={<IconSparkles size={16} />}
51-
className="mb-4"
52-
>
53-
Open Source
54-
</Badge>
92+
<Group justify="center" gap="xs" className="mb-4">
93+
<Badge
94+
size="lg"
95+
variant="gradient"
96+
gradient={{ from: "blue", to: "cyan", deg: 90 }}
97+
leftSection={<IconSparkles size={16} />}
98+
>
99+
Open Source
100+
</Badge>
101+
<Badge
102+
size="lg"
103+
variant="light"
104+
color="yellow"
105+
leftSection={<IconStar size={16} fill="currentColor" />}
106+
>
107+
{stats.loading ? "..." : formatNumber(stats.stars)}
108+
</Badge>
109+
<Badge size="lg" variant="light" color="blue" leftSection={<IconDownload size={16} />}>
110+
{stats.loading ? "..." : formatNumber(stats.downloads)}
111+
</Badge>
112+
</Group>
55113

56114
<Title
57115
order={1}
@@ -114,6 +172,8 @@ export const MainContent = () => {
114172
Feature-rich diff viewer with GitHub-style UI, easy to integrate and highly customizable.
115173
</Highlight>
116174
</Box>
175+
176+
<Space h="xl" />
117177
</Box>
118178

119179
<Divider my="xl" className="opacity-30" />
@@ -169,7 +229,7 @@ export const MainContent = () => {
169229
{/* Right Side - Diff Preview */}
170230
<Grid.Col span={{ base: 12, md: 8 }}>
171231
<Box
172-
className="sticky top-4 h-[calc(100vh-120px)] transform-gpu overflow-hidden rounded-xl border-2 border-solid shadow-2xl transition-all"
232+
className="sticky top-4 h-[calc(100vh-120px)] transform-gpu overflow-hidden rounded-xl border-2 border-solid transition-all"
173233
style={{
174234
borderColor: colorScheme === "light" ? "var(--mantine-color-gray-2)" : "var(--mantine-color-dark-4)",
175235
backgroundColor: colorScheme === "light" ? "white" : "var(--mantine-color-dark-7)",

0 commit comments

Comments
 (0)