Carrusel de animales más fácil de entender
- Botones grandes con texto («Anteriores» / «Siguientes»; en móvil solo flechas, con nombre accesible). - Contador «1–3 / 10» y la siguiente tarjeta asomando por el borde para que se vea que hay más. - Última tarjeta «Ver todos los animales» que lleva a la página Adopta. - Arreglado: al empezar, «Anteriores» no salía desactivado (el scroll-snap desplazaba 4 px). - Versión del tema 2.3.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -506,11 +506,30 @@ function ga_carousel_open( $label = '' ) {
|
||||
);
|
||||
}
|
||||
|
||||
function ga_carousel_close() {
|
||||
/**
|
||||
* Cierre del carrusel: última tarjeta «Ver todos», botones con texto y contador («1–3 / 10»).
|
||||
*
|
||||
* @param string|false $more_url Enlace de la última tarjeta (por defecto, la página Adopta); false = sin ella.
|
||||
*/
|
||||
function ga_carousel_close( $more_url = null ) {
|
||||
$more_url = null === $more_url ? get_post_type_archive_link( 'animal' ) : $more_url;
|
||||
$arrow = function_exists( 'ga_icon' ) ? ga_icon( 'arrow' ) : '→';
|
||||
if ( $more_url ) {
|
||||
printf(
|
||||
'</div><div class="ga-carousel__nav"><button type="button" class="ga-carousel__btn" data-dir="-1" aria-label="%s">←</button><button type="button" class="ga-carousel__btn" data-dir="1" aria-label="%s">→</button></div></div>',
|
||||
esc_attr( ga__( 'Anteriores', 'Aurrekoak' ) ),
|
||||
esc_attr( ga__( 'Siguientes', 'Hurrengoak' ) )
|
||||
'<a class="ga-carousel__more" href="%s">%s<span>%s</span>%s</a>',
|
||||
esc_url( $more_url ),
|
||||
function_exists( 'ga_icon' ) ? ga_icon( 'paw' ) : '',
|
||||
esc_html( ga__( 'Ver todos los animales', 'Animalia guztiak ikusi' ) ),
|
||||
$arrow // SVG estático del tema.
|
||||
);
|
||||
}
|
||||
printf(
|
||||
'</div><div class="ga-carousel__nav"><button type="button" class="ga-carousel__btn" data-dir="-1">%1$s<span>%2$s</span></button>'
|
||||
. '<span class="ga-carousel__count" aria-live="polite"></span>'
|
||||
. '<button type="button" class="ga-carousel__btn" data-dir="1"><span>%3$s</span>%1$s</button></div></div>',
|
||||
$arrow, // SVG estático del tema.
|
||||
esc_html( ga__( 'Anteriores', 'Aurrekoak' ) ),
|
||||
esc_html( ga__( 'Siguientes', 'Hurrengoak' ) )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
document.querySelectorAll( '[data-ga-carousel]' ).forEach( function ( carousel ) {
|
||||
var track = carousel.querySelector( '.ga-carousel__track' );
|
||||
var buttons = carousel.querySelectorAll( '.ga-carousel__btn' );
|
||||
var count = carousel.querySelector( '.ga-carousel__count' );
|
||||
var cards = track ? track.querySelectorAll( '.ga-card' ) : [];
|
||||
if ( ! track ) {
|
||||
return;
|
||||
}
|
||||
@@ -62,6 +64,13 @@
|
||||
buttons[ 0 ].disabled = track.scrollLeft <= 2;
|
||||
buttons[ 1 ].disabled = track.scrollLeft >= max;
|
||||
carousel.classList.toggle( 'is-static', max <= 0 );
|
||||
// Contador «1–3 / 10»: tarjetas enteras a la vista (la tarjeta «Ver todos» no cuenta).
|
||||
if ( count && cards.length ) {
|
||||
var step = cards[ 0 ].offsetWidth + ( parseFloat( getComputedStyle( track ).columnGap ) || 0 );
|
||||
var first = Math.min( cards.length - 1, Math.round( track.scrollLeft / step ) );
|
||||
var last = Math.min( cards.length, first + Math.max( 1, Math.floor( ( track.clientWidth + 8 ) / step ) ) );
|
||||
count.textContent = ( first + 1 ) + ( last > first + 1 ? '–' + last : '' ) + ' / ' + cards.length;
|
||||
}
|
||||
}
|
||||
buttons.forEach( function ( button ) {
|
||||
button.addEventListener( 'click', function () {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'GA_THEME_VERSION', '2.3.0' );
|
||||
define( 'GA_THEME_VERSION', '2.3.1' );
|
||||
|
||||
require_once __DIR__ . '/inc/customizer.php';
|
||||
require_once __DIR__ . '/inc/dynamic-css.php';
|
||||
|
||||
@@ -553,23 +553,47 @@ body { overflow-x: clip; }
|
||||
display: grid; grid-auto-flow: column; gap: 22px;
|
||||
grid-auto-columns: calc((100% - 3 * 22px) / 4);
|
||||
overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
|
||||
scrollbar-width: none; padding: 6px 4px 16px; margin: -6px -4px 0;
|
||||
scrollbar-width: none; padding: 6px 4px 16px; margin: -6px -4px 0; scroll-padding-inline: 4px;
|
||||
}
|
||||
.ga-carousel__track::-webkit-scrollbar { display: none; }
|
||||
.ga-carousel__track > * { scroll-snap-align: start; }
|
||||
.ga-carousel__track:focus-visible { outline-offset: 6px; }
|
||||
.ga-carousel__nav { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
|
||||
/* Pensado para quien no está acostumbrado a los carruseles: la siguiente tarjeta asoma cortada (se ve que hay más),
|
||||
botones grandes con texto, contador «1–3 / 10» y una última tarjeta que lleva al listado completo. */
|
||||
.ga-carousel__nav { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; }
|
||||
.ga-carousel.is-static .ga-carousel__nav { display: none; }
|
||||
.ga-carousel__btn {
|
||||
width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--ga-green); background: transparent;
|
||||
color: var(--ga-green); font-size: 1.2rem; cursor: pointer; transition: background .2s, color .2s;
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px;
|
||||
border-radius: 999px; border: 2px solid var(--ga-green); background: #fff;
|
||||
color: var(--ga-green); font: 700 1rem/1 var(--ga-sans); cursor: pointer; transition: background .2s, color .2s, opacity .2s;
|
||||
}
|
||||
.ga-carousel__btn .ga-icon { width: 22px; height: 22px; }
|
||||
.ga-carousel__btn[data-dir="-1"] .ga-icon { transform: scaleX(-1); }
|
||||
.ga-carousel__btn:hover:not(:disabled) { background: var(--ga-green); color: var(--ga-on-primary); }
|
||||
.ga-carousel__btn:disabled { opacity: .3; cursor: default; }
|
||||
.ga-section--dark .ga-carousel__btn { border-color: #fff; color: #fff; }
|
||||
@media (max-width: 1080px) { .ga-carousel__track { grid-auto-columns: calc((100% - 2 * 22px) / 3); } }
|
||||
.ga-carousel__btn:disabled { opacity: .35; cursor: default; }
|
||||
.ga-carousel__count { min-width: 5.5em; text-align: center; font-weight: 700; color: var(--ga-muted); font-variant-numeric: tabular-nums; }
|
||||
.ga-section--dark .ga-carousel__btn { background: transparent; border-color: #fff; color: #fff; }
|
||||
.ga-section--dark .ga-carousel__btn:hover:not(:disabled) { background: #fff; color: var(--ga-green-dark); }
|
||||
.ga-section--dark .ga-carousel__count { color: var(--ga-on-dark-muted); }
|
||||
.ga-carousel__more {
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
|
||||
padding: 28px 20px; border-radius: var(--ga-radius); text-align: center; text-decoration: none;
|
||||
background: var(--ga-green-soft); border: 2px dashed color-mix(in srgb, var(--ga-green) 35%, transparent);
|
||||
color: var(--ga-green-dark); font: var(--ga-heading-weight) 1.35rem/1.15 var(--ga-serif);
|
||||
transition: background .2s, color .2s, border-color .2s;
|
||||
}
|
||||
.ga-carousel__more > svg:first-child { width: 58px; height: auto; color: var(--ga-green); transition: color .2s; }
|
||||
.ga-carousel__more:hover { background: var(--ga-green); border-color: var(--ga-green); color: var(--ga-on-primary); }
|
||||
.ga-carousel__more:hover > svg { color: currentColor; }
|
||||
.ga-carousel__track { grid-auto-columns: calc((100% - 3 * 22px) / 3.35); }
|
||||
@media (max-width: 1080px) { .ga-carousel__track { grid-auto-columns: calc((100% - 2 * 22px) / 2.35); } }
|
||||
@media (max-width: 760px) { .ga-carousel__track { grid-auto-columns: calc((100% - 22px) / 1.6); gap: 16px; } }
|
||||
@media (max-width: 480px) { .ga-carousel__track { grid-auto-columns: 82%; } }
|
||||
@media (max-width: 480px) {
|
||||
.ga-carousel__track { grid-auto-columns: 82%; }
|
||||
.ga-carousel__nav { gap: 10px; }
|
||||
.ga-carousel__btn { width: 54px; padding: 0; }
|
||||
.ga-carousel__btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
||||
}
|
||||
.ga-content .ga-carousel__track { grid-auto-columns: calc((100% - 22px) / 2.3); }
|
||||
|
||||
/* Filtros */
|
||||
|
||||
Reference in New Issue
Block a user