summaryrefslogtreecommitdiff
path: root/src/components/Carousel.astro
blob: 8df3622bb70c0d60312f81868e06930ca63d0919 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
import { chunkArray } from '../utils/chunk';

// import carouselJson from '../../public/jsonData/carousel.json'
// interface Carousel{
//   img: string;
//   alt: string;
//   link?: string;
// }

// const carouselData : Carousel[] = carouselJson;


var carouselContent = await Astro.glob("../content/partnersCarouselLogo/*.md");

//this is the just for chunking the array into 4 parts
const chunkedContent = chunkArray(carouselContent, 4);

---
  <div class="gallery-wrap">

    <!-- this is the back button for the carousel -->

    <!-- <svg id = "backBtn" xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" {...props}>
      <path fill="black" d="M19.793 3.441v17.118a1.243 1.243 0 0 1-1.83 1.19L3.329 12.991a1.184 1.184 0 0 1 0-1.982l14.634-8.758a1.243 1.243 0 0 1 1.83 1.19" />
    </svg> -->


    <!-- this is the gallery of the carousel -->

    <div class="gallery">
      {chunkedContent.map((chunk, index) => (
        <div>
          {chunk.map((slide, idx) => (
            <span>
              <a href={slide.frontmatter.link} target="_blank" rel="noopener noreferrer">
                <img src={slide.frontmatter.img} alt={slide.frontmatter.alt} />
              </a>
            </span>
          ))}
        </div>
      ))}
    </div>



    <!-- this is the next button for the carousel -->

    <!-- <svg id = "nextBtn" xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" {...props}>
      <path fill="black" d="M19.793 3.441v17.118a1.243 1.243 0 0 1-1.83 1.19L3.329 12.991a1.184 1.184 0 0 1 0-1.982l14.634-8.758a1.243 1.243 0 0 1 1.83 1.19" />
    </svg> -->
</div>



<style>

  .gallery{
    width: 100vh;
    display: flex;
    overflow-x: scroll;
  }

  .gallery div{
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 80px;
    padding: 10px;
    flex: none;
  }
  .gallery div span{
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .gallery div img{
    width: 100%;
    transition: transform 0.5s;
  }

  .gallery::-webkit-scrollbar{
    display: none;
  }
  .gallery-wrap{
    display: flex;
    justify-content: center;
    align-items: center; 
  }

 /* styling of the buttons */

  /* #nextBtn{
    transform: rotateY(180deg);
  }

  #backBtn, #nextBtn{
    width: 3vh;
    cursor: pointer;
    margin: 0 15vh;
  } */

  @media screen and (max-width: 868px){
    .gallery div{
      grid-gap: 70px;
    }

    /* styling of the buttons */
    /* #backBtn, #nextBtn{
      margin: 0;
    } */
  }

</style>

<script>

  let scrollContainer : HTMLElement | null = document.querySelector(".gallery");

  
  scrollContainer?.addEventListener("wheel", (e)=>{
    e.preventDefault();
    scrollContainer.scrollLeft += (e as WheelEvent).deltaY;
    scrollContainer.style.scrollBehavior = "auto";
  });
  
  // this is the code for accessing the button elements

  // let nextBtn : HTMLElement | null = document.getElementById("nextBtn");
  // let backBtn : HTMLElement | null = document.getElementById("backBtn");

  // this is the functioning of the buttons

  // nextBtn?.addEventListener("click", ()=>{
  //   if(scrollContainer){
  //     scrollContainer.style.scrollBehavior = "smooth";
  //     scrollContainer.scrollLeft += 900;
  //   }
  // });
  
  // backBtn?.addEventListener("click", ()=>{
  //   if(scrollContainer){
  //     scrollContainer.style.scrollBehavior = "smooth";
  //     scrollContainer.scrollLeft -= 900;
  //     console.log(scrollContainer.scrollLeft);
  //   }
  // });

</script>