@@ -7,7 +7,7 @@ import TextButton from "../TextButton";
77import React , { useState } from "react" ;
88import { useRouter } from "next/router" ;
99import Image from "next/image" ;
10- import { FaChevronRight } from "react-icons/fa" ;
10+ import { FaChevronRight , FaChevronLeft } from "react-icons/fa" ;
1111import HeroCard from "../HeroCard" ;
1212import PurpleHeroIcon from "../../../public/icons/icon-hero-purple.svg" ;
1313import GreenHeroIcon from "../../../public/icons/icon-hero-green.svg" ;
@@ -22,9 +22,18 @@ const Hero: React.FC<{ className?: string }> = ({ className }) => {
2222 const [ sliderIndex , setSliderIndex ] = useState ( 0 ) ;
2323 const totalCards = roles . length ;
2424
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+ }
2837 } ;
2938
3039 return (
@@ -70,30 +79,42 @@ const Hero: React.FC<{ className?: string }> = ({ className }) => {
7079 Experience a new way of working.
7180 </ p >
7281 </ 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"
7887 >
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 >
91112 < div
92113 id = "tests"
93114 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"
94115 />
95116 < button
96- onClick = { ( ) => handleSliderButton ( 1 ) }
117+ onClick = { ( ) => handleSliderButtonRight ( 1 ) }
97118 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"
98119 >
99120 < FaChevronRight
@@ -164,3 +185,4 @@ const roles = [
164185] ;
165186
166187export default Hero ;
188+
0 commit comments