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

feat: replace tweet grid with carousel #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
96 changes: 51 additions & 45 deletions components/TwitterTestimonials.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"use client"
import React, { useEffect, useState } from "react";
import React, { useRef } from "react";
import { Swiper, SwiperSlide } from 'swiper/react';
import { Pagination, Autoplay, Navigation, FreeMode } from 'swiper/modules';
import 'swiper/css';
import 'swiper/css/pagination';
import 'swiper/css/navigation';
import 'swiper/css/free-mode';
import Tweet from "./tweets";

const tweets = [
{
avatar:
Expand Down Expand Up @@ -114,55 +121,54 @@ const tweets = [


const TwitterTestimonials = () => {
const swiperRef = useRef(null);

return (
<>
<div className="relative mt-20 mb-20">
<div className=" relative mt-2 mb-8 z-10 px-4 sm:px-6 max-w-6xl mx-auto flex flex-col justify-center">
<h3 className=" text-center h2 px-10 text-secondary-300">
We love when users talk about Keploy..
</h3>
{/* for mobile view */}
<div className="space-y-5 mt-10 sm:hidden block">
{
tweets?.slice(0,6).map((tweet, index) => {
return (
<React.Fragment key={index}>
<Tweet
avatar={tweet.avatar}
name={tweet.name}
id={tweet.id}
post={tweet.post}
content={tweet.content}
/>
</React.Fragment>
)
})
}
</div>

{/* sizes above sm(640px) */}
<div className="sm:columns-2 lg:columns-3 sm:gap-5 space-y-5 mt-10 hidden sm:block">
{
tweets?.map((tweet, index) => {
return (
<React.Fragment key={index}>
<Tweet
avatar={tweet.avatar}
name={tweet.name}
id={tweet.id}
post={tweet.post}
content={tweet.content}
/>
</React.Fragment>
)
})
}
</div>
<div className="relative mt-20 mb-20">
<div className="relative mt-2 mb-8 z-10 px-4 sm:px-6 max-w-6xl mx-auto flex flex-col justify-center">
<h3 className="text-center h2 px-10 text-secondary-300">
We love when users talk about Keploy..
</h3>

<div className="mt-10 relative">
<Swiper
ref={swiperRef}
modules={[Pagination, Autoplay, Navigation, FreeMode]}
spaceBetween={20}
slidesPerView={1}
pagination={{ clickable: true }}
navigation={true}
freeMode={true}
mousewheel={true}
autoplay={{
delay: 3000,
disableOnInteraction: false,
}}
breakpoints={{
640: {
slidesPerView: 2,
},
1024: {
slidesPerView: 3,
},
}}
className="tweet-carousel"
>
{tweets.map((tweet, index) => (
<SwiperSlide key={index}>
<Tweet
avatar={tweet.avatar}
name={tweet.name}
id={tweet.id}
post={tweet.post}
content={tweet.content}
/>
</SwiperSlide>
))}
</Swiper>
</div>
</div>
</>
</div>
);
};

Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"react-icons": "^5.0.1",
"react-responsive-carousel": "^3.2.23",
"react-swipeable": "^7.0.1",
"swiper": "^11.1.15",
"tailwind-merge": "^2.4.0"
},
"devDependencies": {
Expand Down