Skip to content

Commit 6820d68

Browse files
committed
chore: remove the swipe ability on testimonial card, as design cannot accommodate it
1 parent 325b399 commit 6820d68

2 files changed

Lines changed: 0 additions & 111 deletions

File tree

static/css/v3/testimonial-card.css

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -234,40 +234,6 @@
234234
max-width: 100%;
235235
}
236236

237-
/*
238-
* Carousel navigation uses hidden radios + <label> arrows so clicking an arrow
239-
* doesn't change the URL or trigger scrollIntoView (which would scroll the
240-
* page). The nav pair matching the currently-:checked radio is the only one
241-
* shown. The track keeps `overflow-x: auto` so touch/swipe still works; JS
242-
* syncs radio <-> scroll position. In no-JS mode the track is switched to
243-
* `overflow: hidden` + CSS transform (see the <noscript> block in
244-
* _testimonial_card.html), which trades touch scroll for a working arrow UI.
245-
*/
246-
.testimonial-card__state {
247-
position: absolute;
248-
width: 1px;
249-
height: 1px;
250-
margin: -1px;
251-
padding: 0;
252-
border: 0;
253-
clip: rect(0 0 0 0);
254-
clip-path: inset(50%);
255-
overflow: hidden;
256-
white-space: nowrap;
257-
}
258-
259-
.testimonial-card__controls {
260-
display: contents;
261-
}
262-
263-
.testimonial-card .testimonial-card__nav-set {
264-
display: none;
265-
}
266-
267-
/* Per-index `display: inline-flex` overrides for the checked radio's nav-set
268-
are generated in _testimonial_card.html (the testimonials count is
269-
data-driven, so the rule set is rendered inline by the template). */
270-
271237
.carousel-buttons label.btn-carousel {
272238
display: inline-flex;
273239
align-items: center;
@@ -283,32 +249,6 @@
283249
pointer-events: none;
284250
}
285251

286-
/* Focus mirroring: the radios are visually hidden but remain keyboard-focusable
287-
(arrow keys move between them natively). When that happens we reflect focus
288-
onto the currently-visible nav-set wrapper so keyboard users see where they
289-
are. Outlining the wrapper (not each button) avoids two outlines colliding
290-
on the adjacent prev/next pills. Only the nav-set matching the checked
291-
radio is `display: inline-flex`; the others are `display: none`, so a
292-
single rule suffices. */
293-
.testimonial-card:has(.testimonial-card__state:focus-visible) .testimonial-card__nav-set {
294-
outline: 2px solid currentColor;
295-
outline-offset: 2px;
296-
border-radius: 8px;
297-
}
298-
299-
/* Scroll-snap: align items when the user swipes. JS uses smooth scroll on
300-
arrow-click so we don't need scroll-behavior here.
301-
`flex: 0 0 100%` forces each item to exactly the flex container width so
302-
both native scroll and the no-JS transform math land on item boundaries. */
303-
.testimonial-card__list {
304-
scroll-snap-type: x mandatory;
305-
}
306-
307-
.testimonial-card__list-item {
308-
scroll-snap-align: start;
309-
flex: 0 0 100%;
310-
}
311-
312252
/**
313253
* The carousel list (.testimonial-card__list) needs overflow-y: hidden
314254
* to keep horizontal scroll behavior, which clips the badge tooltip when it

static/js/carousel.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -156,63 +156,12 @@
156156
}
157157
}
158158

159-
function setupRadioCarousel(root, track) {
160-
const radios = root.querySelectorAll('input[type="radio"].testimonial-card__state');
161-
if (radios.length === 0) return;
162-
const items = track.querySelectorAll(CAROUSEL_ITEM_SELECTOR);
163-
164-
let scrolling = false;
165-
let scrollTimeout = null;
166-
167-
function syncInert(activeIdx) {
168-
items.forEach(function (item, i) {
169-
if (i === activeIdx) item.removeAttribute('inert');
170-
else item.setAttribute('inert', '');
171-
});
172-
}
173-
174-
const initialIdx = Array.prototype.findIndex.call(radios, function (r) { return r.checked; });
175-
syncInert(initialIdx >= 0 ? initialIdx : 0);
176-
177-
radios.forEach(function (radio, idx) {
178-
radio.addEventListener('change', function () {
179-
if (!radio.checked) return;
180-
syncInert(idx);
181-
const target = items[idx];
182-
if (!target) return;
183-
scrolling = true;
184-
target.scrollIntoView({ inline: 'start', block: 'nearest', behavior: 'smooth' });
185-
clearTimeout(scrollTimeout);
186-
scrollTimeout = setTimeout(function () { scrolling = false; }, 400);
187-
});
188-
});
189-
190-
track.addEventListener('scroll', function () {
191-
if (scrolling) return;
192-
const first = items[0];
193-
if (!first) return;
194-
const itemWidth = first.offsetWidth;
195-
if (itemWidth === 0) return;
196-
const idx = Math.round(track.scrollLeft / itemWidth);
197-
const radio = radios[Math.max(0, Math.min(radios.length - 1, idx))];
198-
if (radio && !radio.checked) {
199-
radio.checked = true;
200-
syncInert(idx);
201-
}
202-
}, { passive: true });
203-
}
204-
205159
function initCarousel(root) {
206160
if (!root || !root.id) return;
207161
const track = root.querySelector('[data-carousel-track]');
208162
const controls = document.getElementById(root.id + '-controls');
209163
if (!track || !controls) return;
210164

211-
if (root.hasAttribute('data-carousel-radios')) {
212-
setupRadioCarousel(root, track);
213-
return;
214-
}
215-
216165
if (root.hasAttribute('data-carousel-infinite')) {
217166
setupInfiniteCarousel(root, track);
218167
return;

0 commit comments

Comments
 (0)