|
1 | | -{% load static %} |
2 | 1 | {% comment %} |
3 | 2 | Testimonial Card — displays a carousel of testimonial quotes with author profiles. |
4 | 3 |
|
|
13 | 12 | {% endcomment %} |
14 | 13 |
|
15 | 14 | {% with carousel_id='_testimonials_cards_carousel' %} |
16 | | -<noscript> |
17 | | - <link rel="stylesheet" href="{% static 'css/v3/testimonial-card-nojs.css' %}"> |
18 | | -</noscript> |
| 15 | +{% comment %} |
| 16 | + Per-index visibility rules generated from the testimonials list (the count is |
| 17 | + data-driven, so they can't live as static rules in the CSS). The first <style> |
| 18 | + block runs in both JS and no-JS modes; only the nav-set for the checked radio |
| 19 | + is shown. The <noscript> block additionally switches the track to a CSS |
| 20 | + transform-based carousel: items are flex: 0 0 100% with gap: 0, so |
| 21 | + translateX(-N00%) shifts by exactly one item per radio. visibility: hidden on |
| 22 | + non-current items mirrors the JS-mode `inert` behavior so off-screen author |
| 23 | + links can't receive tab focus. Touch-swipe is lost in no-JS mode (the parent |
| 24 | + `.testimonial-card__post` clips with overflow: hidden) but arrow buttons work |
| 25 | + without scrolling the page. |
| 26 | +{% endcomment %} |
| 27 | +{% if testimonials %} |
| 28 | + <style> |
| 29 | + {% for testimonial in testimonials %} |
| 30 | + .testimonial-card:has(.testimonial-card__state[data-state-index="{{ forloop.counter0 }}"]:checked) .testimonial-card__nav-set[data-nav-index="{{ forloop.counter0 }}"] { display: inline-flex; } |
| 31 | + {% endfor %} |
| 32 | + </style> |
| 33 | + <noscript> |
| 34 | + <style> |
| 35 | + .testimonial-card__list { overflow: visible !important; gap: 0 !important; transition: transform 0.3s ease; } |
| 36 | + .testimonial-card__list-item { visibility: hidden; } |
| 37 | + |
| 38 | + {% for testimonial in testimonials %} |
| 39 | + .testimonial-card:has(.testimonial-card__state[data-state-index="{{ forloop.counter0 }}"]:checked) .testimonial-card__list { transform: translateX(-{{ forloop.counter0 }}00%); } |
| 40 | + .testimonial-card:has(.testimonial-card__state[data-state-index="{{ forloop.counter0 }}"]:checked) .testimonial-card__list-item[data-item-index="{{ forloop.counter0 }}"] { visibility: visible; } |
| 41 | + {% endfor %} |
| 42 | + </style> |
| 43 | + </noscript> |
| 44 | +{% endif %} |
19 | 45 | <div class="card testimonial-card py-large" id="{{carousel_id}}" data-carousel data-carousel-radios role="region" aria-labelledby="{{ carousel_id }}-heading"> |
20 | 46 | {% if testimonials %} |
21 | 47 | {% for testimonial in testimonials %} |
|
0 commit comments