diff --git a/scripts/extract_site.py b/scripts/extract_site.py index 516341a..a66085b 100644 --- a/scripts/extract_site.py +++ b/scripts/extract_site.py @@ -225,10 +225,14 @@ def extract_container(elements): continue if wtype == "premium-addon-fancy-text": + # OJO: el widget trae una clave "text" generica (p.ej. "animado") + # que NO es contenido visible -- es un campo interno del + # plugin Premium Addons sin relacion con lo que se muestra. + # El texto real es prefijo + palabra rotativa + sufijo + # ("es" + "inevitable"/"necesaria"/"la solución"). out["widgets"].append({ "type": "fancy-text", "prefix": settings.get("premium_fancy_prefix_text", ""), - "base": settings.get("text", ""), "strings": [s.get("premium_text_strings_text_field", "") for s in settings.get("premium_fancy_text_strings", [])], "suffix": settings.get("premium_fancy_suffix_text", ""), }) diff --git a/src/components/Section.jsx b/src/components/Section.jsx index a71f90d..4622842 100644 --- a/src/components/Section.jsx +++ b/src/components/Section.jsx @@ -1,55 +1,19 @@ +import Content from './content/Content' + /** - * Renderiza una sección del JSON extraído del export de Elementor. - * - * Los campos `html` contienen HTML tal cual lo guardaba Elementor (con
, - * …, etc.). Lo inyectamos con - * dangerouslySetInnerHTML porque son datos nuestros ya saneados en origen. + * Renderiza una seccion del JSON extraido del export de Elementor + * (ver src/content/site.json y scripts/extract_site.py). El contenido en + * si (encabezados, parrafos, imagenes, listas y widgets como acordeon, + * tabs o carrusel) lo dibuja ; este componente solo pone el + *
con su ancla y variante visual. */ export default function Section({ section, variant = 'default' }) { - const { anchor, headings, paragraphs, images, lists } = section + const { anchor } = section return (
- {headings.slice(0, 2).map((h, i) => { - const Tag = (h.level || 'h2').toLowerCase() - return ( - - ) - })} - - {images.slice(0, 1).map((img, i) => ( -
- {img.alt -
- ))} - - {paragraphs.slice(0, 5).map((p, i) => ( -
- ))} - - {lists.length > 0 && ( -
- {lists.map((l, i) => ( -
    - {l.map((item, j) => ( -
  • - ))} -
- ))} -
- )} +
) diff --git a/src/components/content/Accordion.jsx b/src/components/content/Accordion.jsx new file mode 100644 index 0000000..f98a1c1 --- /dev/null +++ b/src/components/content/Accordion.jsx @@ -0,0 +1,35 @@ +import { useState } from 'react' +import Content from './Content' + +export default function Accordion({ items = [] }) { + const [openIndex, setOpenIndex] = useState(null) + if (!items.length) return null + + return ( +
+ {items.map((item, i) => { + const isOpen = openIndex === i + return ( +
+ + {isOpen && ( +
+ +
+ )} +
+ ) + })} +
+ ) +} diff --git a/src/components/content/Carousel.jsx b/src/components/content/Carousel.jsx new file mode 100644 index 0000000..2355057 --- /dev/null +++ b/src/components/content/Carousel.jsx @@ -0,0 +1,37 @@ +import { useRef } from 'react' +import Content from './Content' + +/** Carrusel de Elementor (nested-carousel): cada slide trae su propio + * contenido (encabezados/parrafos/imagenes), no solo una imagen. */ +export default function Carousel({ slides = [] }) { + const trackRef = useRef(null) + if (!slides.length) return null + + const scrollByAmount = (dir) => { + const el = trackRef.current + if (!el) return + el.scrollBy({ left: dir * el.clientWidth * 0.9, behavior: 'smooth' }) + } + + return ( +
+
+ {slides.map((slide, i) => ( +
+ +
+ ))} +
+ {slides.length > 1 && ( +
+ + +
+ )} +
+ ) +} diff --git a/src/components/content/Content.jsx b/src/components/content/Content.jsx new file mode 100644 index 0000000..3edce96 --- /dev/null +++ b/src/components/content/Content.jsx @@ -0,0 +1,102 @@ +import './content.css' +import Accordion from './Accordion' +import Tabs from './Tabs' +import Carousel from './Carousel' +import Slideshow from './Slideshow' +import ProgressBar from './ProgressBar' +import FancyText from './FancyText' + +/** + * Renderiza un bloque de contenido extraido de Elementor: encabezados, + * parrafos, imagenes, listas y widgets especiales (acordeon, tabs, + * carrusel, slideshow, barra de progreso, texto animado). + * + * Se usa tanto para una seccion completa de la home/paginas legales como, + * recursivamente, para el contenido anidado dentro de un panel de + * acordeon/tab/slide de carrusel (por eso "truncate" es false por defecto: + * los paneles anidados suelen ser pequenos y no conviene recortarlos). + */ +export default function Content({ + headings = [], + paragraphs = [], + images = [], + lists = [], + widgets = [], + truncate = false, +}) { + const shownHeadings = truncate ? headings.slice(0, 2) : headings + const shownParagraphs = truncate ? paragraphs.slice(0, 5) : paragraphs + const shownImages = truncate ? images.slice(0, 1) : images + + return ( + <> + {shownHeadings.map((h, i) => { + const Tag = (h.level || 'h2').toLowerCase() + return ( + + ) + })} + + {shownImages.map((img, i) => ( +
+ {img.alt +
+ ))} + + {shownParagraphs.map((p, i) => ( +
+ ))} + + {lists.length > 0 && ( +
+ {lists.map((l, i) => ( +
    + {l.map((item, j) => ( +
  • + ))} +
+ ))} +
+ )} + + {widgets.map((w, i) => ( + + ))} + + ) +} + +function Widget({ widget }) { + switch (widget.type) { + case 'accordion': + return + case 'tabs': + return + case 'carousel': + return + case 'slideshow': + return + case 'progressbar': + return + case 'fancy-text': + return + case 'carousel-decorative': + case 'nav-menu': + // Sin contenido propio que mostrar (ver scripts/extract_site.py). + return null + default: + if (import.meta.env.DEV && widget.type?.startsWith('unhandled:')) { + // eslint-disable-next-line no-console + console.warn('[Content] widget sin componente todavia:', widget.type, widget.settingsKeys) + } + return null + } +} diff --git a/src/components/content/FancyText.jsx b/src/components/content/FancyText.jsx new file mode 100644 index 0000000..880812a --- /dev/null +++ b/src/components/content/FancyText.jsx @@ -0,0 +1,27 @@ +import { useEffect, useState } from 'react' + +/** Widget "Fancy Text" de Premium Addons: prefijo fijo + palabra que + * rota entre varias opciones + sufijo fijo (p.ej. "es" + "inevitable" / + * "necesaria" / "la solución"). */ +export default function FancyText({ prefix = '', strings = [], suffix = '' }) { + const [index, setIndex] = useState(0) + + useEffect(() => { + if (strings.length < 2) return undefined + const id = setInterval(() => setIndex((i) => (i + 1) % strings.length), 2600) + return () => clearInterval(id) + }, [strings.length]) + + if (!prefix && !strings.length && !suffix) return null + const current = strings[index] || '' + + return ( +

+ {prefix}{' '} + + {current} + + {suffix} +

+ ) +} diff --git a/src/components/content/ProgressBar.jsx b/src/components/content/ProgressBar.jsx new file mode 100644 index 0000000..364762c --- /dev/null +++ b/src/components/content/ProgressBar.jsx @@ -0,0 +1,17 @@ +export default function ProgressBar({ leftLabel = '', rightLabel = '', percent = '0', image = {} }) { + const pct = Math.max(0, Math.min(100, parseFloat(percent) || 0)) + return ( +
+ {image.url && } +
+
+ {leftLabel} + {rightLabel} +
+
+
+
+
+
+ ) +} diff --git a/src/components/content/Slideshow.jsx b/src/components/content/Slideshow.jsx new file mode 100644 index 0000000..c09eb0d --- /dev/null +++ b/src/components/content/Slideshow.jsx @@ -0,0 +1,46 @@ +import { useEffect, useState } from 'react' + +/** Widget "Slides" de Elementor Pro: imagenes de fondo con texto opcional + * encima (en esta web la mayoria son solo imagen, sin texto). */ +export default function Slideshow({ slides = [] }) { + const [index, setIndex] = useState(0) + + useEffect(() => { + if (slides.length < 2) return undefined + const id = setInterval(() => setIndex((i) => (i + 1) % slides.length), 5000) + return () => clearInterval(id) + }, [slides.length]) + + if (!slides.length) return null + const slide = slides[index] + + return ( +
+
+ {slide.image?.url && ( + {slide.heading + )} + {(slide.heading || slide.description) && ( +
+ {slide.heading &&

{slide.heading}

} + {slide.description &&

{slide.description}

} + {slide.buttonText && {slide.buttonText}} +
+ )} +
+ {slides.length > 1 && ( +
+ {slides.map((_, i) => ( +
+ )} +
+ ) +} diff --git a/src/components/content/Tabs.jsx b/src/components/content/Tabs.jsx new file mode 100644 index 0000000..28cc7d6 --- /dev/null +++ b/src/components/content/Tabs.jsx @@ -0,0 +1,29 @@ +import { useState } from 'react' +import Content from './Content' + +export default function Tabs({ items = [] }) { + const [active, setActive] = useState(0) + if (!items.length) return null + + return ( +
+
+ {items.map((item, i) => ( + + ))} +
+
+ +
+
+ ) +} diff --git a/src/components/content/content.css b/src/components/content/content.css new file mode 100644 index 0000000..a5615be --- /dev/null +++ b/src/components/content/content.css @@ -0,0 +1,215 @@ +/* + * Estilos para los widgets de Elementor reconstruidos en React: + * acordeon, tabs, carrusel, slideshow, barra de progreso y texto animado. + * Reutilizan los tokens definidos en App.css (--color-accent, etc.). + * + * Nota de alcance: esta primera pasada prioriza estructura e + * interactividad correctas sobre replicar al pixel cada ajuste visual + * que traia cada widget en Elementor (bordes, sombras, tipografias + * especificas...). Es mas facil afinar esto despues, widget por widget, + * que intentar adivinarlo todo de una vez. + */ + +/* ---- Acordeon ---- */ +.pa-accordion { + margin: 1.5rem 0; + border-top: 1px solid rgba(0, 0, 0, 0.1); +} +.pa-accordion-item { + border-bottom: 1px solid rgba(0, 0, 0, 0.1); +} +.pa-accordion-trigger { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + padding: 1rem 0.25rem; + background: none; + border: none; + font: inherit; + font-weight: 600; + font-size: 1.05rem; + color: inherit; + text-align: left; + cursor: pointer; +} +.pa-accordion-icon { + flex: none; + color: var(--color-accent); + font-size: 1.2rem; + line-height: 1; +} +.pa-accordion-panel { + padding: 0 0.25rem 1.25rem; +} +.pa-accordion-panel .section-paragraph:last-child { + margin-bottom: 0; +} + +/* ---- Tabs ---- */ +.pa-tabs { + margin: 1.5rem 0; +} +.pa-tabs-list { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin-bottom: 1.25rem; +} +.pa-tabs-trigger { + padding: 0.5rem 1.1rem; + border-radius: 999px; + border: 1px solid rgba(0, 0, 0, 0.15); + background: transparent; + font: inherit; + font-weight: 600; + cursor: pointer; + color: inherit; +} +.pa-tabs-trigger.is-active { + background: var(--color-accent); + border-color: var(--color-accent); + color: #fff; +} +.pa-tabs-panel .section-paragraph:last-child { + margin-bottom: 0; +} + +/* ---- Carrusel ---- */ +.pa-carousel { + margin: 1.5rem 0; + position: relative; +} +.pa-carousel-track { + display: flex; + gap: 1.25rem; + overflow-x: auto; + scroll-snap-type: x mandatory; + padding-bottom: 0.5rem; + scrollbar-width: thin; +} +.pa-carousel-slide { + flex: 0 0 85%; + max-width: 420px; + scroll-snap-align: start; +} +.pa-carousel-controls { + display: flex; + gap: 0.5rem; + justify-content: flex-end; + margin-top: 0.5rem; +} +.pa-carousel-controls button { + width: 2.25rem; + height: 2.25rem; + border-radius: 50%; + border: 1px solid rgba(0, 0, 0, 0.15); + background: #fff; + font-size: 1.2rem; + line-height: 1; + cursor: pointer; +} +.pa-carousel-controls button:hover { + border-color: var(--color-accent); + color: var(--color-accent); +} + +/* ---- Slideshow ---- */ +.pa-slideshow { + margin: 1.5rem 0; +} +.pa-slideshow-frame { + position: relative; + border-radius: 10px; + overflow: hidden; +} +.pa-slideshow-frame img { + width: 100%; + aspect-ratio: 16 / 9; + object-fit: cover; +} +.pa-slideshow-caption { + position: absolute; + inset: auto 0 0 0; + padding: 1.25rem; + background: linear-gradient(0deg, rgba(0, 0, 0, 0.65), transparent); + color: #fff; +} +.pa-slideshow-dots { + display: flex; + gap: 0.5rem; + justify-content: center; + margin-top: 0.75rem; +} +.pa-slideshow-dot { + width: 0.55rem; + height: 0.55rem; + border-radius: 50%; + border: none; + background: rgba(0, 0, 0, 0.2); + padding: 0; + cursor: pointer; +} +.pa-slideshow-dot.is-active { + background: var(--color-accent); +} + +/* ---- Barra de progreso ---- */ +.pa-progressbar { + display: flex; + align-items: center; + gap: 0.75rem; + margin: 1rem 0; +} +.pa-progressbar-icon { + width: 2.5rem; + height: 2.5rem; + object-fit: contain; + flex: none; +} +.pa-progressbar-body { + flex: 1; + min-width: 0; +} +.pa-progressbar-labels { + display: flex; + justify-content: space-between; + font-size: 0.9rem; + font-weight: 600; + margin-bottom: 0.3rem; +} +.pa-progressbar-track { + height: 0.5rem; + border-radius: 999px; + background: rgba(0, 0, 0, 0.1); + overflow: hidden; +} +.pa-progressbar-fill { + height: 100%; + background: var(--color-accent); + border-radius: inherit; + transition: width 0.6s ease; +} + +/* ---- Texto animado ---- */ +.pa-fancy-text { + font-size: clamp(1.6rem, 4vw, 2.6rem); + font-weight: 700; + margin: 0.5rem 0 1.5rem; +} +.pa-fancy-text-rotating { + display: inline-block; + color: var(--color-accent); + animation: pa-fade-in 0.4s ease; +} +@keyframes pa-fade-in { + from { + opacity: 0; + transform: translateY(0.3em); + } + to { + opacity: 1; + transform: translateY(0); + } +} diff --git a/src/content/site.json b/src/content/site.json index d138715..36befa8 100644 --- a/src/content/site.json +++ b/src/content/site.json @@ -176,7 +176,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2025/11/question-2.png", + "url": "http://remigracion.es/wp-content/uploads/2025/11/question-2.png", "alt": "" } ], @@ -185,7 +185,6 @@ { "type": "fancy-text", "prefix": "es", - "base": "animado", "strings": [ "inevitable ", "necesaria ", @@ -196,7 +195,6 @@ { "type": "fancy-text", "prefix": "", - "base": "animado", "strings": [ "necesaria ", "inevitable ", @@ -238,7 +236,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/Sin-titulo-3-e1769970459949.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-3-e1769970459949.jpg" } }, { @@ -246,7 +244,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/Sin-titulo-4-e1769970494226.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-4-e1769970494226.jpg" } }, { @@ -254,7 +252,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/Sin-titulo-23.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-23.jpg" } }, { @@ -262,7 +260,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/Sin-titulo-1-e1769969819361.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-1-e1769969819361.jpg" } }, { @@ -270,7 +268,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/z-9.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/z-9.jpg" } }, { @@ -278,7 +276,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/Sin-titulo-5-e1769970526297.jpg" + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-5-e1769970526297.jpg" } }, { @@ -286,7 +284,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/titular-final-.png_0000_Sin-titulo-7.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/titular-final-.png_0000_Sin-titulo-7.png" } }, { @@ -294,7 +292,7 @@ "description": "", "buttonText": "", "image": { - "url": "/wp-content/uploads/2026/02/titular-final-.png_0001_Sin-titulo-6.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/titular-final-.png_0001_Sin-titulo-6.png" } } ] @@ -351,7 +349,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-24.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-24.jpg", "alt": "" } ], @@ -514,35 +512,35 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-15.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-15.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/Sin-titulo-30.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-30.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2025/10/f.elconfidencial.com_original_f8e_780_24a_f8e78024ab9c646d096e6ac8c2f8e503.jpg", + "url": "http://remigracion.es/wp-content/uploads/2025/10/f.elconfidencial.com_original_f8e_780_24a_f8e78024ab9c646d096e6ac8c2f8e503.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/remigracion.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/remigracion.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/Sin-titulo-18.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-18.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/Sin-titulo-18.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-18.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/Sin-titulo-11.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-11.jpg", "alt": "" }, { - "url": "/wp-content/uploads/2026/02/Sin-titulo-31.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-31.jpg", "alt": "" } ], @@ -558,7 +556,7 @@ "rightLabel": "80.7%", "percent": "80.7", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-8.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-8.png" } }, { @@ -567,7 +565,7 @@ "rightLabel": "60,1%", "percent": "60", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-9.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-9.png" } }, { @@ -576,7 +574,7 @@ "rightLabel": "55.7%", "percent": "56", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-10.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-10.png" } }, { @@ -585,7 +583,7 @@ "rightLabel": "70.9%", "percent": "71", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-11.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-11.png" } }, { @@ -594,7 +592,7 @@ "rightLabel": "80.7%", "percent": "80.7", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-8.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-8.png" } }, { @@ -603,7 +601,7 @@ "rightLabel": "60,1%", "percent": "60", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-9.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-9.png" } }, { @@ -612,7 +610,7 @@ "rightLabel": "55.7%", "percent": "56", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-10.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-10.png" } }, { @@ -621,7 +619,7 @@ "rightLabel": "70.9%", "percent": "71", "image": { - "url": "/wp-content/uploads/2026/02/placeholder-11.png" + "url": "http://remigracion.es/wp-content/uploads/2026/02/placeholder-11.png" } } ] @@ -675,7 +673,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Imagen2.png", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Imagen2.png", "alt": "" } ], @@ -873,7 +871,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-50.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-50.jpg", "alt": "" } ], @@ -891,7 +889,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-20.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-20.jpg", "alt": "" } ], @@ -911,7 +909,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-29.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-29.jpg", "alt": "" } ], @@ -931,7 +929,7 @@ ], "images": [ { - "url": "/wp-content/uploads/2026/02/Sin-titulo-22.jpg", + "url": "http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-22.jpg", "alt": "" } ],