ActuallyCookie's picture
Upload components/Hero.jsx with huggingface_hub
3177dbf verified
Raw History Blame Contribute Delete
3.83 kB
import { useState, useEffect } from 'react';
export default function Hero() {
const [greeting, setGreeting] = useState('Hi');
const [apiMessage, setApiMessage] = useState('');
const [loading, setLoading] = useState(true);
useEffect(() => {
fetch('/api/hello')
.then(res => res.json())
.then(data => {
setApiMessage(data.message);
setLoading(false);
})
.catch(() => {
setApiMessage('Unable to fetch greeting');
setLoading(false);
});
}, []);
return (
<section className="min-h-[calc(100vh-8rem)] flex flex-col items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-50 px-4">
<div className="text-center">
<h1 className="text-6xl md:text-8xl font-extrabold text-gray-900 mb-6 tracking-tight">
{greeting}
</h1>
<p className="text-lg md:text-xl text-gray-600 mb-4 max-w-md mx-auto">
Welcome to your new Next.js application
</p>
<div className="h-6 mb-8">
{loading ? (
<p className="text-sm text-gray-400 animate-pulse">Loading API greeting...</p>
) : (
<p className="text-sm font-medium text-blue-600 bg-blue-50 inline-block px-3 py-1 rounded-full">
{apiMessage}
</p>
)}
</div>
<button
onClick={() => setGreeting(greeting === 'Hi' ? 'Hello' : 'Hi')}
className="px-6 py-3 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
>
Toggle Greeting
</button>
</div>
<div className="mt-12 grid grid-cols-1 md:grid-cols-3 gap-6 max-w-4xl w-full">
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div className="h-10 w-10 bg-blue-100 rounded-lg flex items-center justify-center mb-4">
<svg className="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<h3 className="font-semibold text-gray-900 mb-2">Fast</h3>
<p className="text-gray-500 text-sm">Built with Next.js for optimal performance</p>
</div>
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div className="h-10 w-10 bg-green-100 rounded-lg flex items-center justify-center mb-4">
<svg className="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<h3 className="font-semibold text-gray-900 mb-2">Reliable</h3>
<p className="text-gray-500 text-sm">Type-safe and production ready</p>
</div>
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div className="h-10 w-10 bg-purple-100 rounded-lg flex items-center justify-center mb-4">
<svg className="h-6 w-6 text-purple-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z" />
</svg>
</div>
<h3 className="font-semibold text-gray-900 mb-2">Scalable</h3>
<p className="text-gray-500 text-sm">Component-based architecture</p>
</div>
</div>
</section>
);
}