To implement the "Services" component as requested, we'll follow a clean and modular approach using React functional components and CSS for styling. The component will display each service with an image, description, and price, aligned horizontally in a flexible layout.
🧩 Step-by-Step Implementation
1. Create the Services Component
Create a new file named Services.js inside your src/components/ directory (or any other preferred location).
// src/components/Services.js
import React from 'react';
import './Services.css';
const Services = () => {
const services = [
{
id: 1,
image: 'https://via.placeholder.com/100',
description: 'Incluye uniformes y seguro médico privado',
price: '800€'
},
{
id: 2,
image: 'https://via.placeholder.com/100',
description: 'Servicios de asesoría laboral y capacitación',
price: '1200€'
},
{
id: 3,
image: 'https://via.placeholder.com/100',
description: 'Asistencia en contratación y nómina',
price: '900€'
}
];
return (
<div className="services">
{services.map((service) => (
<div key={service.id} className="service-item">
<img src={service.image} alt={service.description} />
<div className="description">{service.description}</div>
<div className="price">{service.price}</div>
</div>
))}
</div>
);
};
export default Services;
2. Add Styling with CSS
Create a Services.css file in the same directory as Services.js:
/* src/components/Services.css */
.services {
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px;
max-width: 800px;
margin: 0 auto;
}
.service-item {
display: flex;
align-items: center;
gap: 15px;
padding: 15px 20px;
background-color: #f9f9f9;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.service-item img {
width: 100px;
height: auto;
border-radius: 50%;
object-fit: cover;
}
.description {
flex: 1;
font-size: 1rem;
color: #333;
}
.price {
font-size: 1.1rem;
font-weight: bold;
color: #2c3e50;
}
3. Include the Services Component in App.js
Update App.js to include the new Services component:
// src/App.js
import React from 'react';
import './App.css';
import Services from './components/Services';
function App() {
return (
<div className="App">
<header>
<h1>Great Little Minds</h1>
</header>
<main>
<Services />
</main>
</div>
);
}
export default App;
✅ Final Output
This implementation will render a list of services, each showing:
- A profile-style image on the left.
- A description in the middle.
- A price on the right.
Example layout for one service item:
[Image] | Incluye uniformes y seguro médico privado | 800€
📦 Optional Enhancements
- Add more services to the
services array.
- Use local images by placing them in a
public/images/ folder and referencing them via /images/your-image.jpg.
- Make it responsive using media queries or a CSS framework like Tailwind or Bootstrap.
Let me know if you'd like this integrated into a specific section (e.g., a "Services" page in a navigation menu)!