Skip to content

Commit a0dcf4d

Browse files
authored
feat: improve explorer ux (#20)
* fix(explorer): fix filtered groups search * feat(explorer): add loader to pages * chore(explorer): add website metadata
1 parent e4f6d4b commit a0dcf4d

File tree

8 files changed

+61
-7
lines changed

8 files changed

+61
-7
lines changed
4.13 KB
Loading

apps/explorer/public/icon.svg

Lines changed: 4 additions & 0 deletions
Loading
190 KB
Loading

apps/explorer/src/app/[network]/[group]/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ export default function Group() {
1515
const [filteredCommitments, setFilteredCommitments] = useState<string[]>([])
1616
const [filteredProofs, setFilteredProofs] = useState<any[]>([])
1717

18+
const [loading, setLoading] = useState(false)
19+
1820
useEffect(() => {
1921
const fetchData = async () => {
22+
setLoading(true)
2023
const subgraph = new SemaphoreSubgraph(network)
2124

2225
const groupInfo = await subgraph.getGroup(groupId, {
@@ -28,6 +31,7 @@ export default function Group() {
2831

2932
setFilteredCommitments(groupInfo.members || [])
3033
setFilteredProofs(groupInfo.validatedProofs || [])
34+
setLoading(false)
3135
}
3236

3337
fetchData()
@@ -59,7 +63,11 @@ export default function Group() {
5963
[group]
6064
)
6165

62-
return (
66+
return loading ? (
67+
<div className="flex justify-center items-center h-screen">
68+
<div className="loader" />
69+
</div>
70+
) : (
6371
group && (
6472
<div className="mx-auto max-w-7xl px-4 lg:px-8 pt-20">
6573
<div className="flex justify-center flex-col pb-10 font-[family-name:var(--font-geist-sans)]">

apps/explorer/src/app/[network]/page.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ export default function Network() {
1313
const [allGroups, setAllGroups] = useState<GroupResponse[]>([])
1414
const [filteredGroups, setFilteredGroups] = useState<GroupResponse[]>([])
1515

16+
const [loading, setLoading] = useState(false)
17+
1618
useEffect(() => {
1719
const fetchData = async () => {
20+
setLoading(true)
1821
const subgraph = new SemaphoreSubgraph(network)
1922

2023
const groups = await subgraph.getGroups({
@@ -24,18 +27,26 @@ export default function Network() {
2427

2528
setAllGroups(groups)
2629
setFilteredGroups(groups.slice())
30+
setLoading(false)
2731
}
2832

2933
fetchData()
3034
}, [])
3135

32-
const filterGroups = useCallback((groupId: string) => {
33-
const groups = allGroups.filter((group) => (!groupId ? true : group.id.includes(groupId)))
36+
const filterGroups = useCallback(
37+
(groupId: string) => {
38+
const groups = allGroups.filter((group) => (!groupId ? true : group.id.includes(groupId)))
3439

35-
setFilteredGroups(groups)
36-
}, [])
40+
setFilteredGroups(groups)
41+
},
42+
[allGroups]
43+
)
3744

38-
return (
45+
return loading ? (
46+
<div className="flex justify-center items-center h-screen">
47+
<div className="loader" />
48+
</div>
49+
) : (
3950
allGroups && (
4051
<div className="mx-auto max-w-7xl px-4 lg:px-8 pt-20">
4152
<SearchBar className="mb-6" placeholder="Group ID" onChange={filterGroups} />

apps/explorer/src/app/favicon.ico

-25.3 KB
Binary file not shown.

apps/explorer/src/app/globals.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ body {
2525
text-wrap: balance;
2626
}
2727
}
28+
29+
.loader {
30+
width: 25px;
31+
height: 25px;
32+
border-radius: 50%;
33+
border-top: 2px solid #3555df;
34+
border-right: 2px solid transparent;
35+
animation: spin 1s linear infinite;
36+
z-index: 20;
37+
}
38+
39+
@keyframes spin {
40+
to {
41+
transform: rotate(360deg);
42+
}
43+
}

apps/explorer/src/app/layout.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,22 @@ const geistMono = localFont({
1616

1717
export const metadata: Metadata = {
1818
title: "Semaphore Explorer",
19-
description: "Discover Semaphore groups, view members and zero-knowledge proofs."
19+
description: "Discover Semaphore groups, view members and zero-knowledge proofs.",
20+
icons: { icon: "/icon.svg", apple: "/apple-icon.png" },
21+
metadataBase: new URL("https://explorer.semaphore.pse.dev"),
22+
openGraph: {
23+
type: "website",
24+
url: "https://explorer.semaphore.pse.dev",
25+
title: "Semaphore Explorer",
26+
description: "Discover Semaphore groups, view members and zero-knowledge proofs.",
27+
siteName: "Semaphore Explorer",
28+
images: [
29+
{
30+
url: "https://explorer.semaphore.pse.dev/social-media.png"
31+
}
32+
]
33+
},
34+
twitter: { card: "summary_large_image", images: "https://explorer.semaphore.pse.dev/social-media.png" }
2035
}
2136

2237
export default function RootLayout({

0 commit comments

Comments
 (0)