This commit is contained in:
ct
2025-07-16 19:55:37 +08:00
parent 06675de71b
commit fe32ffda42
12 changed files with 639 additions and 13 deletions

View File

@@ -0,0 +1,220 @@
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { KeywordBadge } from '@/components/ui/keyword-badge';
import Footer from '@/pages/home/partials/Footer';
import { Link, router } from '@inertiajs/react';
import { Edit, Search } from 'lucide-react';
import { useState } from 'react';
import { route } from 'ziggy-js';
import BrandLogo from '../home/partials/BrandLogo';
interface MemeMedia {
ids: string;
name: string;
description: string;
keywords: string[];
action_keywords: string[];
emotion_keywords: string[];
misc_keywords: string[];
mov_url: string;
webm_url: string;
gif_url: string;
webp_url: string;
slug: string;
}
interface PaginationLinks {
url: string | null;
label: string;
active: boolean;
}
interface PaginatedMemes {
data: MemeMedia[];
current_page: number;
last_page: number;
per_page: number;
total: number;
links: PaginationLinks[];
}
interface Props {
memes: PaginatedMemes;
types: string[];
popularKeywords: string[];
filters: {
search?: string;
};
}
export default function MemesIndex({ memes, popularKeywords, filters }: Props) {
const [search, setSearch] = useState(filters.search || '');
const handleSearch = (e: React.FormEvent) => {
e.preventDefault();
navigateToSearch(search);
};
const handleKeywordClick = (keyword: string) => {
setSearch(keyword);
navigateToSearch(keyword);
};
const navigateToSearch = (searchTerm: string) => {
if (!searchTerm.trim()) {
router.get(route('memes.index'));
return;
}
const trimmedSearch = searchTerm.trim();
// Convert spaces to + for URL segment
const urlSegment = trimmedSearch.replace(/\s+/g, '+');
router.get(route('memes.search', urlSegment));
};
const handlePageChange = (url: string) => {
router.get(url);
};
return (
<>
<div className="min-h-screen bg-neutral-50 pb-10 dark:bg-black">
<div className="container mx-auto px-4 pt-8 pb-0">
<BrandLogo className="py-3"></BrandLogo>
{/* Header */}
<div className="mb-8 text-center">
<h1 className="text-foreground mb-4 text-4xl font-bold">Meme Library</h1>
<p className="text-muted-foreground mx-auto max-w-2xl text-xl">
Thousands of memes ready for TikTok, Reels, Threads and YouTube Shorts. No signup needed - click any meme to start
creating!
</p>
</div>
{/* Search and Filters */}
<Card className="mb-8">
<CardContent className="p-6">
<form onSubmit={handleSearch} className="mb-4 flex flex-col gap-4 md:flex-row">
<div className="flex-1">
<div className="relative">
<Search className="text-muted-foreground absolute top-4 left-4 h-5 w-5" />
<Input
type="text"
placeholder="Search memes..."
value={search}
onChange={(e) => setSearch(e.target.value)}
className="h-12 pl-12 text-lg"
/>
</div>
</div>
<Button
type="submit"
size="lg"
className="h-12 bg-gradient-to-r from-purple-600 to-pink-600 text-lg text-white hover:from-purple-700 hover:to-pink-700"
>
Search
</Button>
</form>
{/* Popular Keywords */}
<div className="mt-4">
<h3 className="text-foreground mb-3 text-sm font-medium">Popular Keywords</h3>
<div className="flex flex-wrap gap-2">
{popularKeywords.map((keyword) => (
<KeywordBadge key={keyword} keyword={keyword} size="lg" />
))}
</div>
</div>
{/* Active Search */}
{filters.search && (
<div className="mt-4 flex flex-wrap gap-2">
<Badge variant="secondary" className="flex items-center gap-1">
Search: {filters.search}
<button
onClick={() => {
setSearch('');
router.get(route('memes.index'));
}}
className="ml-1 hover:text-red-500"
>
×
</button>
</Badge>
</div>
)}
</CardContent>
</Card>
{/* Results Count */}
<div className="mb-6 flex items-center justify-between">
<p className="text-muted-foreground">
Showing {memes.data.length} of {memes.total} memes
</p>
</div>
{/* Memes Grid */}
<div className="xs:grid-cols-2 mb-8 grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
{memes.data.map((meme) => (
<Card key={meme.ids} className="group flex flex-col overflow-hidden p-0 transition-shadow hover:shadow-lg">
<div className="relative aspect-[9/16] overflow-hidden bg-[#00FF00]">
<img
src={meme.webp_url}
alt={meme.name}
className="h-full w-full object-cover transition-transform group-hover:scale-105"
/>
<Link
href={route('memes.show', meme.slug)}
className="bg-opacity-0 absolute inset-0 flex items-center justify-center transition-all group-hover:opacity-40 hover:bg-black"
>
<Edit className="h-8 w-8 text-white opacity-0 transition-opacity group-hover:opacity-100" />
</Link>
</div>
<div className="flex flex-grow flex-col px-4 pt-0 pb-4">
<h3 className="text-foreground mb-2 line-clamp-2 text-sm font-semibold">{meme.name}</h3>
<div className="mb-3 flex flex-wrap gap-1">
{meme.keywords?.slice(0, 6).map((keyword, index) => <KeywordBadge key={index} keyword={keyword} />)}
{meme.keywords && meme.keywords.length > 6 && (
<Badge variant="secondary" className="text-xs">
+{meme.keywords.length - 6} more
</Badge>
)}
</div>
<div className="mt-auto">
<Link href={route('memes.show', meme.slug)}>
<Button
size="sm"
className="w-full bg-gradient-to-r from-purple-600 to-pink-600 text-white hover:from-purple-700 hover:to-pink-700"
>
Use meme
</Button>
</Link>
</div>
</div>
</Card>
))}
</div>
{/* Pagination */}
{memes.last_page > 1 && (
<div className="flex items-center justify-center gap-2">
{memes.links.map((link, index) => (
<Button
key={index}
variant={link.active ? 'default' : 'outline'}
size="sm"
onClick={() => link.url && handlePageChange(link.url)}
disabled={!link.url}
dangerouslySetInnerHTML={{ __html: link.label }}
/>
))}
</div>
)}
</div>
<Footer />
</div>
</>
);
}

