generated from enflujo/enflujo-plantilla-astro
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 Organizar Ficha en partes para no enloquecer
- Loading branch information
Showing
6 changed files
with
135 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
--- | ||
|
||
<div class="seccionDatos" id="fichaImagenes"> | ||
<div id="listaImagenes" class="contenido imagenes"></div> | ||
</div> | ||
|
||
<script> | ||
import 'photoswipe/style.css'; | ||
import Galeria from 'photoswipe/lightbox'; | ||
import { datosFicha } from '@/utilidades/cerebro'; | ||
|
||
const seccionImagenes = document.getElementById('fichaImagenes') as HTMLDivElement; | ||
const contenedorImagenes = document.getElementById('listaImagenes') as HTMLDivElement; | ||
const urlBase = import.meta.env.BASE_URL; | ||
|
||
const galeria = new Galeria({ | ||
gallery: '#listaImagenes', | ||
children: 'a', | ||
pswpModule: () => import('photoswipe') | ||
}); | ||
|
||
galeria.init(); | ||
|
||
datosFicha.subscribe((datos) => { | ||
if (!datos.visible) return; | ||
|
||
// Llenar imágenes, si hay | ||
if (datos.imagenes && datos.imagenes.length) { | ||
contenedorImagenes.innerHTML = ''; | ||
seccionImagenes.style.display = 'flex'; | ||
|
||
datos.imagenes.forEach((elemento) => { | ||
const imagenAncho = document.createElement('a'); | ||
imagenAncho.classList.add('imagenAncho'); | ||
imagenAncho.href = `${urlBase}/imgs/fotos/${datos.id}/${elemento.grande}`; | ||
imagenAncho.setAttribute('data-pswp-width', `${elemento.ancho}`); | ||
imagenAncho.setAttribute('data-pswp-height', `${elemento.alto}`); | ||
|
||
const imagen = document.createElement('img'); | ||
imagen.classList.add('imagenFicha'); | ||
imagen.src = `${urlBase}/imgs/fotos/${datos.id}/${elemento.peque}`; | ||
imagen.alt = ''; | ||
|
||
imagenAncho.appendChild(imagen); | ||
contenedorImagenes.append(imagenAncho); | ||
imagen.alt = ''; | ||
|
||
imagen.addEventListener('click', () => { | ||
imagen.classList.toggle('grande'); | ||
}); | ||
}); | ||
} else { | ||
seccionImagenes.style.display = 'none'; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
--- | ||
|
||
<div class="seccionRed" id="fichaRed" data-nombre="red"> | ||
<a | ||
id="enlaceRedAcademia" | ||
href="#" | ||
target="_blank" | ||
style={`background-image: url(${import.meta.env.BASE_URL}/imgs/icono-enlace-externo.svg`} | ||
)></a> | ||
<iframe id="redAcademica"></iframe> | ||
|
||
<p class="pieDeFoto">Red de colaboración entre personas</p> | ||
</div> | ||
|
||
<script> | ||
import { datosFicha } from '@/utilidades/cerebro'; | ||
|
||
datosFicha.subscribe((datos) => { | ||
if (!datos.visible) return; | ||
/** | ||
* RED Académica de lideres | ||
*/ | ||
const seccionRed = document.getElementById('fichaRed') as HTMLDivElement; | ||
const contenedorRed = document.getElementById('redAcademica') as HTMLIFrameElement; | ||
const enlaceRed = document.getElementById('enlaceRedAcademia') as HTMLAnchorElement; | ||
const idAcademia = datos.academia; | ||
|
||
if (idAcademia) { | ||
seccionRed.style.display = 'block'; | ||
contenedorRed.src = `https://academia.uniandes.edu.co/academynetsweb/personnet.html?&personId=${idAcademia}&highlight=${idAcademia}&minified=true&scale=50&force=-100"`; | ||
enlaceRed.onclick = () => { | ||
const enlace = `https://academia.uniandes.edu.co/academynetsweb/personnet.html?&personId=${idAcademia}&highlight=${idAcademia}`; | ||
enlaceRed.setAttribute('href', enlace); | ||
}; | ||
} else { | ||
contenedorRed.src = ''; | ||
seccionRed.style.display = 'none'; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default class SeccionFicha extends HTMLElement { | ||
lista: HTMLUListElement; | ||
|
||
constructor() { | ||
super(); | ||
this.lista = this.querySelector<HTMLUListElement>('.contenido') as HTMLUListElement; | ||
} | ||
|
||
agregarElemento(elemento: HTMLElement) { | ||
this.lista.appendChild(elemento); | ||
} | ||
|
||
limpiar() { | ||
this.lista.innerHTML = ''; | ||
} | ||
|
||
mostrar() { | ||
this.classList.add('visible'); | ||
} | ||
|
||
esconder() { | ||
this.classList.remove('visible'); | ||
} | ||
} | ||
|
||
customElements.define('enflujo-seccion-ficha', SeccionFicha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters