aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/components/StopGallery.tsx
blob: 7dda637238d4f626e9b5cff2e5232b287708710e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React, { useRef } from "react";
import { motion, useMotionValue } from "framer-motion";
import { type Stop } from "../data/StopDataProvider";
import StopGalleryItem from "./StopGalleryItem";
import "./StopGallery.css";

interface StopGalleryProps {
  stops: Stop[];
  title: string;
  emptyMessage?: string;
}

const StopGallery: React.FC<StopGalleryProps> = ({ stops, title, emptyMessage }) => {
  const scrollRef = useRef<HTMLDivElement>(null);
  const x = useMotionValue(0);

  if (stops.length === 0 && emptyMessage) {
    return (
      <div className="gallery-container">
        <h2 className="page-subtitle">{title}</h2>
        <p className="message">{emptyMessage}</p>
      </div>
    );
  }

  if (stops.length === 0) {
    return null;
  }

  return (
    <div className="gallery-container">
      <div className="gallery-header">
        <h2 className="page-subtitle">{title}</h2>
        <span className="gallery-counter">{stops.length}</span>
      </div>
      
      <motion.div 
        className="gallery-scroll-container"
        ref={scrollRef}
        style={{ x }}
      >
        <div className="gallery-track">
          {stops.map((stop) => (
            <StopGalleryItem key={stop.stopId} stop={stop} />
          ))}
        </div>
      </motion.div>

      <div className="gallery-indicators">
        {stops.map((_, index) => (
          <div key={index} className="gallery-indicator" />
        ))}
      </div>
    </div>
  );
};

export default StopGallery;