mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
split explore from clone
This commit is contained in:
1 parent
67a77419df
commit
2fdd9e6a49
5 files changed
+347
-291
No files matched your search
@@ -5,6 +5,7 @@ import { URLFragmentHandler } from "./components/URLFragmentHandler";
|
||||
|
||||
import Index from "./pages/Index";
|
||||
import Clone from "./pages/Clone";
|
||||
import Explore from "./pages/Explore";
|
||||
import Settings from "./pages/Settings";
|
||||
import Preferences from "./pages/Preferences";
|
||||
import NostrSettings from "./pages/NostrSettings";
|
||||
@@ -38,6 +39,7 @@ export function AppRouter() {
|
||||
<Route path="/" element={<Index />} />
|
||||
<Route path="/giftcard" element={<Index />} />
|
||||
<Route path="/clone" element={<Clone />} />
|
||||
<Route path="/explore" element={<Explore />} />
|
||||
<Route path="/oauth/github" element={<GitHubOAuth />} />
|
||||
<Route path="/oauth/netlify" element={<NetlifyOAuth />} />
|
||||
<Route path="/oauth/vercel" element={<VercelOAuth />} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders } from 'lucide-react';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders, Compass } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -367,6 +367,13 @@ export function ProjectSidebar({
|
||||
<GitBranch className="h-4 w-4" />
|
||||
{t('importRepository')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => navigateAndClose('/explore')}
|
||||
className="flex items-center gap-2 w-full"
|
||||
>
|
||||
<Compass className="h-4 w-4" />
|
||||
{t('exploreApps')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setLabelsDialogOpen(true)}
|
||||
className="flex items-center gap-2 w-full"
|
||||
|
||||
@@ -139,6 +139,10 @@
|
||||
"emailUpdatesDescription": "Subscribe to Shakespeare updates and resources",
|
||||
"newProject": "New Project",
|
||||
"importRepository": "Import Repository",
|
||||
"explore": "Explore",
|
||||
"exploreApps": "Explore Apps",
|
||||
"exploreRepositories": "Explore repositories from the Nostr network",
|
||||
"pleaseLogInToExplore": "Please log in to explore repositories",
|
||||
"noProjectsYet": "No projects yet",
|
||||
"createFirstProject": "Create your first project to get started",
|
||||
"searchProjects": "Search projects...",
|
||||
|
||||
+4
-290
@@ -1,32 +1,19 @@
|
||||
import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AppLayout } from '@/components/AppLayout';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { GitBranch, Loader2, AlertCircle, FileArchive, MoreHorizontal, Search } from 'lucide-react';
|
||||
import { GitBranch, Loader2, AlertCircle, FileArchive, MoreHorizontal } from 'lucide-react';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { ZipImportDialog } from '@/components/ZipImportDialog';
|
||||
import { useSeoMeta } from '@unhead/react';
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useUserRepositories } from '@/hooks/useUserRepositories';
|
||||
import { useContacts } from '@/hooks/useContacts';
|
||||
import { useFollowedRepositories } from '@/hooks/useFollowedRepositories';
|
||||
import { RepositoryCard } from '@/components/RepositoryCard';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||
import type { Repository } from '@/hooks/useUserRepositories';
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { NSchema as n } from '@nostrify/nostrify';
|
||||
import type { NostrMetadata } from '@nostrify/nostrify';
|
||||
import { NostrURI } from '@/lib/NostrURI';
|
||||
import { useGitSettings } from '@/hooks/useGitSettings';
|
||||
import { detectFork } from '@/lib/detectFork';
|
||||
import { NostrURI } from '@/lib/NostrURI';
|
||||
|
||||
export default function Clone() {
|
||||
const { t } = useTranslation();
|
||||
@@ -41,46 +28,6 @@ export default function Clone() {
|
||||
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
|
||||
const { user } = useCurrentUser();
|
||||
const { settings: gitSettings } = useGitSettings();
|
||||
const { data: repositories = [], isLoading: isLoadingRepos } = useUserRepositories(user?.pubkey);
|
||||
const { data: contacts = [] } = useContacts(user?.pubkey);
|
||||
const { data: followedRepositories = [], isLoading: isLoadingFollowedRepos } = useFollowedRepositories(contacts);
|
||||
const [activeTab, setActiveTab] = useState<'my-projects' | 'follows'>('my-projects');
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
// Get unique pubkeys from all repositories
|
||||
const allRepos = useMemo(() => [...repositories, ...followedRepositories], [repositories, followedRepositories]);
|
||||
const uniquePubkeys = useMemo(() => {
|
||||
const pubkeys = new Set<string>();
|
||||
allRepos.forEach(repo => pubkeys.add(repo.pubkey));
|
||||
return Array.from(pubkeys);
|
||||
}, [allRepos]);
|
||||
|
||||
// Fetch author metadata for all unique pubkeys
|
||||
const { nostr } = useNostr();
|
||||
const { data: authorMetadataMap = new Map<string, NostrMetadata>() } = useQuery({
|
||||
queryKey: ['repository-authors', uniquePubkeys.sort().join(',')],
|
||||
queryFn: async () => {
|
||||
if (uniquePubkeys.length === 0) return new Map<string, NostrMetadata>();
|
||||
|
||||
const events = await nostr.query(
|
||||
[{ kinds: [0], authors: uniquePubkeys, limit: uniquePubkeys.length }],
|
||||
{ signal: AbortSignal.timeout(3000) }
|
||||
);
|
||||
|
||||
const metadataMap = new Map<string, NostrMetadata>();
|
||||
for (const event of events) {
|
||||
try {
|
||||
const metadata = n.json().pipe(n.metadata()).parse(event.content);
|
||||
metadataMap.set(event.pubkey, metadata);
|
||||
} catch {
|
||||
// If parsing fails, continue without metadata for this pubkey
|
||||
}
|
||||
}
|
||||
return metadataMap;
|
||||
},
|
||||
enabled: uniquePubkeys.length > 0,
|
||||
staleTime: 60000, // 1 minute
|
||||
});
|
||||
|
||||
useSeoMeta({
|
||||
title: `${t('importRepository')} - Shakespeare`,
|
||||
@@ -256,65 +203,6 @@ export default function Clone() {
|
||||
}
|
||||
};
|
||||
|
||||
// Filter repositories based on search query
|
||||
const filterRepositories = useCallback((repos: Repository[], query: string): Repository[] => {
|
||||
if (!query.trim()) {
|
||||
return repos;
|
||||
}
|
||||
|
||||
const lowerQuery = query.toLowerCase();
|
||||
|
||||
return repos.filter((repo) => {
|
||||
// Filter by repository name
|
||||
if (repo.name.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by description
|
||||
if (repo.description?.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by tags (hashtags)
|
||||
if (repo.repoTags.some(tag => tag.toLowerCase().includes(lowerQuery))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by hex pubkey
|
||||
if (repo.pubkey.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by npub (bech32 encoded pubkey)
|
||||
try {
|
||||
const npub = nip19.npubEncode(repo.pubkey);
|
||||
if (npub.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// If encoding fails, skip npub search
|
||||
}
|
||||
|
||||
// Filter by author name
|
||||
const authorMetadata = authorMetadataMap.get(repo.pubkey);
|
||||
if (authorMetadata?.name?.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}, [authorMetadataMap]);
|
||||
|
||||
// Filtered repositories for "My Projects" tab
|
||||
const filteredMyRepositories = useMemo(() => {
|
||||
return filterRepositories(repositories, searchQuery);
|
||||
}, [repositories, searchQuery, filterRepositories]);
|
||||
|
||||
// Filtered repositories for "Follows" tab
|
||||
const filteredFollowedRepositories = useMemo(() => {
|
||||
return filterRepositories(followedRepositories, searchQuery);
|
||||
}, [followedRepositories, searchQuery, filterRepositories]);
|
||||
|
||||
return (
|
||||
<AppLayout title={t('importRepository')}>
|
||||
<div className="max-w-2xl mx-auto">
|
||||
@@ -399,180 +287,6 @@ export default function Clone() {
|
||||
open={isZipDialogOpen}
|
||||
onOpenChange={setIsZipDialogOpen}
|
||||
/>
|
||||
|
||||
{/* NIP-34 Repositories with Tabs */}
|
||||
{user && (
|
||||
<div className="mt-16 max-w-7xl mx-auto">
|
||||
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as 'my-projects' | 'follows')}>
|
||||
<div className="flex items-center gap-4 mb-6 flex-wrap">
|
||||
<TabsList>
|
||||
<TabsTrigger value="my-projects">
|
||||
My Projects
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="follows">
|
||||
Follows
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Search Input */}
|
||||
{(repositories.length > 0 || followedRepositories.length > 0) && (
|
||||
<div className="relative flex-1 min-w-[200px] max-w-md">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Search repositories..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-9 h-10 text-sm"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<TabsContent value="my-projects">
|
||||
{isLoadingRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : filteredMyRepositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredMyRepositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : searchQuery.trim() ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<Search className="h-8 w-8 mx-auto mb-2 opacity-50 text-muted-foreground" />
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found matching "{searchQuery}".
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setSearchQuery('')}
|
||||
>
|
||||
Clear search
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found. Publish your first repository to Nostr to see it here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="follows">
|
||||
{isLoadingFollowedRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : filteredFollowedRepositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredFollowedRepositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : searchQuery.trim() ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<Search className="h-8 w-8 mx-auto mb-2 opacity-50 text-muted-foreground" />
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found matching "{searchQuery}".
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setSearchQuery('')}
|
||||
>
|
||||
Clear search
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : contacts.length > 0 ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
None of the people you follow have published repositories yet.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
You're not following anyone yet. Follow people on Nostr to see their repositories here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
import { useState, useMemo, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AppLayout } from '@/components/AppLayout';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Search, Compass } from 'lucide-react';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useUserRepositories } from '@/hooks/useUserRepositories';
|
||||
import { useContacts } from '@/hooks/useContacts';
|
||||
import { useFollowedRepositories } from '@/hooks/useFollowedRepositories';
|
||||
import { RepositoryCard } from '@/components/RepositoryCard';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import type { Repository } from '@/hooks/useUserRepositories';
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { NSchema as n } from '@nostrify/nostrify';
|
||||
import type { NostrMetadata } from '@nostrify/nostrify';
|
||||
import { useSeoMeta } from '@unhead/react';
|
||||
|
||||
export default function Explore() {
|
||||
const { t } = useTranslation();
|
||||
const { user } = useCurrentUser();
|
||||
const { data: repositories = [], isLoading: isLoadingRepos } = useUserRepositories(user?.pubkey);
|
||||
const { data: contacts = [] } = useContacts(user?.pubkey);
|
||||
const { data: followedRepositories = [], isLoading: isLoadingFollowedRepos } = useFollowedRepositories(contacts);
|
||||
const [activeTab, setActiveTab] = useState<'my-projects' | 'follows'>('my-projects');
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
// Get unique pubkeys from all repositories
|
||||
const allRepos = useMemo(() => [...repositories, ...followedRepositories], [repositories, followedRepositories]);
|
||||
const uniquePubkeys = useMemo(() => {
|
||||
const pubkeys = new Set<string>();
|
||||
allRepos.forEach(repo => pubkeys.add(repo.pubkey));
|
||||
return Array.from(pubkeys);
|
||||
}, [allRepos]);
|
||||
|
||||
// Fetch author metadata for all unique pubkeys
|
||||
const { nostr } = useNostr();
|
||||
const { data: authorMetadataMap = new Map<string, NostrMetadata>() } = useQuery({
|
||||
queryKey: ['repository-authors', uniquePubkeys.sort().join(',')],
|
||||
queryFn: async () => {
|
||||
if (uniquePubkeys.length === 0) return new Map<string, NostrMetadata>();
|
||||
|
||||
const events = await nostr.query(
|
||||
[{ kinds: [0], authors: uniquePubkeys, limit: uniquePubkeys.length }],
|
||||
{ signal: AbortSignal.timeout(3000) }
|
||||
);
|
||||
|
||||
const metadataMap = new Map<string, NostrMetadata>();
|
||||
for (const event of events) {
|
||||
try {
|
||||
const metadata = n.json().pipe(n.metadata()).parse(event.content);
|
||||
metadataMap.set(event.pubkey, metadata);
|
||||
} catch {
|
||||
// If parsing fails, continue without metadata for this pubkey
|
||||
}
|
||||
}
|
||||
return metadataMap;
|
||||
},
|
||||
enabled: uniquePubkeys.length > 0,
|
||||
staleTime: 60000, // 1 minute
|
||||
});
|
||||
|
||||
useSeoMeta({
|
||||
title: `${t('explore')} - Shakespeare`,
|
||||
description: t('exploreRepositories'),
|
||||
});
|
||||
|
||||
// Filter repositories based on search query
|
||||
const filterRepositories = useCallback((repos: Repository[], query: string): Repository[] => {
|
||||
if (!query.trim()) {
|
||||
return repos;
|
||||
}
|
||||
|
||||
const lowerQuery = query.toLowerCase();
|
||||
|
||||
return repos.filter((repo) => {
|
||||
// Filter by repository name
|
||||
if (repo.name.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by description
|
||||
if (repo.description?.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by tags (hashtags)
|
||||
if (repo.repoTags.some(tag => tag.toLowerCase().includes(lowerQuery))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by hex pubkey
|
||||
if (repo.pubkey.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Filter by npub (bech32 encoded pubkey)
|
||||
try {
|
||||
const npub = nip19.npubEncode(repo.pubkey);
|
||||
if (npub.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// If encoding fails, skip npub search
|
||||
}
|
||||
|
||||
// Filter by author name
|
||||
const authorMetadata = authorMetadataMap.get(repo.pubkey);
|
||||
if (authorMetadata?.name?.toLowerCase().includes(lowerQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}, [authorMetadataMap]);
|
||||
|
||||
// Filtered repositories for "My Projects" tab
|
||||
const filteredMyRepositories = useMemo(() => {
|
||||
return filterRepositories(repositories, searchQuery);
|
||||
}, [repositories, searchQuery, filterRepositories]);
|
||||
|
||||
// Filtered repositories for "Follows" tab
|
||||
const filteredFollowedRepositories = useMemo(() => {
|
||||
return filterRepositories(followedRepositories, searchQuery);
|
||||
}, [followedRepositories, searchQuery, filterRepositories]);
|
||||
|
||||
if (!user) {
|
||||
return (
|
||||
<AppLayout title={t('exploreApps')}>
|
||||
<div className="max-w-2xl mx-auto text-center py-12">
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('pleaseLogInToExplore')}
|
||||
</p>
|
||||
</div>
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AppLayout title={t('exploreApps')}>
|
||||
<div className="max-w-7xl mx-auto">
|
||||
<div className="mb-8">
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<Compass className="h-8 w-8 text-primary flex-shrink-0" />
|
||||
<h1 className="text-3xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
{t('exploreApps')}
|
||||
</h1>
|
||||
</div>
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('exploreRepositories')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as 'my-projects' | 'follows')}>
|
||||
<div className="flex items-center gap-4 mb-6 flex-wrap">
|
||||
<TabsList>
|
||||
<TabsTrigger value="my-projects">
|
||||
My Projects
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="follows">
|
||||
Follows
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Search Input */}
|
||||
{(repositories.length > 0 || followedRepositories.length > 0) && (
|
||||
<div className="relative flex-1 min-w-[200px] max-w-md">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Search repositories..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-9 h-10 text-sm"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<TabsContent value="my-projects">
|
||||
{isLoadingRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : filteredMyRepositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredMyRepositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : searchQuery.trim() ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<Search className="h-8 w-8 mx-auto mb-2 opacity-50 text-muted-foreground" />
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found matching "{searchQuery}".
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setSearchQuery('')}
|
||||
>
|
||||
Clear search
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found. Publish your first repository to Nostr to see it here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="follows">
|
||||
{isLoadingFollowedRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : filteredFollowedRepositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredFollowedRepositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : searchQuery.trim() ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<Search className="h-8 w-8 mx-auto mb-2 opacity-50 text-muted-foreground" />
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found matching "{searchQuery}".
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setSearchQuery('')}
|
||||
>
|
||||
Clear search
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : contacts.length > 0 ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
None of the people you follow have published repositories yet.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
You're not following anyone yet. Follow people on Nostr to see their repositories here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user