Skip to content
Open
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
160 changes: 77 additions & 83 deletions components/project-card-list/ProjectCardList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,94 +8,88 @@ import "swiper/swiper-bundle.css";
import "swiper/components/navigation/navigation.min.css";
import "swiper/components/pagination/pagination.min.css";
import "swiper/components/scrollbar/scrollbar.min.css";
// import styled from "styled-components";
// import { Swiper, SwiperSlide } from "swiper/react";
// import { SectionTitle } from "../../projects/home/home.style";
// import NextIcon from "../../projects/svg-components/next-icon";
// import PrevIcon from "../../projects/svg-components/prev-icon";
import styled from "styled-components";
import { Swiper, SwiperSlide } from "swiper/react";
import { SectionTitle } from "../../projects/home/home.style";
import NextIcon from "../../projects/svg-components/next-icon";
import PrevIcon from "../../projects/svg-components/prev-icon";

SwiperCore.use([Navigation, Pagination, Scrollbar, Controller]);
// const breakpoints = {
// 240: {
// slidesPerView: 1
// },
// 768: {
// slidesPerView: 2
// },
// 1024: {
// slidesPerView: 3
// }
// };
// const Container = styled.div`
// display: flex;
// justify-content: space-between;
// `;
// const ControlContainer = styled.div`
// display: flex;
// align-items: center;
// `;
// const ButtonSlide = styled.button`
// border: none;
// background: #00000000;
// padding: 4;
// `;
const breakpoints = {
240: {
slidesPerView: 1
},
768: {
slidesPerView: 2
},
1024: {
slidesPerView: 3
}
};
const Container = styled.div`
display: flex;
justify-content: space-between;
`;
const ControlContainer = styled.div`
display: flex;
align-items: center;
`;
const ButtonSlide = styled.button`
border: none;
background: #00000000;
padding: 4;
`;
const ProjectCardList = ({ list }) => {
// const [swiper, setSwiper] = useState(null);
// const [isBeginning, setIsBeginning] = useState(true);
// const [isEnd, setIsEnd] = useState(false);
const [swiper, setSwiper] = React.useState(null);
const [isBeginning, setIsBeginning] = React.useState(true);
const [isEnd, setIsEnd] = React.useState(false);

return (
// <>
// <Container>
// <SectionTitle>Latest researches</SectionTitle>
// <ControlContainer>
// <ButtonSlide
// onClick={() => {
// swiper.slidePrev();
// setIsBeginning(swiper.isBeginning);
// setIsEnd(swiper.isEnd);
// }}
// style={{ cursor: `${isBeginning ? `not-allowed` : `pointer`}` }}>
// <PrevIcon disabled={isBeginning} />
// </ButtonSlide>
// <ButtonSlide
// onClick={() => {
// swiper.slideNext();
// setIsBeginning(swiper.isBeginning);
// setIsEnd(swiper.isEnd);
// }}
// style={{ cursor: `${isEnd ? `not-allowed` : `pointer`}` }}>
// <NextIcon disabled={isEnd} />
// </ButtonSlide>
// </ControlContainer>
// </Container>
// <ListContainer>
// <Swiper
// id="main"
// scrollbar={{ draggable: true }}
// // pagination={{ clickable: true }}
// slidesPerView={3}
// spaceBetween={50}
// contoller={{ control: swiper }}
// onSwiper={setSwiper}
// breakpoints={breakpoints}>
// {list.map((item) => {
// const { key, ...rest } = item;
// return (
// <SwiperSlide key={key}>
// <ProjectCard key={key} {...rest} />
// </SwiperSlide>
// );
// })}
// </Swiper>
// </ListContainer>
// </>
<CardsContainer>
{list.map((item) => {
const { key, ...rest } = item;
return <ProjectCard key={key} {...rest} />;
})}
</CardsContainer>
<>
<Container>
<SectionTitle>Latest researches</SectionTitle>
<ControlContainer>
<ButtonSlide
onClick={() => {
swiper.slidePrev();
setIsBeginning(swiper.isBeginning);
setIsEnd(swiper.isEnd);
}}
style={{ cursor: `${isBeginning ? `not-allowed` : `pointer`}` }}>
<PrevIcon disabled={isBeginning} />
</ButtonSlide>
<ButtonSlide
onClick={() => {
swiper.slideNext();
setIsBeginning(swiper.isBeginning);
setIsEnd(swiper.isEnd);
}}
style={{ cursor: `${isEnd ? `not-allowed` : `pointer`}` }}>
<NextIcon disabled={isEnd} />
</ButtonSlide>
</ControlContainer>
</Container>
<ListContainer>
<Swiper
id="main"
scrollbar={{ draggable: true }}
// pagination={{ clickable: true }}
slidesPerView={3}
spaceBetween={50}
contoller={{ control: swiper }}
onSwiper={setSwiper}
breakpoints={breakpoints}>
{list.map((item) => {
const { key, ...rest } = item;
return (
<SwiperSlide key={key}>
<ProjectCard key={key} {...rest} />
</SwiperSlide>
);
})}
</Swiper>
</ListContainer>
</>
);
};

Expand Down
2 changes: 1 addition & 1 deletion components/project-card-list/project-card-list.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ListContainer = styled.div`
}
@media (min-width: 240px) {
.swiper-container {
width: 300px;
width: 330px;
}
}
@media (min-width: 768px) {
Expand Down