View File

@@ -0,0 +1,174 @@
import { Head } from '@inertiajs/react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { ArrowLeft, Play, Download, Share2 } from 'lucide-react';
import { Link } from '@inertiajs/react';
import { route } from 'ziggy-js';
interface MemeMedia {
ids: string;
name: string;
description: string;
keywords: string[];
action_keywords: string[];
emotion_keywords: string[];
misc_keywords: string[];
mov_url: string;
webm_url: string;
gif_url: string;
webp_url: string;
slug: string;
}
interface Props {
meme: MemeMedia;
relatedMemes: MemeMedia[];
}
export default function MemeShow({ meme, relatedMemes }: Props) {
const allKeywords = [
...(meme.keywords || []),
...(meme.action_keywords || []),
...(meme.emotion_keywords || []),
...(meme.misc_keywords || [])
].filter(Boolean);
return (
<>
<Head title={`${meme.name} - Meme Template`} />
<Head>
<meta name="description" content={meme.description} />
<meta name="keywords" content={allKeywords.join(', ')} />
<meta property="og:title" content={`${meme.name} - Meme Template`} />
<meta property="og:description" content={meme.description} />
<meta property="og:image" content={meme.webp_url} />
<meta property="og:type" content="video.other" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={`${meme.name} - Meme Template`} />
<meta name="twitter:description" content={meme.description} />
<meta name="twitter:image" content={meme.webp_url} />
</Head>
<div className="min-h-screen bg-gradient-to-br from-purple-50 to-pink-50">
<div className="container mx-auto px-4 py-8">
{/* Header */}
<div className="flex items-center gap-4 mb-8">
<Link href={route('memes.index')}>
<Button variant="outline" size="sm">
<ArrowLeft className="h-4 w-4 mr-2" />
Back to Memes
</Button>
</Link>
<div>
<h1 className="text-3xl font-bold text-gray-900">{meme.name}</h1>
<p className="text-gray-600 mt-2">{meme.description}</p>
</div>
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
{/* Main Content */}
<div className="lg:col-span-2">
<Card>
<CardContent className="p-6">
{/* Video Preview */}
<div className="aspect-[9/16] bg-black rounded-lg overflow-hidden mb-6 max-w-md mx-auto">
<video
src={meme.webm_url}
poster={meme.webp_url}
controls
className="w-full h-full object-cover"
preload="metadata"
/>
</div>
{/* Action Buttons */}
<div className="flex flex-wrap gap-3 justify-center">
<Button className="bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700">
<Play className="h-4 w-4 mr-2" />
Create Meme
</Button>
<Button variant="outline">
<Download className="h-4 w-4 mr-2" />
Download
</Button>
<Button variant="outline">
<Share2 className="h-4 w-4 mr-2" />
Share
</Button>
</div>
</CardContent>
</Card>
</div>
{/* Sidebar */}
<div className="space-y-6">
{/* Keywords */}
<Card>
<CardHeader>
<CardTitle className="text-lg">Keywords</CardTitle>
<CardDescription>
Related keywords for this meme template
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex flex-wrap gap-2">
{meme.action_keywords?.map((keyword, index) => (
<Badge key={`action-${index}`} variant="secondary" className="bg-blue-100 text-blue-800">
{keyword}
</Badge>
))}
{meme.emotion_keywords?.map((keyword, index) => (
<Badge key={`emotion-${index}`} variant="secondary" className="bg-green-100 text-green-800">
{keyword}
</Badge>
))}
{meme.misc_keywords?.map((keyword, index) => (
<Badge key={`misc-${index}`} variant="secondary" className="bg-gray-100 text-gray-800">
{keyword}
</Badge>
))}
</div>
</CardContent>
</Card>
{/* Related Memes */}
{relatedMemes.length > 0 && (
<Card>
<CardHeader>
<CardTitle className="text-lg">Related Memes</CardTitle>
<CardDescription>
Similar meme templates you might like
</CardDescription>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 gap-3">
{relatedMemes.map((related) => (
<Link
key={related.ids}
href={route('memes.show', related.slug)}
className="block"
>
<div className="aspect-[9/16] bg-gray-100 rounded-lg overflow-hidden mb-2">
<img
src={related.webp_url}
alt={related.name}
className="w-full h-full object-cover hover:scale-105 transition-transform"
/>
</div>
<p className="text-sm font-medium text-gray-900 truncate">
{related.name}
</p>
</Link>
))}
</div>
</CardContent>
</Card>
)}
</div>
</div>
</div>
</div>
</>
);
}