Skip to content

Commit

Permalink
add carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSingh-02 committed Oct 11, 2023
1 parent be29378 commit f386a00
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
29 changes: 25 additions & 4 deletions src/components/Fourth/fourth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import React, { useEffect, useState } from "react";
import React, { use, useEffect, useState } from "react";
import style from "./fourth.module.css";
import Image from "next/image";
import { slide as Slide, Props as IRevs } from "../Slides/slide";
Expand All @@ -13,11 +13,32 @@ export const Fourth = () => {
text: "Hello world",
});

const [keyId, setKey] = useState<number>(1);

useEffect(() => {
setTimeout(() => {
setReviews(revs.rev1);
}, 3000);
}, []);
getIndex(revs.rev1.key);
if (keyId == 1) {
setReviews(revs.rev1);
} else if (keyId == 2) {
setReviews(revs.rev2);
} else if (keyId == 3) {
setReviews(revs.rev3);
} else {
setReviews(revs.rev4);
}
}, 5000);
}, [keyId]);

const getIndex = (num: number) => {
setKey((prev)=>{
if(prev == 4){
return prev = 1
}else{
return prev +=1;
}
})
};

return (
<div className={style.fourth}>
Expand Down
20 changes: 12 additions & 8 deletions src/components/Fourth/reviews.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
{
"rev1": {
"key":1,
"im": "/person.png",
"name": "joshua",
"name": "John Doe",
"position": "marketing",
"text": "Hello this is johua"
"text": "Hello this is John Doe"
},
"rev2": {
"key":2,
"im": "/person.png",
"name": "joshua sam",
"name": "Foo",
"position": "marketing",
"text": "Hello this is johua"
"text": "Hello this is foo"
},
"rev3": {
"key":3,
"im": "/person.png",
"name": "joshua singh",
"name": "Bar",
"position": "marketing",
"text": "Hello this is johua"
"text": "Hello this is Bar"
},
"rev4": {
"key":4,
"im": "/person.png",
"name": "joshua jodd",
"name": "NextJs",
"position": "marketing",
"text": "Hello this is johua"
"text": "Hello this is NexTJs"
}
}
1 change: 1 addition & 0 deletions src/components/Slides/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Props {
name: string;
position: string;
text: string;
key?: number;
}

export const slide = (props: Props) => {
Expand Down

0 comments on commit f386a00

Please sign in to comment.