aboutsummaryrefslogtreecommitdiff
path: root/components/hero/content.js
blob: 532e4a63abf5ca15bd52e9380a0b9071218f0c62 (plain) (blame)
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
import Link from "next/link";
import React from "react";
import Image from "next/image";
import { MdChevronLeft, MdChevronRight } from "react-icons/md";

export default function Content({ ids, section, data }) {
  const slideLeft = () => {
    var slider = document.getElementById(ids);
    slider.scrollLeft = slider.scrollLeft - 500;
  };
  const slideRight = () => {
    var slider = document.getElementById(ids);
    slider.scrollLeft = slider.scrollLeft + 500;
  };

  const array = data;
  const filteredData = array.filter((item) => item.status !== "Unknown");

  return (
    <div>
      <h1 className="px-5 font-outfit text-[20px] font-extrabold lg:text-[27px]">
        {section}
      </h1>
      <div className="py-10">
        <div className="relative flex items-center lg:gap-2">
          <MdChevronLeft
            onClick={slideLeft}
            size={40}
            className="mb-5 cursor-pointer opacity-50 hover:opacity-100"
          />
          <div
            id={ids}
            className="scroll flex h-full w-full items-center overflow-x-scroll scroll-smooth whitespace-nowrap overflow-y-hidden scrollbar-hide lg:gap-5"
          >
            {filteredData.map((anime) => {
              const url = encodeURIComponent(
                anime.title.english || anime.title.romaji
              );

              return (
                <div
                  key={anime.id}
                  className="flex shrink-0 cursor-pointer items-center"
                >
                  <Link href={`/anime/${anime.id}`}>
                    <Image
                      draggable={false}
                      src={
                        anime.image ||
                        anime.coverImage?.extraLarge ||
                        "https://cdn.discordapp.com/attachments/986579286397964290/1058415946945003611/gray_pfp.png"
                      }
                      alt={anime.title.romaji || anime.title.english}
                      width={209}
                      height={300}
                      placeholder="blur"
                      blurDataURL={
                        anime.image ||
                        anime.coverImage?.extraLarge ||
                        "https://cdn.discordapp.com/attachments/986579286397964290/1058415946945003611/gray_pfp.png"
                      }
                      className="z-20 h-[230px] w-[168px] object-cover p-2 duration-300 ease-in-out hover:scale-105 lg:h-[290px] lg:w-[209px]"
                    />
                  </Link>
                </div>
              );
            })}
          </div>
          <MdChevronRight
            onClick={slideRight}
            size={40}
            className="mb-5 cursor-pointer opacity-50 hover:opacity-100"
          />
        </div>
      </div>
    </div>
  );
}