File tree Expand file tree Collapse file tree 2 files changed +102
-5
lines changed
Expand file tree Collapse file tree 2 files changed +102
-5
lines changed Original file line number Diff line number Diff line change 1- import React from ' react'
1+ import React , { useState } from " react" ;
22
33function Testimonials ( ) {
4+ const [ currentIndex , setCurrentIndex ] = useState ( 0 ) ;
5+ const testimonials = [
6+ {
7+ quote : "This is the best product I've ever used!" ,
8+ author : "Jane Doe" ,
9+ } ,
10+ {
11+ quote : "I highly recommend this product to everyone!" ,
12+ author : "John Smith" ,
13+ } ,
14+ {
15+ quote : "This product has completely changed my life!" ,
16+ author : "Bob Johnson" ,
17+ } ,
18+ ] ;
19+
20+ const handlePrevClick = ( ) => {
21+ setCurrentIndex (
22+ ( currentIndex + testimonials . length - 1 ) % testimonials . length
23+ ) ;
24+ } ;
25+ const handleNextClick = ( ) => {
26+ setCurrentIndex ( ( currentIndex + 1 ) % testimonials . length ) ;
27+ } ;
28+
429 return (
5- < div >
6- Testimonials
30+ < div className = "testimonials" >
31+ < div className = "testimonials-quote" >
32+ { testimonials [ currentIndex ] . quote }
33+ </ div >
34+
35+ < div className = "testimonials-author" >
36+ - { testimonials [ currentIndex ] . author }
37+ </ div >
38+
39+ < div className = "testimonials-nav" >
40+ < button onClick = { handlePrevClick } > Prev</ button >
41+ < button onClick = { handleNextClick } > Next</ button >
42+ </ div >
743 </ div >
8- )
44+ ) ;
945}
1046
11- export default Testimonials
47+ export default Testimonials ;
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ }
6+
7+ body {
8+ display : flex;
9+ justify-content : center;
10+ align-items : center;
11+ height : 100vh ;
12+ background-color : # e8faff ;
13+ }
14+
15+ .testimonials {
16+ margin : 0 auto;
17+ text-align : center;
18+ font-family : sans-serif;
19+ border-radius : 10px ;
20+ padding : 40px ;
21+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.1 );
22+ background-color : # f0fdfe ;
23+ }
24+
25+ .testimonials-quote {
26+ font-size : 22px ;
27+ font-style : italic;
28+ margin-bottom : 10px ;
29+ color : # 666 ;
30+ }
31+
32+ .testimonials-author {
33+ font-size : 18px ;
34+ font-weight : bold;
35+ margin-bottom : 20px ;
36+ color : # 333 ;
37+ }
38+
39+ .testimonials-nav {
40+ display : flex;
41+ justify-content : space-between;
42+ }
43+
44+ .testimonials-nav button {
45+ padding : 10px 20px ;
46+ border : none;
47+ background-color : # 82e5ee ;
48+ color : # fff ;
49+ font-size : 16px ;
50+ cursor : pointer;
51+ border-radius : 5px ;
52+ transition : background-color 0.3s ;
53+ }
54+
55+ .testimonials-nav button : hover {
56+ background-color : # 037680 ;
57+ }
58+
59+ .testimonials-nav button : active {
60+ transform : scale (0.95 );
61+ }
You can’t perform that action at this time.
0 commit comments