@@ -7,7 +7,7 @@ import TextButton from "../TextButton";
7
7
import React , { useState } from "react" ;
8
8
import { useRouter } from "next/router" ;
9
9
import Image from "next/image" ;
10
- import { FaChevronRight } from "react-icons/fa" ;
10
+ import { FaChevronRight , FaChevronLeft } from "react-icons/fa" ;
11
11
import HeroCard from "../HeroCard" ;
12
12
import PurpleHeroIcon from "../../../public/icons/icon-hero-purple.svg" ;
13
13
import GreenHeroIcon from "../../../public/icons/icon-hero-green.svg" ;
@@ -22,9 +22,18 @@ const Hero: React.FC<{ className?: string }> = ({ className }) => {
22
22
const [ sliderIndex , setSliderIndex ] = useState ( 0 ) ;
23
23
const totalCards = roles . length ;
24
24
25
- const handleSliderButton = ( increment : number ) => {
26
- const newIndex = ( sliderIndex + increment + totalCards ) % totalCards ;
27
- setSliderIndex ( newIndex ) ;
25
+ const handleSliderButtonLeft = ( decrement : number ) => {
26
+ if ( sliderIndex != 0 ) {
27
+ const newIndex = ( sliderIndex - decrement + totalCards ) % totalCards ;
28
+ setSliderIndex ( newIndex ) ;
29
+ }
30
+ } ;
31
+
32
+ const handleSliderButtonRight = ( increment : number ) => {
33
+ if ( sliderIndex != roles . length - 2 ) {
34
+ const newIndex = ( sliderIndex + increment + totalCards ) % totalCards ;
35
+ setSliderIndex ( newIndex ) ;
36
+ }
28
37
} ;
29
38
30
39
return (
@@ -70,30 +79,42 @@ const Hero: React.FC<{ className?: string }> = ({ className }) => {
70
79
Experience a new way of working.
71
80
</ p >
72
81
</ div >
73
- < div className = "relative hidden w-full items-center overflow-hidden sm:max-w-[40em] md:flex" >
74
- < motion . div
75
- className = "z-20 flex gap-5"
76
- animate = { { x : ` ${ sliderIndex * - 308 } px` } }
77
- transition = { { duration : 0.5 , type : "spring" , stiffness : 60 } }
82
+
83
+ < div className = "relative hidden w-full items-center sm:max-w-[40em] md:flex" >
84
+ < button
85
+ onClick = { ( ) => handleSliderButtonLeft ( 1 ) }
86
+ className = "group absolute left-0 -translate-x-5 z-30 flex h-6 w-8 items-center justify-center rounded-full border border-white/20 bg-black bg-gradient-to-r from-white/10 to-black hover:border-white/30"
78
87
>
79
- { roles . map ( ( role , index ) => (
80
- < HeroCard
81
- key = { role . title }
82
- title = { role . title }
83
- subtitle = { role . subtitle }
84
- leftIcon = { role . icon }
85
- onClick = { ( ) => {
86
- router . push ( "/" ) . catch ( console . error ) ;
87
- } }
88
- />
89
- ) ) }
90
- </ motion . div >
88
+ < FaChevronLeft
89
+ size = { 10 }
90
+ className = "text-gray-400 transition-transform group-hover:translate-x-0.5"
91
+ />
92
+ </ button >
93
+ < div className = "relative hidden w-full items-center overflow-hidden sm:max-w-[40em] md:flex" >
94
+ < motion . div
95
+ className = "z-20 flex gap-5"
96
+ animate = { { x : `${ sliderIndex * - 308 } px` } }
97
+ transition = { { duration : 0.5 , type : "spring" , stiffness : 60 } }
98
+ >
99
+ { roles . map ( ( role , index ) => (
100
+ < HeroCard
101
+ key = { role . title }
102
+ title = { role . title }
103
+ subtitle = { role . subtitle }
104
+ leftIcon = { role . icon }
105
+ onClick = { ( ) => {
106
+ router . push ( "/" ) . catch ( console . error ) ;
107
+ } }
108
+ />
109
+ ) ) }
110
+ </ motion . div >
111
+ </ div >
91
112
< div
92
113
id = "tests"
93
114
className = "absolute right-0 z-20 h-full w-10 bg-gradient-to-r from-transparent to-black to-75% text-white sm:w-40"
94
115
/>
95
116
< button
96
- onClick = { ( ) => handleSliderButton ( 1 ) }
117
+ onClick = { ( ) => handleSliderButtonRight ( 1 ) }
97
118
className = "group absolute right-10 z-30 flex h-6 w-8 items-center justify-center rounded-full border border-white/20 bg-black bg-gradient-to-r from-white/10 to-black hover:border-white/30"
98
119
>
99
120
< FaChevronRight
@@ -164,3 +185,4 @@ const roles = [
164
185
] ;
165
186
166
187
export default Hero ;
188
+
0 commit comments