-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeStatsSection.astro
More file actions
179 lines (158 loc) · 4.85 KB
/
HomeStatsSection.astro
File metadata and controls
179 lines (158 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
import type { SiteLang } from "@/lib/blog";
interface Props {
lang: SiteLang;
}
const { lang } = Astro.props;
type StatItem = {
value: string;
title: string;
icon: "users" | "tokens" | "containers" | "awards";
};
const stats: Record<SiteLang, StatItem[]> = {
zh: [
{ value: "600+", title: "注册用户", icon: "users" },
{ value: "200+亿", title: "Token调用量", icon: "tokens" },
{ value: "700+", title: "容器镜像实例", icon: "containers" },
{ value: "10+", title: "教学科研奖项", icon: "awards" },
],
en: [
{ value: "600+", title: "Registered users", icon: "users" },
{ value: "20B+", title: "Tokens consumed", icon: "tokens" },
{ value: "700+", title: "Container image instances", icon: "containers" },
{ value: "10+", title: "Teaching & research awards", icon: "awards" },
],
};
const items = stats[lang];
---
<section class="home-stats-section" aria-label={lang === "zh" ? "平台数据" : "Platform metrics"}>
<ul class="stats-grid">
{
items.map((item) => (
<li class="stat-card">
<div class="stat-icon" aria-hidden="true">
{item.icon === "users" && (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="3" />
<path d="M22 21v-2a4 4 0 0 0-3-3.87" />
<path d="M16 3.13a4 4 0 0 1 0 7.75" />
</svg>
)}
{item.icon === "tokens" && (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<path d="M4 19V5" />
<path d="M4 19h16" />
<path d="M8 15l3-4 3 3 4-6" />
</svg>
)}
{item.icon === "containers" && (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<path d="M12 3 3 7.5 12 12l9-4.5L12 3z" />
<path d="M3 12l9 4.5 9-4.5" />
<path d="M3 16.5 12 21l9-4.5" />
</svg>
)}
{item.icon === "awards" && (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<circle cx="12" cy="8" r="5" />
<path d="M8.5 14 6 22l6-3 6 3-2.5-8" />
</svg>
)}
</div>
<div class="stat-text">
<p class="stat-value">{item.value}</p>
<p class="stat-title">{item.title}</p>
</div>
</li>
))
}
</ul>
</section>
<style>
.home-stats-section {
width: 100%;
}
.stats-grid {
list-style: none;
margin: 0;
padding: 0;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: clamp(0.85rem, 1.6vw, 1.35rem);
}
.stat-card {
display: flex;
align-items: center;
gap: clamp(0.9rem, 1.5vw, 1.15rem);
padding: clamp(1rem, 1.6vw, 1.35rem) clamp(1rem, 1.8vw, 1.4rem);
border-radius: 1rem;
background: color-mix(in srgb, var(--accent-color-extralight) 72%, var(--bg-color));
border: 1px solid color-mix(in srgb, var(--accent-color) 14%, var(--border-color));
box-shadow: 0 4px 18px color-mix(in srgb, var(--accent-color) 6%, transparent);
}
.stat-icon {
flex-shrink: 0;
width: clamp(3.25rem, 4vw, 3.75rem);
height: clamp(3.25rem, 4vw, 3.75rem);
border-radius: 0.75rem;
display: grid;
place-items: center;
background: color-mix(in srgb, var(--accent-color) 12%, var(--bg-color-dimmer));
color: var(--accent-color);
}
.stat-icon svg {
width: clamp(1.6rem, 2vw, 1.85rem);
height: clamp(1.6rem, 2vw, 1.85rem);
}
.stat-text {
min-width: 0;
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.stat-value {
margin: 0;
font-size: clamp(1.45rem, 2.1vw, 2rem);
font-weight: 700;
line-height: 1.15;
letter-spacing: -0.02em;
color: #5b3db8;
}
.stat-title {
margin: 0;
font-size: clamp(0.95rem, 1.25vw, 1.125rem);
line-height: 1.35;
color: var(--sub-text-color);
font-weight: 600;
}
:global([data-theme="dark"]) .stat-card {
background: color-mix(in srgb, var(--bg-color-dimmer) 88%, var(--bg-color));
border-color: color-mix(in srgb, var(--accent-color) 22%, var(--border-color));
}
:global([data-theme="dark"]) .stat-value {
color: #c4b5fd;
}
@media (max-width: 1080px) {
.stats-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 560px) {
.stats-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.75rem;
}
.stat-card {
flex-direction: column;
align-items: flex-start;
padding: 0.9rem 0.85rem;
}
.stat-value {
font-size: 1.35rem;
}
.stat-title {
font-size: 0.875rem;
}
}
</style>