feat(andreknie.de): improve accessibility and initial loading
This commit is contained in:
@@ -123,10 +123,21 @@ export default function TestimonialSlider({ testimonials = [] }) {
|
||||
}
|
||||
}
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === 'ArrowLeft') {
|
||||
event.preventDefault()
|
||||
scrollByCard(-1)
|
||||
} else if (event.key === 'ArrowRight') {
|
||||
event.preventDefault()
|
||||
scrollByCard(1)
|
||||
}
|
||||
}
|
||||
|
||||
if (testimonials.length === 0) return null
|
||||
|
||||
return (
|
||||
<section className="testimonials-section app-container">
|
||||
<section className="testimonials-section app-container" aria-labelledby="testimonials-heading">
|
||||
<h2 id="testimonials-heading" className="sr-only">Testimonials</h2>
|
||||
<div className="testimonial-slider-controls" aria-label="Testimonials wechseln">
|
||||
<button type="button" className="testimonial-nav-button" onClick={() => scrollByCard(-1)} aria-label="Vorheriges Testimonial">
|
||||
<ChevronLeft size={22} aria-hidden="true" />
|
||||
@@ -138,6 +149,11 @@ export default function TestimonialSlider({ testimonials = [] }) {
|
||||
<div
|
||||
className={`testimonial-scroll-container${isDragging ? ' dragging' : ''}`}
|
||||
ref={scrollerRef}
|
||||
role="region"
|
||||
aria-label={`Testimonial ${testimonials.length > 1 ? 'Karussell' : ''}`}
|
||||
aria-roledescription="Karussell"
|
||||
tabIndex="0"
|
||||
onKeyDown={handleKeyDown}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={stopDragging}
|
||||
@@ -147,7 +163,7 @@ export default function TestimonialSlider({ testimonials = [] }) {
|
||||
}}
|
||||
>
|
||||
{visibleTestimonials.map((current, i) => (
|
||||
<div className="testimonial-card glass-panel" key={`${current.name}-${i}`}>
|
||||
<div className="testimonial-card glass-panel" key={`${current.name}-${i}`} aria-hidden={canLoop && Math.floor(i / testimonials.length) !== MIDDLE_SET}>
|
||||
<div className="testimonial-quote">
|
||||
<span className="quote-mark">"</span>
|
||||
<p>{current.quote}</p>
|
||||
|
||||
Reference in New Issue
Block a user