Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progress bar #24

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions frontend/src/components/Home/UpcomingCarousel/UpcomingCarousel.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "../../../styles/UpcomingCarousel.scoped.scss";
import { useEffect } from "react";
import { useEffect , useRef } from "react";
import { Link } from "react-router-dom";
import ScrollCarousel from "scroll-carousel";
import { anime_data } from "../../../data";
Expand All @@ -11,6 +11,9 @@ import "@splidejs/splide/dist/css/splide.min.css";
var top10UpcomingAnime;

export const UpcomingCarousel = () => {



// Sort the anime_data array based on start_date in descending order
// this way, we get most recent by start_date, elements. and put them in other list, which shows latest 10 by start_date
const sortedAnimeData = anime_data.sort((a, b) => {
Expand All @@ -22,6 +25,27 @@ export const UpcomingCarousel = () => {
// this way, we get most recent by start_date, elements. and put them in other list, which shows latest 10 by start_date
top10UpcomingAnime = sortedAnimeData.slice(0, 10);





// progress bar
const splideRef = useRef(null);
const barRef = useRef(null);

useEffect(() => {
const splide = splideRef.current.splide;
const bar = barRef.current;

splide.on(' autoplay:play mounted move dragged', () => {
const end = splide.Components.Controller.getEnd() + 1;
const rate = Math.min((splide.index + 1) / end, 1);
bar.style.width = `${100 * rate}%`;
});
}, []);



return (
<>
<div className="line"> </div>
Expand All @@ -36,6 +60,8 @@ export const UpcomingCarousel = () => {
</div>

<Splide
ref={splideRef}

options={{
perPage: 3,
gap: "0.75rem",
Expand All @@ -48,17 +74,26 @@ export const UpcomingCarousel = () => {
pagination: false,
drag: "free",
snap: true,
wheel: true,
}}

aria-labelledby="reactivity-example-heading"
className="mt-2"
className="mt-2 "
>
{top10UpcomingAnime.map((item, index) => (
<SplideSlide key={index}>
<Item item={item} index={index} />
</SplideSlide>
))}



</Splide>

<div class="my-carousel-progress">
<div class="my-carousel-progress-bar" ref={barRef}></div>
</div>


</div>
</>
);
Expand Down
167 changes: 68 additions & 99 deletions frontend/src/styles/UpcomingCarousel.scoped.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
.main {

width: 100%;
height: 22rem;

@media screen and (min-width: 768px) {

width: 100%;
height: 40rem;
@media screen and (min-width: 768px) {
width: 100%;
height: 40rem;
}




@media screen and (min-width: 1280px) {

width: 100%;
height: 43rem;

}
@media screen and (min-width: 1280px) {
width: 100%;
height: 43rem;
}


background: linear-gradient(180deg, #111 0%, #1e1e1e 50.52%, #1e1e1e 100%);
}

Expand All @@ -35,22 +27,16 @@
.small_header > div > h3 {
color: #fff;
font-family: Inter;



// font-size: 2vw;
font-size: 10pt;

@media screen and (min-width: 768px) {


@media screen and (min-width: 768px) {
font-size: 13pt;
}


@media screen and (min-width: 1280px) {

font-size: 16pt;

@media screen and (min-width: 1280px) {
font-size: 16pt;
}

font-style: normal;
Expand All @@ -65,16 +51,12 @@
// font-size: 1.5vw;

font-size: 7pt;


@media screen and (min-width: 768px) {


@media screen and (min-width: 768px) {
font-size: 10pt;
}
@media screen and (min-width: 1280px) {

@media screen and (min-width: 1280px) {
font-size: 12pt;

}

font-style: normal;
Expand All @@ -86,40 +68,32 @@
/* carousel */

.item {

text-wrap: wrap;

// width: 26rem;
// height: 35em;


width: 10rem;
height: 15em;


// normal
@media screen and (min-width: 1280px) {

width: 26rem;
height: 35em;
text-wrap: wrap;

// width: 26rem;
// height: 35em;

width: 10rem;
height: 15em;

// normal
@media screen and (min-width: 1280px) {
width: 26rem;
height: 35em;
}


@media screen and (min-width: 768px) {

width: 20rem;
height: 30em;

@media screen and (min-width: 768px) {
width: 20rem;
height: 30em;
}



// @media screen and (max-width: 768px) {

// width: 10rem;
// height: 15em;

// }


border: 3px solid #ea1179;
border-radius: 15px;
background: linear-gradient(180deg, #111 0%, #1e1e1e 50.52%, #1e1e1e 100%);
Expand All @@ -128,55 +102,40 @@ text-wrap: wrap;
.item > div > img {
border: 0;
// object-fit: contain;



@media screen and (max-width: 768px) {
object-fit: cover;
width:100%;
height:14em;
}

@media screen and (max-width: 768px) {
object-fit: cover;
width: 100%;
height: 14em;
}

@media screen and (min-width: 768px) {
object-fit: cover;
width:100%;
height:30em;


@media screen and (min-width: 768px) {
object-fit: cover;
width: 100%;
height: 30em;
}



}

.item_div {
width: 100%;
height: 60%;




border-radius: 12px 12px 0 0;
overflow: hidden;
}

.inner > h1 {
color: #fff;
font-family: Inter;



// font-size: 1.9vw;

font-size: 10pt;


@media screen and (min-width: 768px) {

font-size: 15pt;

@media screen and (min-width: 768px) {
font-size: 15pt;
}


// font-style: normal;
// font-weight: 400;

Expand All @@ -192,11 +151,9 @@ text-wrap: wrap;
// font-size: 1.5vw;

font-size: 7pt;

@media screen and (min-width: 768px) {

font-size: 11pt;

@media screen and (min-width: 768px) {
font-size: 11pt;
}

font-style: normal;
Expand All @@ -208,18 +165,13 @@ text-wrap: wrap;
color: #fff;
font-family: Inter;
// font-size: 1.7vw;



font-size: 7pt;


@media screen and (min-width: 768px) {

font-size: 8pt;

@media screen and (min-width: 768px) {
font-size: 8pt;
}


font-style: normal;
font-weight: 400;
line-height: normal;
Expand All @@ -232,6 +184,23 @@ text-wrap: wrap;
width: 100%;
}

.my-carousel-progress {
background: #1e1e1e;

margin-top: 1.5em;

@media (min-width: 768px) and (max-width: 1279px) {
margin-top: 3.8em;
}

@media (min-width: 1279px) and (max-width: 127999px) {
margin-top: 6.1em;
}
}

.my-carousel-progress-bar {
background: #ea1179;
height: 3px;
transition: width 400ms ease;
width: 0;
}