Okay, let's create a "Services" component for your great-little-minds-react repository.
We'll follow these steps:
- Create a new folder for the
Services component: src/components/Services.
- Create
ServiceItem.js: This will be a small component to render a single service.
- Create
Services.js: This will be the main component that holds an array of service data and renders multiple ServiceItem components.
- Create
Services.css: For styling the components.
- Add sample images: We'll need a couple of placeholder images.
- Integrate
Services into App.js: To display it on the main page.
Step 1: Clone the base repository (if you haven't already)
git clone https://github.com/R1c4ar6/great-little-minds-react.git
cd great-little-minds-react
npm install
npm start
Your app should be running at http://localhost:3000.
Step 2: Create a Services directory and files
Create the following files and folders:
src/
└── components/
└── Services/
├── Services.js
├── ServiceItem.js
└── Services.css
└── assets/ <-- Create this folder if it doesn't exist
└── images/ <--- Create this folder
└── service1.jpg <-- You'll put your images here
└── service2.jpg
Step 3: Add Sample Images
Download two small placeholder images and save them in src/assets/images/ as service1.jpg and service2.jpg. You can use any images you like, or find some temporary ones online.
Step 4: Code the Components and Styles
src/components/Services/ServiceItem.js
This component will display a single service item.
import React from 'react';
import './Services.css'; // Import the CSS for styling
const ServiceItem = ({ image, description, price }) => {
return (
<div className="service-item">
<img src={image} alt="Service" className="service-image" />
<p className="service-description">{description}</p>
<span className="service-price">{price}</span>
</div>
);
};
export default ServiceItem;
src/components/Services/Services.js
This component will manage the data for your services and render multiple ServiceItem components.
import React from 'react';
import ServiceItem from './ServiceItem';
import './Services.css';
// Import your service images
import service1Image from '../../assets/images/service1.jpg'; // Adjust path if needed
import service2Image from '../../assets/images/service2.jpg'; // Adjust path if needed
// Add more imports for additional service images
const Services = () => {
// Define your service data
const servicesData = [
{
id: 1,
image: service1Image,
description: 'Incluye uniformes, material didáctico y seguro médico privado.',
price: '800€',
},
{
id: 2,
image: service2Image,
description: 'Actividades extracurriculares de música, arte y deporte.',
price: '150€/mes',
},
{
id: 3,
image: service1Image, // Reusing image for demonstration
description: 'Servicio de comedor con menús saludables y adaptados.',
price: '120€/mes',
},
{
id: 4,
image: service2Image, // Reusing image for demonstration
description: 'Transporte escolar con rutas flexibles y monitores acompañantes.',
price: '90€/mes',
},
];
return (
<section className="services-section">
<h2 className="services-title">Nuestros Servicios</h2>
<div className="services-container">
{servicesData.map(service => (
<ServiceItem
key={service.id}
image={service.image}
description={service.description}
price={service.price}
/>
))}
</div>
</section>
);
};
export default Services;
src/components/Services/Services.css
This file will contain the styles for both Services and ServiceItem.
/* Services Section Styles */
.services-section {
padding: 40px 20px;
background-color: #f9f9f9;
text-align: center;
}
.services-title {
font-size: 2.5em;
color: #333;
margin-bottom: 40px;
font-family: 'Comic Sans MS', cursive, sans-serif; /* Adjust font as per repo's style */
}
.services-container {
display: flex;
flex-direction: column; /* Stack items vertically by default */
gap: 30px; /* Space between service items */
max-width: 1000px; /* Limit width for better readability */
margin: 0 auto; /* Center the container */
}
/* Service Item Styles */
.service-item {
display: flex; /* Use flexbox to align items horizontally */
align-items: center; /* Vertically center items */
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: left; /* Align text within the item */
transition: transform 0.3s ease;
}
.service-item:hover {
transform: translateY(-5px);
}
.service-image {
width: 100px; /* Fixed width for the image */
height: 100px; /* Fixed height for the image */
object-fit: cover; /* Cover the area, cropping if necessary */
border-radius: 50%; /* Make image circular */
margin-right: 20px; /* Space between image and description */
flex-shrink: 0; /* Prevent image from shrinking */
border: 3px solid #66bb6a; /* A nice green border */
}
.service-description {
flex-grow: 1; /* Allow description to take up available space */
font-size: 1.1em;
color: #555;
margin: 0; /* Remove default paragraph margin */
}
.service-price {
font-size: 1.4em;
font-weight: bold;
color: #007bff; /* A prominent color for the price */
margin-left: auto; /* Push price to the far right edge */
flex-shrink: 0; /* Prevent price from shrinking */
padding-left: 20px; /* Add some padding to separate from description */
}
/* Responsive adjustments */
@media (max-width: 768px) {
.services-title {
font-size: 2em;
}
.service-item {
flex-direction: column; /* Stack items vertically on small screens */
text-align: center;
padding: 15px;
}
.service-image {
margin-right: 0;
margin-bottom: 15px; /* Space below image */
}
.service-description {
font-size: 1em;
margin-bottom: 10px;
}
.service-price {
margin-left: 0; /* Remove auto margin on small screens */
padding-left: 0;
}
}
Step 5: Integrate into App.js
Now, open src/App.js and import and render the Services component. You can place it wherever you think it fits best, for example, after the existing Hero or AboutUs components.
import React from 'react';
import './App.css';
import Hero from './components/Hero/Hero';
import AboutUs from './components/AboutUs/AboutUs';
import Courses from './components/Courses/Courses'; // Assuming this exists
import Footer from './components/Footer/Footer'; // Assuming this exists
import Services from './components/Services/Services'; // <--- IMPORT THIS
function App() {
return (
<div className="App">
<Hero />
<AboutUs />
{/* Add your Services component here */}
<Services /> {/* <--- ADD THIS LINE */}
<Courses />
<Footer />
</div>
);
}
export default App;
Step 6: Run and Verify
Save all the files. Your development server (npm start) should automatically recompile. Open your browser to http://localhost:3000. You should now see a new "Nuestros Servicios" section displaying the service items with the image on the left, description in the middle, and price on the right.
The styling uses flexbox to achieve the desired layout and includes some basic responsiveness for smaller screens. Feel free to adjust the font-family, colors, and sizes in Services.css to better match the existing design of your great-little-minds-react app.