Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve explorer ux #20

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/explorer/public/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/explorer/public/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/explorer/public/social-media.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion apps/explorer/src/app/[network]/[group]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ export default function Group() {
const [filteredCommitments, setFilteredCommitments] = useState<string[]>([])
const [filteredProofs, setFilteredProofs] = useState<any[]>([])

const [loading, setLoading] = useState(false)

useEffect(() => {
const fetchData = async () => {
setLoading(true)
const subgraph = new SemaphoreSubgraph(network)

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

setFilteredCommitments(groupInfo.members || [])
setFilteredProofs(groupInfo.validatedProofs || [])
setLoading(false)
}

fetchData()
Expand Down Expand Up @@ -59,7 +63,11 @@ export default function Group() {
[group]
)

return (
return loading ? (
<div className="flex justify-center items-center h-screen">
<div className="loader" />
</div>
) : (
group && (
<div className="mx-auto max-w-7xl px-4 lg:px-8 pt-20">
<div className="flex justify-center flex-col pb-10 font-[family-name:var(--font-geist-sans)]">
Expand Down
21 changes: 16 additions & 5 deletions apps/explorer/src/app/[network]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export default function Network() {
const [allGroups, setAllGroups] = useState<GroupResponse[]>([])
const [filteredGroups, setFilteredGroups] = useState<GroupResponse[]>([])

const [loading, setLoading] = useState(false)

useEffect(() => {
const fetchData = async () => {
setLoading(true)
const subgraph = new SemaphoreSubgraph(network)

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

setAllGroups(groups)
setFilteredGroups(groups.slice())
setLoading(false)
}

fetchData()
}, [])

const filterGroups = useCallback((groupId: string) => {
const groups = allGroups.filter((group) => (!groupId ? true : group.id.includes(groupId)))
const filterGroups = useCallback(
(groupId: string) => {
const groups = allGroups.filter((group) => (!groupId ? true : group.id.includes(groupId)))

setFilteredGroups(groups)
}, [])
setFilteredGroups(groups)
},
[allGroups]
)

return (
return loading ? (
<div className="flex justify-center items-center h-screen">
<div className="loader" />
</div>
) : (
allGroups && (
<div className="mx-auto max-w-7xl px-4 lg:px-8 pt-20">
<SearchBar className="mb-6" placeholder="Group ID" onChange={filterGroups} />
Expand Down
Binary file removed apps/explorer/src/app/favicon.ico
Binary file not shown.
16 changes: 16 additions & 0 deletions apps/explorer/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ body {
text-wrap: balance;
}
}

.loader {
width: 25px;
height: 25px;
border-radius: 50%;
border-top: 2px solid #3555df;
border-right: 2px solid transparent;
animation: spin 1s linear infinite;
z-index: 20;
}

@keyframes spin {
to {
transform: rotate(360deg);
}
}
17 changes: 16 additions & 1 deletion apps/explorer/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ const geistMono = localFont({

export const metadata: Metadata = {
title: "Semaphore Explorer",
description: "Discover Semaphore groups, view members and zero-knowledge proofs."
description: "Discover Semaphore groups, view members and zero-knowledge proofs.",
icons: { icon: "/icon.svg", apple: "/apple-icon.png" },
metadataBase: new URL("https://explorer.semaphore.pse.dev"),
openGraph: {
type: "website",
url: "https://explorer.semaphore.pse.dev",
title: "Semaphore Explorer",
description: "Discover Semaphore groups, view members and zero-knowledge proofs.",
siteName: "Semaphore Explorer",
images: [
{
url: "https://explorer.semaphore.pse.dev/social-media.png"
}
]
},
twitter: { card: "summary_large_image", images: "https://explorer.semaphore.pse.dev/social-media.png" }
}

export default function RootLayout({
Expand Down