fix project slider
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import Button from '@/components/uikit/button';
|
import Button from '@/components/uikit/button';
|
||||||
@@ -11,12 +13,13 @@ interface Props {
|
|||||||
locale: TLocales;
|
locale: TLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProjectThumb = ({ project, locale }: Props) => {
|
export default function ProjectThumb({ project, locale }: Props) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const routes = routeFactory(t, locale);
|
const routes = routeFactory(t, locale);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="group flex flex-col gap-3 overflow-hidden bg-white md:gap-5">
|
<div className="group flex flex-col gap-3 overflow-hidden bg-white md:gap-5">
|
||||||
<div className="relative aspect-[1.4] w-full overflow-hidden rounded-2xl">
|
<div className="relative aspect-[1.09] w-full overflow-hidden rounded-2xl">
|
||||||
<Image
|
<Image
|
||||||
src={project.imageSrc}
|
src={project.imageSrc}
|
||||||
alt={project.title}
|
alt={project.title}
|
||||||
@@ -24,7 +27,7 @@ const ProjectThumb = ({ project, locale }: Props) => {
|
|||||||
className="h-auto w-full object-cover"
|
className="h-auto w-full object-cover"
|
||||||
/>
|
/>
|
||||||
<div className="invisible absolute inset-0 flex items-center justify-center bg-black/20 opacity-0 backdrop-blur-xs transition-all group-hover:visible group-hover:opacity-100">
|
<div className="invisible absolute inset-0 flex items-center justify-center bg-black/20 opacity-0 backdrop-blur-xs transition-all group-hover:visible group-hover:opacity-100">
|
||||||
<Button endIcon="showMore" link={routes.project.route(project.id)}>
|
<Button link={routes.project.route(project.id)} endIcon="showMore">
|
||||||
{t('com_home_projects_details_CTA')}
|
{t('com_home_projects_details_CTA')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -38,6 +41,4 @@ const ProjectThumb = ({ project, locale }: Props) => {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
export default ProjectThumb;
|
|
||||||
|
|||||||
@@ -1,22 +1,36 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
import { Swiper, SwiperSlide } from 'swiper/react';
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
||||||
import { FreeMode } from 'swiper/modules';
|
import { FreeMode } from 'swiper/modules';
|
||||||
import 'swiper/css';
|
import 'swiper/css';
|
||||||
import 'swiper/css/free-mode';
|
import 'swiper/css/free-mode';
|
||||||
|
|
||||||
import ProjectThumb from './ProjectThumb';
|
import ProjectThumb from './ProjectThumb';
|
||||||
import { TLocales } from '@/models/layout';
|
|
||||||
import { IProjectThumbResponseData } from '@/app/api/projects/data';
|
import { IProjectThumbResponseData } from '@/app/api/projects/data';
|
||||||
|
import { TLocales } from '@/models/layout';
|
||||||
|
import SliderThumbSkeleton from '@/components/layout/sliderSkeleton';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
projects: IProjectThumbResponseData[];
|
||||||
|
locale: TLocales;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ProjectsGridSlider({
|
export default function ProjectsGridSlider({
|
||||||
projects,
|
projects,
|
||||||
locale,
|
locale,
|
||||||
className = '',
|
className = '',
|
||||||
}: {
|
}: Props) {
|
||||||
projects: IProjectThumbResponseData[];
|
const [hasMounted, setHasMounted] = useState(false);
|
||||||
locale: TLocales;
|
|
||||||
className?: string;
|
useEffect(() => {
|
||||||
}) {
|
setHasMounted(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!hasMounted) return <SliderThumbSkeleton count={3} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<Swiper
|
<Swiper
|
||||||
@@ -25,12 +39,15 @@ export default function ProjectsGridSlider({
|
|||||||
spaceBetween={16}
|
spaceBetween={16}
|
||||||
breakpoints={{
|
breakpoints={{
|
||||||
0: { slidesPerView: 1.1 },
|
0: { slidesPerView: 1.1 },
|
||||||
768: { slidesPerView: projects.length, spaceBetween: 24 },
|
768: {
|
||||||
|
slidesPerView: Math.min(projects.length, 3),
|
||||||
|
spaceBetween: 24,
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
{projects.map((project) => (
|
{projects.map((project) => (
|
||||||
<SwiperSlide key={project.id}>
|
<SwiperSlide key={project.id} className="w-auto">
|
||||||
<ProjectThumb project={project} locale={locale} />
|
<ProjectThumb project={project} locale={locale} />
|
||||||
</SwiperSlide>
|
</SwiperSlide>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user