always use Typescript, and make code for NextJs project
EyeCatchingComponent.tsx
) in your components
directory.import React from 'react';
import styled from 'styled-components';
interface EyeCatchingComponentProps {
title: string;
description: string;
imageUrl: string;
}
const Container = styled.div`
background-color: #f0f8ff; /* Light background */
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
max-width: 800px;
margin: 2rem auto;
@media (max-width: 768px) {
padding: 1.5rem;
}
`;
const Title = styled.h2`
color: #333;
font-size: 2.5rem;
margin-bottom: 1rem;
`;
const Description = styled.p`
color: #666;
font-size: 1.1rem;
line-height: 1.6;
margin-bottom: 2rem;
`;
const Image = styled.img`
max-width: 100%;
height: auto;
border-radius: 4px;
margin-bottom: 1.5rem;
`;
const EyeCatchingComponent: React.FC<EyeCatchingComponentProps> = ({ title, description, imageUrl }) => {
return (
<Container>
<Title>{title}</Title>
<Image src={imageUrl} alt={title} />
<Description>{description}</Description>
</Container>
);
};
export default EyeCatchingComponent;
import EyeCatchingComponent from '../components/EyeCatchingComponent';
export default function HomePage() {
return (
<div>
<EyeCatchingComponent
title="Welcome to Our Awesome App!"
description="Experience the best features and user interface. Our app is designed to provide you with a seamless and enjoyable experience."
imageUrl="/images/hero-image.jpg" // Replace with your image path
/>
{/* Other page content */}
</div>
);
}
tsconfig.json
for better type checking.next/image
or services like Cloudinary.import Image from 'next/image';
//... inside EyeCatchingComponent
<Image src={imageUrl} alt={title} width={800} height={400} layout="responsive" />