| // src/components/blog/BlogHeader.tsx | |
| import { Link } from "react-router-dom"; | |
| import { Search, Filter, Grid, List, BookOpen } from "lucide-react"; | |
| import { useState } from "react"; | |
| import { motion } from "framer-motion"; | |
| interface BlogHeaderProps { | |
| title?: string; | |
| subtitle?: string; | |
| onSearch?: (query: string) => void; | |
| onViewChange?: (view: "grid" | "list") => void; | |
| currentView?: "grid" | "list"; | |
| showViewToggle?: boolean; | |
| } | |
| export function BlogHeader({ | |
| title = "Research Blog", | |
| subtitle = "Latest insights, discoveries, and research updates", | |
| onSearch, | |
| onViewChange, | |
| currentView = "grid", | |
| showViewToggle = true | |
| }: BlogHeaderProps) { | |
| const [searchQuery, setSearchQuery] = useState(""); | |
| const handleSubmit = (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| if (onSearch && searchQuery.trim()) { | |
| onSearch(searchQuery); | |
| } | |
| }; | |
| return ( | |
| <div className="relative overflow-hidden rounded-[2.5rem] border border-gray-200/50 bg-white/40 p-10 md:p-16 mb-12 shadow-sm backdrop-blur-xl dark:border-gray-800/50 dark:bg-gray-900/40"> | |
| <div className="absolute top-0 right-0 w-96 h-96 bg-primary/20 rounded-full blur-3xl opacity-60" /> | |
| <div className="absolute bottom-0 left-0 w-96 h-96 bg-secondary/20 rounded-full blur-3xl opacity-60" /> | |
| <div className="relative z-10 text-center max-w-3xl mx-auto"> | |
| <motion.div | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| className="inline-flex items-center gap-2 rounded-full border border-primary/20 bg-primary/10 px-4 py-1.5 text-sm font-semibold tracking-wide text-primary mb-6" | |
| > | |
| <BookOpen className="h-4 w-4" /> | |
| Latest Research | |
| </motion.div> | |
| <motion.h1 | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| transition={{ delay: 0.1 }} | |
| className="text-4xl md:text-5xl lg:text-6xl font-black tracking-tight mb-4" | |
| > | |
| {title} | |
| </motion.h1> | |
| <motion.p | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| transition={{ delay: 0.2 }} | |
| className="text-lg md:text-xl text-gray-600 dark:text-gray-400 leading-relaxed max-w-2xl mx-auto" | |
| > | |
| {subtitle} | |
| </motion.p> | |
| {onSearch && ( | |
| <motion.form | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| transition={{ delay: 0.3 }} | |
| onSubmit={handleSubmit} | |
| className="mt-8 max-w-lg mx-auto" | |
| > | |
| <div className="relative group"> | |
| <Search className="absolute left-5 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400 group-hover:text-primary transition-colors" /> | |
| <input | |
| type="text" | |
| value={searchQuery} | |
| onChange={(e) => setSearchQuery(e.target.value)} | |
| placeholder="Search articles..." | |
| className="w-full rounded-full border border-gray-200/60 bg-white/60 dark:border-gray-700/60 dark:bg-gray-800/60 py-4 pl-14 pr-6 shadow-sm backdrop-blur-md focus:border-primary focus:outline-none focus:ring-4 focus:ring-primary/10 transition-all text-gray-900 dark:text-white placeholder:text-gray-400" | |
| /> | |
| </div> | |
| </motion.form> | |
| )} | |
| {showViewToggle && onViewChange && ( | |
| <motion.div | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| transition={{ delay: 0.4 }} | |
| className="flex justify-center gap-3 mt-8" | |
| > | |
| <button | |
| onClick={() => onViewChange("grid")} | |
| className={`flex items-center justify-center p-3 rounded-xl transition-all ${currentView === "grid" ? "bg-primary text-white shadow-md shadow-primary/20 scale-105" : "bg-white/60 dark:bg-gray-800/60 text-gray-500 hover:bg-white dark:hover:bg-gray-800 backdrop-blur-md border border-gray-200/50 dark:border-gray-700/50"}`} | |
| aria-label="Grid view" | |
| > | |
| <Grid className="h-5 w-5" /> | |
| </button> | |
| <button | |
| onClick={() => onViewChange("list")} | |
| className={`flex items-center justify-center p-3 rounded-xl transition-all ${currentView === "list" ? "bg-primary text-white shadow-md shadow-primary/20 scale-105" : "bg-white/60 dark:bg-gray-800/60 text-gray-500 hover:bg-white dark:hover:bg-gray-800 backdrop-blur-md border border-gray-200/50 dark:border-gray-700/50"}`} | |
| aria-label="List view" | |
| > | |
| <List className="h-5 w-5" /> | |
| </button> | |
| </motion.div> | |
| )} | |
| </div> | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 4.76 kB
- Xet hash:
- 17f0e4eeb7f4fac7eab7af2830023c3a843e7767bc74ae364e2d93bf4ce99df9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.