diff --git a/components/blocks/ReferencesSlider.test.tsx b/components/blocks/ReferencesSlider.test.tsx index d18b97d14..4a8cd039c 100644 --- a/components/blocks/ReferencesSlider.test.tsx +++ b/components/blocks/ReferencesSlider.test.tsx @@ -51,15 +51,14 @@ describe('ReferencesSlider TDD', () => { expect(screen.getByText('Referenz Projekt Zwei')).toBeTruthy(); }); - it('renders each tile as a link to the reference detail page', () => { + it('renders each tile as a static block and NOT wrapped in a link', () => { render(); + + const links = screen.queryAllByTestId('reference-tile-link'); + expect(links).toHaveLength(0); const tiles = screen.getAllByTestId('reference-tile'); expect(tiles).toHaveLength(2); - - // Check if they have href attributes - expect(tiles[0].getAttribute('href')).toContain('/en/referenzen#referenz-projekt-eins'); - expect(tiles[1].getAttribute('href')).toContain('/en/referenzen#referenz-projekt-zwei'); }); }); diff --git a/components/blocks/ReferencesSlider.tsx b/components/blocks/ReferencesSlider.tsx index 45eddad5e..8a188978f 100644 --- a/components/blocks/ReferencesSlider.tsx +++ b/components/blocks/ReferencesSlider.tsx @@ -40,6 +40,12 @@ export function ReferencesSlider(props: ReferencesSliderProps) { const { data } = props; const references = props.references || []; + const containerRef = React.useRef(null); + const dragDistanceRef = React.useRef(0); + const startXRef = React.useRef(0); + const scrollLeftRef = React.useRef(0); + const isDraggingRef = React.useRef(false); + const [isDragging, setIsDragging] = React.useState(false); const badge = props.badge || data?.badge || t('badge'); const title = props.title || data?.title || t('title'); @@ -57,6 +63,36 @@ export function ReferencesSlider(props: ReferencesSliderProps) { '/assets/photos/DSC00010.JPG', ]; + const onMouseDown = (e: React.MouseEvent) => { + if (!containerRef.current) return; + setIsDragging(true); + isDraggingRef.current = true; + const startXVal = e.clientX - (containerRef.current.offsetLeft || 0); + startXRef.current = startXVal; + scrollLeftRef.current = containerRef.current.scrollLeft || 0; + dragDistanceRef.current = 0; + }; + + const onMouseLeave = () => { + setIsDragging(false); + isDraggingRef.current = false; + }; + + const onMouseUp = () => { + setIsDragging(false); + isDraggingRef.current = false; + }; + + const onMouseMove = (e: React.MouseEvent) => { + if (!isDraggingRef.current || !containerRef.current) return; + e.preventDefault(); + const x = e.clientX - (containerRef.current.offsetLeft || 0); + const walk = (x - startXRef.current) * 2; // Scroll-fast + containerRef.current.scrollLeft = scrollLeftRef.current - walk; + dragDistanceRef.current = Math.abs(x - startXRef.current); + }; + + return (
@@ -66,13 +102,24 @@ export function ReferencesSlider(props: ReferencesSliderProps) {

{badge}

{title}

-
+
{description}
-
-
+
+
+ + {/* Carousel: stays inside container for left alignment, breaks right to viewport edge */} +
{references.map((ref, i) => { const imgSrc = ref.image ? (typeof ref.image === 'string' ? ref.image : ref.image.url) @@ -81,47 +128,54 @@ export function ReferencesSlider(props: ReferencesSliderProps) { return ( - {ref.title} - -
- - - -
-
- {ref.category} -
-

- {ref.title} -

-
- + href={`/${locale}/referenzen#${ref.slug}`} + onClick={(e) => { + if (dragDistanceRef.current > 5) { + e.preventDefault(); + e.stopPropagation(); + } + }} + onDragStart={(e) => e.preventDefault()} + draggable={false} + data-testid="reference-tile" + className="block relative select-none aspect-[16/10] bg-neutral-800 rounded-2xl overflow-hidden mb-5 border border-white/5 shadow-2xl cursor-pointer" + > + {ref.title} +
+ + + +
+ + {ref.category} + +

{ref.title}

+
+ ); })} + {/* Right padding spacer so last card doesn't clip at viewport edge */} +
-
+