forked from Bitcoindefi/OpenAO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdatesPanel.tsx
More file actions
282 lines (256 loc) · 12.4 KB
/
Copy pathUpdatesPanel.tsx
File metadata and controls
282 lines (256 loc) · 12.4 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import changelogEntries from "@/data/changelog.json";
import roadmapEntries from "@/data/roadmap.json";
type ChangelogEntry = {
features: string[];
};
type RoadmapEntry = {
title: string;
items: string[];
};
type UpdatesPanelProps = {
mode?: "preview" | "full";
backHref?: string;
};
const reversedChangelogEntries = [
...(changelogEntries as ChangelogEntry[]),
].reverse();
const orderedRoadmapEntries = roadmapEntries as RoadmapEntry[];
export default function UpdatesPanel({
mode = "preview",
backHref,
}: UpdatesPanelProps) {
const isPreview = mode === "preview";
const [isChangelogExpanded, setIsChangelogExpanded] = useState(false);
const [isRoadmapExpanded, setIsRoadmapExpanded] = useState(false);
const changelogPreview = reversedChangelogEntries[0];
const roadmapPreview = orderedRoadmapEntries[0];
const visibleChangelogEntries =
isPreview || !isChangelogExpanded
? reversedChangelogEntries.slice(0, 1)
: reversedChangelogEntries;
const visibleRoadmapEntries =
isPreview || !isRoadmapExpanded
? orderedRoadmapEntries.slice(0, 1)
: orderedRoadmapEntries;
useEffect(() => {
if (isPreview) {
return;
}
const syncExpandedSections = () => {
const rawHash = window.location.hash;
const normalizedHash = rawHash.includes("#")
? `#${rawHash.split("#").filter(Boolean)[0] ?? ""}`
: rawHash;
if (normalizedHash && normalizedHash !== rawHash) {
window.history.replaceState(
null,
"",
`${window.location.pathname}${window.location.search}${normalizedHash}`,
);
}
setIsChangelogExpanded(normalizedHash === "#changelog");
setIsRoadmapExpanded(normalizedHash === "#roadmap");
};
syncExpandedSections();
window.addEventListener("hashchange", syncExpandedSections);
return () => {
window.removeEventListener("hashchange", syncExpandedSections);
};
}, [isPreview]);
const navigateToUpdatesSection = (section: "changelog" | "roadmap") => {
if (typeof window !== "undefined") {
window.location.assign(`/updates#${section}`);
}
};
return (
<div className="space-y-6">
{backHref ? (
<div className="flex justify-end">
<Link
href={backHref}
prefetch={false}
className="text-sm text-stone-300 transition hover:text-stone-100"
>
Volver
</Link>
</div>
) : null}
<section
id="changelog"
className="rounded-[28px] border border-white/8 bg-stone-950/75 p-5 shadow-2xl backdrop-blur-md"
>
<div className="flex items-center justify-between gap-3">
<p className="text-[11px] uppercase tracking-[0.3em] text-cyan-200/75">
Changelog
</p>
{isPreview ? (
<button
type="button"
onClick={() =>
navigateToUpdatesSection("changelog")
}
className="text-xs font-medium uppercase tracking-[0.22em] text-cyan-100 transition hover:text-white"
>
Mostrar mas
</button>
) : null}
</div>
<div className="mt-5 space-y-4">
{isPreview ? (
changelogPreview ? (
<article className="relative overflow-hidden rounded-2xl border border-white/7 bg-white/4 p-4">
<span className="mb-3 inline-flex rounded-full bg-cyan-300/12 px-2.5 py-1 text-[10px] uppercase tracking-[0.24em] text-cyan-100">
Update{" "}
{String(changelogEntries.length).padStart(
2,
"0",
)}
</span>
<ul className="mt-3 space-y-2 text-sm text-stone-300">
{changelogPreview.features
.slice(0, 3)
.map((feature) => (
<li
key={feature}
className="flex gap-2 leading-6"
>
<span className="mt-2 h-1.5 w-1.5 rounded-full bg-amber-200" />
<span>{feature}</span>
</li>
))}
</ul>
{changelogPreview.features.length > 3 ? (
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-stone-950 via-stone-950/85 to-transparent" />
) : null}
</article>
) : null
) : (
visibleChangelogEntries.map((entry, index) => (
<article
key={`${entry.features[0] ?? "update"}-${index}`}
className="relative rounded-2xl border border-white/7 bg-white/4 p-4"
>
<span className="mb-3 inline-flex rounded-full bg-cyan-300/12 px-2.5 py-1 text-[10px] uppercase tracking-[0.24em] text-cyan-100">
Update{" "}
{String(
changelogEntries.length - index,
).padStart(2, "0")}
</span>
<ul className="mt-3 space-y-2 text-sm text-stone-300">
{entry.features.map((feature) => (
<li
key={feature}
className="flex gap-2 leading-6"
>
<span className="mt-2 h-1.5 w-1.5 rounded-full bg-amber-200" />
<span>{feature}</span>
</li>
))}
</ul>
</article>
))
)}
{!isPreview && reversedChangelogEntries.length > 1 ? (
<button
type="button"
onClick={() =>
setIsChangelogExpanded((current) => !current)
}
className="w-full rounded-2xl border border-cyan-300/20 bg-cyan-300/10 px-4 py-3 text-sm font-medium text-cyan-100 transition hover:border-cyan-300/40 hover:bg-cyan-300/15"
>
{isChangelogExpanded
? "Mostrar menos"
: "Mostrar mas"}
</button>
) : null}
</div>
</section>
<section
id="roadmap"
className="rounded-[28px] border border-white/8 bg-stone-950/75 p-5 shadow-2xl backdrop-blur-md"
>
<div className="flex items-center justify-between gap-3">
<p className="text-[11px] uppercase tracking-[0.3em] text-amber-200/75">
Roadmap
</p>
{isPreview ? (
<button
type="button"
onClick={() => navigateToUpdatesSection("roadmap")}
className="text-xs font-medium uppercase tracking-[0.22em] text-amber-100 transition hover:text-white"
>
Mostrar mas
</button>
) : null}
</div>
<div className="mt-5 space-y-4">
{isPreview ? (
roadmapPreview ? (
<article className="relative overflow-hidden rounded-2xl border border-white/7 bg-white/4 p-4">
<p className="text-base font-semibold text-white">
{roadmapPreview.title}
</p>
<ul className="mt-4 space-y-2 text-sm text-stone-300">
{roadmapPreview.items
.slice(0, 2)
.map((item) => (
<li
key={item}
className="flex gap-2 leading-6"
>
<span className="mt-2 h-1.5 w-1.5 rounded-full bg-cyan-200" />
<span>{item}</span>
</li>
))}
</ul>
{roadmapPreview.items.length > 2 ? (
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-stone-950 via-stone-950/85 to-transparent" />
) : null}
</article>
) : null
) : (
visibleRoadmapEntries.map((entry) => (
<article
key={`${entry.title}`}
className="rounded-2xl border border-white/7 bg-white/4 p-4"
>
<div className="flex flex-wrap items-center justify-between gap-3">
<p className="text-base font-semibold text-white">
{entry.title}
</p>
</div>
<ul className="mt-4 space-y-2 text-sm text-stone-300">
{entry.items.map((item) => (
<li
key={item}
className="flex gap-2 leading-6"
>
<span className="mt-2 h-1.5 w-1.5 rounded-full bg-cyan-200" />
<span>{item}</span>
</li>
))}
</ul>
</article>
))
)}
{!isPreview && orderedRoadmapEntries.length > 1 ? (
<button
type="button"
onClick={() =>
setIsRoadmapExpanded((current) => !current)
}
className="w-full rounded-2xl border border-amber-300/20 bg-amber-300/10 px-4 py-3 text-sm font-medium text-amber-100 transition hover:border-amber-300/40 hover:bg-amber-300/15"
>
{isRoadmapExpanded
? "Mostrar menos"
: "Mostrar mas"}
</button>
) : null}
</div>
</section>
</div>
);
}