mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-28 08:59:40 +05:00
feat: add collections page
This commit is contained in:
parent
dbe9eba23f
commit
9e843be11f
7 changed files with 338 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
.swiper-button:global(.swiper-button-disabled) {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
.section .swiper-button {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.section:hover .swiper-button {
|
||||
display: flex !important;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
}
|
97
app/components/CollectionCourusel/CollectionCourusel.tsx
Normal file
97
app/components/CollectionCourusel/CollectionCourusel.tsx
Normal file
|
@ -0,0 +1,97 @@
|
|||
"use client";
|
||||
import { useEffect } from "react";
|
||||
import { CollectionLink } from "../CollectionLink/CollectionLink";
|
||||
import { AddCollectionLink } from "../AddCollectionLink/AddCollectionLink";
|
||||
import Link from "next/link";
|
||||
|
||||
import Styles from "./CollectionCourusel.module.css";
|
||||
import Swiper from "swiper";
|
||||
import "swiper/css";
|
||||
import "swiper/css/navigation";
|
||||
import { Navigation } from "swiper/modules";
|
||||
|
||||
export const CollectionCourusel = (props: {
|
||||
sectionTitle: string;
|
||||
showAllLink?: string;
|
||||
content: any;
|
||||
isMyCollections?: boolean;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
const options: any = {
|
||||
direction: "horizontal",
|
||||
spaceBetween: 8,
|
||||
allowTouchMove: true,
|
||||
slidesPerView: "auto",
|
||||
navigation: {
|
||||
enabled: false,
|
||||
nextEl: ".swiper-button-next",
|
||||
prevEl: ".swiper-button-prev",
|
||||
},
|
||||
breakpoints: {
|
||||
450: {
|
||||
navigation: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
modules: [Navigation],
|
||||
};
|
||||
new Swiper(".swiper", options);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section className={`${Styles.section}`}>
|
||||
<div className="flex justify-between px-4 py-2 border-b-2 border-black dark:border-white">
|
||||
<h1 className="font-bold text-md sm:text-xl md:text-lg xl:text-xl">
|
||||
{props.sectionTitle}
|
||||
</h1>
|
||||
{props.showAllLink && (
|
||||
<Link href={props.showAllLink}>
|
||||
<div className="flex items-center">
|
||||
<p className="hidden text-xl font-bold sm:block">Показать все</p>
|
||||
<span className="w-6 h-6 iconify mdi--arrow-right"></span>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className="m-4">
|
||||
<div className="swiper">
|
||||
<div className="swiper-wrapper">
|
||||
{props.content.map((collection) => {
|
||||
return (
|
||||
<div
|
||||
className="swiper-slide"
|
||||
key={collection.id}
|
||||
style={{ width: "fit-content" }}
|
||||
>
|
||||
<div className="xl:w-[600px] sm:w-[400px] w-[80vw] aspect-video">
|
||||
<CollectionLink {...collection} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{props.isMyCollections && (
|
||||
<div className="swiper-slide" style={{ width: "fit-content" }}>
|
||||
<div className="xl:w-[600px] sm:w-[400px] w-[80vw] aspect-video">
|
||||
<AddCollectionLink />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className={`swiper-button-prev ${Styles["swiper-button"]} after:iconify after:material-symbols--chevron-left aspect-square bg-black bg-opacity-25 backdrop-blur rounded-full after:bg-white`}
|
||||
style={
|
||||
{ "--swiper-navigation-size": "64px" } as React.CSSProperties
|
||||
}
|
||||
></div>
|
||||
<div
|
||||
className={`swiper-button-next ${Styles["swiper-button"]} after:iconify after:material-symbols--chevron-right aspect-square bg-black bg-opacity-25 backdrop-blur rounded-full after:bg-white`}
|
||||
style={
|
||||
{ "--swiper-navigation-size": "64px" } as React.CSSProperties
|
||||
}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue