🛠 Switched to embla and made carousel bleed off page
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
"date-fns": "^2.28.0",
|
"date-fns": "^2.28.0",
|
||||||
"dayjs": "^1.10.6",
|
"dayjs": "^1.10.6",
|
||||||
"ellipsize": "^0.5.1",
|
"ellipsize": "^0.5.1",
|
||||||
|
"embla-carousel-react": "^8.6.0",
|
||||||
"express": "^4.20.0",
|
"express": "^4.20.0",
|
||||||
"filename-parser": "^1.0.2",
|
"filename-parser": "^1.0.2",
|
||||||
"final-form": "^4.20.2",
|
"final-form": "^4.20.2",
|
||||||
@@ -48,7 +49,6 @@
|
|||||||
"i18next-http-backend": "^2.5.0",
|
"i18next-http-backend": "^2.5.0",
|
||||||
"immer": "^10.0.3",
|
"immer": "^10.0.3",
|
||||||
"jsdoc": "^3.6.10",
|
"jsdoc": "^3.6.10",
|
||||||
"keen-slider": "^6.8.6",
|
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pretty-bytes": "^5.6.0",
|
"pretty-bytes": "^5.6.0",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { ReactElement, useState } from "react";
|
import React, { ReactElement, useState, useCallback } from "react";
|
||||||
import { map } from "lodash";
|
import { map } from "lodash";
|
||||||
import Card from "../shared/Carda";
|
import Card from "../shared/Carda";
|
||||||
import Header from "../shared/Header";
|
import Header from "../shared/Header";
|
||||||
@@ -10,8 +10,7 @@ import axios from "axios";
|
|||||||
import rateLimiter from "axios-rate-limit";
|
import rateLimiter from "axios-rate-limit";
|
||||||
import { setupCache } from "axios-cache-interceptor";
|
import { setupCache } from "axios-cache-interceptor";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import "keen-slider/keen-slider.min.css";
|
import useEmblaCarousel from "embla-carousel-react";
|
||||||
import { useKeenSlider } from "keen-slider/react";
|
|
||||||
import { COMICVINE_SERVICE_URI } from "../../constants/endpoints";
|
import { COMICVINE_SERVICE_URI } from "../../constants/endpoints";
|
||||||
import { Field, Form } from "react-final-form";
|
import { Field, Form } from "react-final-form";
|
||||||
import DatePickerDialog from "../shared/DatePicker";
|
import DatePickerDialog from "../shared/DatePicker";
|
||||||
@@ -34,24 +33,13 @@ export const PullList = (): ReactElement => {
|
|||||||
format(date, "yyyy/M/dd"),
|
format(date, "yyyy/M/dd"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// keen slider
|
// embla carousel
|
||||||
const [sliderRef, instanceRef] = useKeenSlider(
|
const [emblaRef, emblaApi] = useEmblaCarousel({
|
||||||
{
|
loop: false,
|
||||||
loop: true,
|
align: "start",
|
||||||
slides: {
|
containScroll: "trimSnaps",
|
||||||
origin: "auto",
|
slidesToScroll: 1,
|
||||||
number: 15,
|
});
|
||||||
perView: 5,
|
|
||||||
spacing: 15,
|
|
||||||
},
|
|
||||||
slideChanged() {
|
|
||||||
console.log("slide changed");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[
|
|
||||||
// add plugins here
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: pullList,
|
data: pullList,
|
||||||
@@ -126,34 +114,41 @@ export const PullList = (): ReactElement => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isSuccess && !isLoading && (
|
{isSuccess && !isLoading && (
|
||||||
<div ref={sliderRef} className="keen-slider flex flex-row">
|
<div className="content">
|
||||||
{map(pullList?.data.result, (issue, idx) => {
|
<div className="overflow-hidden -mr-[100vw]" ref={emblaRef}>
|
||||||
return (
|
<div className="flex">
|
||||||
<div key={idx} className="keen-slider__slide">
|
{map(pullList?.data.result, (issue, idx) => {
|
||||||
<Card
|
return (
|
||||||
orientation={"vertical-2"}
|
<div
|
||||||
imageUrl={issue.coverImageUrl}
|
key={idx}
|
||||||
hasDetails
|
className="flex-[0_0_200px] min-w-0 sm:flex-[0_0_220px] md:flex-[0_0_240px] lg:flex-[0_0_260px] xl:flex-[0_0_280px] pr-[15px]"
|
||||||
title={ellipsize(issue.issueName, 25)}
|
>
|
||||||
>
|
<Card
|
||||||
<div className="px-1">
|
orientation={"vertical-2"}
|
||||||
<span className="inline-flex mb-2 items-center bg-slate-50 text-slate-800 text-xs font-medium px-2.5 py-1 rounded-md dark:text-slate-900 dark:bg-slate-400">
|
imageUrl={issue.coverImageUrl}
|
||||||
{issue.publicationDate}
|
hasDetails
|
||||||
</span>
|
title={ellipsize(issue.issueName, 25)}
|
||||||
<div className="flex flex-row justify-end">
|
>
|
||||||
<button
|
<div className="px-1">
|
||||||
className="flex space-x-1 mb-2 sm:mt-0 sm:flex-row sm:items-center rounded-lg border border-green-400 dark:border-green-200 bg-green-200 px-2 py-1 text-gray-500 hover:bg-transparent hover:text-green-600 focus:outline-none focus:ring active:text-indigo-500"
|
<span className="inline-flex mb-2 items-center bg-slate-50 text-slate-800 text-xs font-medium px-2.5 py-1 rounded-md dark:text-slate-900 dark:bg-slate-400">
|
||||||
onClick={() => addToLibrary("locg", issue)}
|
{issue.publicationDate}
|
||||||
>
|
</span>
|
||||||
<i className="icon-[solar--add-square-bold-duotone] w-5 h-5 mr-2"></i>{" "}
|
<div className="flex flex-row justify-end">
|
||||||
Want
|
<button
|
||||||
</button>
|
className="flex space-x-1 mb-2 sm:mt-0 sm:flex-row sm:items-center rounded-lg border border-green-400 dark:border-green-200 bg-green-200 px-2 py-1 text-gray-500 hover:bg-transparent hover:text-green-600 focus:outline-none focus:ring active:text-indigo-500"
|
||||||
</div>
|
onClick={() => addToLibrary("locg", issue)}
|
||||||
|
>
|
||||||
|
<i className="icon-[solar--add-square-bold-duotone] w-5 h-5 mr-2"></i>{" "}
|
||||||
|
Want
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
);
|
||||||
</div>
|
})}
|
||||||
);
|
</div>
|
||||||
})}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{isLoading ? <div>Loading...</div> : null}
|
{isLoading ? <div>Loading...</div> : null}
|
||||||
|
|||||||
23
yarn.lock
23
yarn.lock
@@ -5402,6 +5402,24 @@ ellipsize@^0.5.1:
|
|||||||
resolved "https://registry.yarnpkg.com/ellipsize/-/ellipsize-0.5.1.tgz#2ac8bba69b2190d629cc5065a9c2bf28d99f237e"
|
resolved "https://registry.yarnpkg.com/ellipsize/-/ellipsize-0.5.1.tgz#2ac8bba69b2190d629cc5065a9c2bf28d99f237e"
|
||||||
integrity sha512-0jEAyuIRU6U8MN0S5yUqIrkK/AQWkChh642N3zQuGV57s9bsUWYLc0jJOoDIUkZ2sbEL3ySq8xfq71BvG4q3hw==
|
integrity sha512-0jEAyuIRU6U8MN0S5yUqIrkK/AQWkChh642N3zQuGV57s9bsUWYLc0jJOoDIUkZ2sbEL3ySq8xfq71BvG4q3hw==
|
||||||
|
|
||||||
|
embla-carousel-react@^8.6.0:
|
||||||
|
version "8.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/embla-carousel-react/-/embla-carousel-react-8.6.0.tgz#b737042a32761c38d6614593653b3ac619477bd1"
|
||||||
|
integrity sha512-0/PjqU7geVmo6F734pmPqpyHqiM99olvyecY7zdweCw+6tKEXnrE90pBiBbMMU8s5tICemzpQ3hi5EpxzGW+JA==
|
||||||
|
dependencies:
|
||||||
|
embla-carousel "8.6.0"
|
||||||
|
embla-carousel-reactive-utils "8.6.0"
|
||||||
|
|
||||||
|
embla-carousel-reactive-utils@8.6.0:
|
||||||
|
version "8.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/embla-carousel-reactive-utils/-/embla-carousel-reactive-utils-8.6.0.tgz#607f1d8ab9921c906a555c206251b2c6db687223"
|
||||||
|
integrity sha512-fMVUDUEx0/uIEDM0Mz3dHznDhfX+znCCDCeIophYb1QGVM7YThSWX+wz11zlYwWFOr74b4QLGg0hrGPJeG2s4A==
|
||||||
|
|
||||||
|
embla-carousel@8.6.0:
|
||||||
|
version "8.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/embla-carousel/-/embla-carousel-8.6.0.tgz#abcedff2bff36992ea8ac27cd30080ca5b6a3f58"
|
||||||
|
integrity sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==
|
||||||
|
|
||||||
emittery@^0.13.1:
|
emittery@^0.13.1:
|
||||||
version "0.13.1"
|
version "0.13.1"
|
||||||
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad"
|
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad"
|
||||||
@@ -7920,11 +7938,6 @@ jsonfile@^6.0.1:
|
|||||||
object.assign "^4.1.4"
|
object.assign "^4.1.4"
|
||||||
object.values "^1.1.6"
|
object.values "^1.1.6"
|
||||||
|
|
||||||
keen-slider@^6.8.6:
|
|
||||||
version "6.8.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/keen-slider/-/keen-slider-6.8.6.tgz#17bb7b219860f291a5ea5fde4496b737bf407a83"
|
|
||||||
integrity sha512-dcEQ7GDBpCjUQA8XZeWh3oBBLLmyn8aoeIQFGL/NTVkoEOsmlnXqA4QykUm/SncolAZYGsEk/PfUhLZ7mwMM2w==
|
|
||||||
|
|
||||||
keyv@^4.5.3:
|
keyv@^4.5.3:
|
||||||
version "4.5.4"
|
version "4.5.4"
|
||||||
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
|
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
|
||||||
|
|||||||
Reference in New Issue
Block a user