🖼️ blog listing styles updates
This commit is contained in:
125
components/blog/blog-card.tsx
Normal file
125
components/blog/blog-card.tsx
Normal file
@@ -0,0 +1,125 @@
|
||||
import Link from 'next/link'
|
||||
import Image from 'next/image'
|
||||
import { Post } from '@/lib/types/frontmatter'
|
||||
import { formatDate } from '@/lib/utils'
|
||||
|
||||
interface BlogCardProps {
|
||||
post: Post
|
||||
variant: 'image-top' | 'image-side' | 'text-only'
|
||||
}
|
||||
|
||||
export function BlogCard({ post, variant }: BlogCardProps) {
|
||||
const hasImage = !!post.frontmatter.image
|
||||
|
||||
if (!hasImage || variant === 'text-only') {
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 p-6 h-full cyber-glitch-hover">
|
||||
<div className="border-l-4 pl-4 mb-4" style={{ borderColor: 'var(--neon-pink)' }}>
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} <span style={{ color: 'var(--neon-cyan)' }}>//</span> {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
if (variant === 'image-side') {
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 overflow-hidden h-full cyber-glitch-hover">
|
||||
<div className="flex flex-col md:flex-row h-full">
|
||||
<div className="md:w-1/3 relative h-64 md:h-auto bg-zinc-900">
|
||||
<Image
|
||||
src={post.frontmatter.image!}
|
||||
alt={post.frontmatter.title}
|
||||
fill
|
||||
className="object-cover grayscale"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-zinc-900/60" />
|
||||
</div>
|
||||
<div className="md:w-2/3 p-6">
|
||||
<div className="border-l-4 border-cyan-400 pl-4 mb-4">
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} // {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 overflow-hidden transition-all duration-300 cyber-glitch-hover h-full">
|
||||
<div className="relative h-64 bg-zinc-900">
|
||||
<Image
|
||||
src={post.frontmatter.image!}
|
||||
alt={post.frontmatter.title}
|
||||
fill
|
||||
className="object-cover grayscale"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-zinc-900/60" />
|
||||
</div>
|
||||
<div className="p-6">
|
||||
<div className="border-l-4 pl-4 mb-4" style={{ borderColor: 'var(--neon-pink)' }}>
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} <span style={{ color: 'var(--neon-cyan)' }}>//</span> {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
52
components/blog/navbar.tsx
Normal file
52
components/blog/navbar.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { ThemeToggle } from '@/components/theme-toggle'
|
||||
|
||||
export function Navbar() {
|
||||
const [isVisible, setIsVisible] = useState(true)
|
||||
const [lastScrollY, setLastScrollY] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
const currentScrollY = window.scrollY
|
||||
|
||||
if (currentScrollY < 10) {
|
||||
setIsVisible(true)
|
||||
} else if (currentScrollY > lastScrollY) {
|
||||
setIsVisible(false)
|
||||
} else {
|
||||
setIsVisible(true)
|
||||
}
|
||||
|
||||
setLastScrollY(currentScrollY)
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', handleScroll, { passive: true })
|
||||
return () => window.removeEventListener('scroll', handleScroll)
|
||||
}, [lastScrollY])
|
||||
|
||||
return (
|
||||
<nav className={`border-b-4 border-slate-700 bg-slate-900 dark:bg-zinc-950 sticky top-0 z-50 ${isVisible ? 'navbar-visible' : 'navbar-hidden'}`}>
|
||||
<div className="max-w-7xl mx-auto px-6 py-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-8">
|
||||
<Link href="/" className="font-mono text-sm uppercase tracking-wider transition-colors cursor-pointer" style={{ color: 'var(--neon-cyan)' }}>
|
||||
< HOME
|
||||
</Link>
|
||||
<span className="font-mono text-sm text-zinc-100 dark:text-zinc-300 uppercase tracking-wider">
|
||||
// <span style={{ color: 'var(--neon-pink)' }}>BLOG</span> ARCHIVE
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-6">
|
||||
<Link href="/about" className="font-mono text-sm text-zinc-400 dark:text-zinc-500 uppercase tracking-wider hover:text-cyan-400 dark:hover:text-cyan-300 transition-colors cursor-pointer">
|
||||
[ABOUT]
|
||||
</Link>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
19
components/blog/search-bar.tsx
Normal file
19
components/blog/search-bar.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
interface SearchBarProps {
|
||||
searchQuery: string
|
||||
onSearchChange: (value: string) => void
|
||||
}
|
||||
|
||||
export function SearchBar({ searchQuery, onSearchChange }: SearchBarProps) {
|
||||
return (
|
||||
<div className="flex-1 flex items-center border-2 border-slate-700 bg-zinc-900 transition-all focus-within:border-[var(--neon-cyan)] focus-within:shadow-[0_0_10px_var(--neon-cyan),0_0_20px_rgba(0,255,255,0.5),inset_0_0_10px_rgba(0,255,255,0.1)]">
|
||||
<span className="pl-4 pr-2 font-mono text-lg" style={{ color: 'var(--neon-cyan)' }}>></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="SEARCH POSTS..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
className="flex-1 bg-transparent font-mono text-zinc-100 dark:text-zinc-100 px-2 py-3 focus:outline-none placeholder:text-zinc-600 uppercase text-sm"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
20
components/blog/sort-dropdown.tsx
Normal file
20
components/blog/sort-dropdown.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
type SortOption = 'newest' | 'oldest' | 'title'
|
||||
|
||||
interface SortDropdownProps {
|
||||
sortBy: SortOption
|
||||
onSortChange: (value: SortOption) => void
|
||||
}
|
||||
|
||||
export function SortDropdown({ sortBy, onSortChange }: SortDropdownProps) {
|
||||
return (
|
||||
<select
|
||||
value={sortBy}
|
||||
onChange={(e) => onSortChange(e.target.value as SortOption)}
|
||||
className="border-2 border-slate-700 bg-zinc-900 dark:bg-zinc-900 text-zinc-100 dark:text-zinc-100 font-mono px-6 py-3 uppercase text-sm cyber-focus-pink transition-all hover:border-cyan-400 cursor-pointer"
|
||||
>
|
||||
<option value="newest" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>NEWEST FIRST</option>
|
||||
<option value="oldest" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>OLDEST FIRST</option>
|
||||
<option value="title" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>BY TITLE</option>
|
||||
</select>
|
||||
)
|
||||
}
|
||||
41
components/blog/tag-filter.tsx
Normal file
41
components/blog/tag-filter.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
interface TagFilterProps {
|
||||
allTags: string[]
|
||||
selectedTags: string[]
|
||||
onToggleTag: (tag: string) => void
|
||||
onClearTags: () => void
|
||||
}
|
||||
|
||||
export function TagFilter({ allTags, selectedTags, onToggleTag, onClearTags }: TagFilterProps) {
|
||||
if (allTags.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-6 mb-12">
|
||||
<p className="font-mono text-xs text-zinc-500 uppercase tracking-widest mb-4">
|
||||
FILTER BY TAG
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{allTags.map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
onClick={() => onToggleTag(tag)}
|
||||
className={`px-4 py-2 font-mono text-xs uppercase border-2 transition-colors cursor-pointer ${
|
||||
selectedTags.includes(tag)
|
||||
? 'bg-cyan-400 border-cyan-400 text-slate-900'
|
||||
: 'bg-zinc-900 border-slate-700 text-zinc-400 hover:border-cyan-400 hover:text-cyan-400'
|
||||
}`}
|
||||
>
|
||||
#{tag}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{selectedTags.length > 0 && (
|
||||
<button
|
||||
onClick={onClearTags}
|
||||
className="mt-4 font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors cursor-pointer"
|
||||
>
|
||||
> CLEAR FILTERS
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user