Pricing Sections (BuscaPrecios)
TheBuscaPrecios component displays pricing tiers in a responsive grid layout with detailed feature lists. It consumes data from precios.json and renders pricing cards for web pages and online stores.
Component Location
File:src/sections/BuscaPrecios.astro
Data Source
Pricing data is loaded fromsrc/data/precios.json, which contains two pricing categories:
- ID 0: Precios de páginas web (Web page pricing)
- ID 1: Precios de tiendas online (Online store pricing)
Component Structure
Fromsrc/sections/BuscaPrecios.astro:1-70:
Usage
Display Web Page Pricing
Display Online Store Pricing
Props
| Prop | Type | Required | Description |
|---|---|---|---|
idServicio | number | Yes | Index of the pricing category (0 or 1) |
Pricing Card Structure
Each pricing card displays:-
Header section (colored background)
- Title (
card.titulo) - Subtitle (
card.subtitulo)
- Title (
-
Price display
- Large price number (
card.precio) - ”+ iva” label
- Large price number (
-
Feature list (up to 17 details)
card.detalle1throughcard.detalle17- Each non-empty detail is displayed with an
<hr>separator
-
CTA button
- “Reservar ahora” button linking to
/contacto/
- “Reservar ahora” button linking to
Hero Section
The component includes a hero section with:- Background image from
servicio.background - Dark overlay (
rgba(0, 0, 0, 0.5)) - Title and subtitle
- CTA button to alternate pricing page
Hero Styles
Fromsrc/sections/BuscaPrecios.astro:100-130:
Pricing Grid Layout
The pricing cards are displayed in a responsive 3-column grid:Grid Styles
Fromsrc/sections/BuscaPrecios.astro:77-94:
Highlighted Card (Middle Column)
The middle pricing card (index 1) receives special highlighting:Highlighted Styles
Data Requirements
Each pricing service inprecios.json must have:
Feature List Rendering
The component conditionally renders each detail field:Buttons and CTAs
Hero Button
- Links to alternate pricing page
- Light button style with top margin
Card CTA Button
- Links to contact page
- Green button style with bottom margin
- Spanish text: “Reservar ahora” (Reserve now)
WebTienda Component
The section includes theWebTienda component at the bottom:
Responsive Behavior
While specific mobile styles aren’t shown in the excerpt, the component uses:- CSS Grid for flexible layout
- Percentage-based heights (
50vhfor hero) - Max-width containers (
1200px)
Styling Classes
| Class | Purpose |
|---|---|
.seccionBlanco | White background section |
.seccionColor | Colored background section |
.hero | Hero banner with background image |
.overlay | Dark overlay on hero |
.columnas | Grid container for pricing cards |
.columna | Individual pricing card |
.columna-amarilla | Yellow background for highlighted card |
.servicio | Card header section |
.servicio-azul | Blue background for highlighted header |
.btn-verde | Green CTA button |
.btn-light | Light-colored button |
Example: Adding to a Page
Customization
To customize the pricing section:- Edit data: Modify
src/data/precios.json - Change colors: Update
.servicio-azuland.columna-amarillaclasses - Adjust grid: Modify
grid-template-columnsin.columnas - Update button text: Change “Reservar ahora” to your preferred CTA
- Add mobile styles: Add media queries for responsive breakpoints
Best Practices
- Limit to 3 cards: The design shows
slice(0, 3)for optimal display - Use empty strings: Set unused
detalleNfields to""in JSON - Consistent pricing: Use numeric strings without currency symbols in
preciofield - WebP images: Use WebP format for background images
- Descriptive features: Make each
detalleclear and concise - Highlight middle card: The center card gets automatic highlighting