-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added transition on right side, fixed styling a little bit
- Loading branch information
Showing
5 changed files
with
204 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
.testimonials { | ||
margin-top: 1rem; | ||
width: 100%; | ||
|
||
[class^='number-slide'], | ||
[class*=' number-slide'] { | ||
background: grey; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 50px; | ||
color: #fff; | ||
font-weight: 500; | ||
height: 300px; | ||
max-height: 100vh; | ||
} | ||
|
||
h3 { | ||
@media (max-width: $tablet-breakpoint) { | ||
margin-top: 0; | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
margin-bottom: 2rem; | ||
} | ||
|
||
.slider-wrapper { | ||
position: relative; | ||
width: 100%; | ||
|
||
ul { | ||
background-color: white; | ||
padding-left: 0; | ||
list-style-type: none; | ||
position: relative; | ||
|
||
&::before { | ||
content: ''; | ||
display: block; | ||
width: 50px; | ||
height: 100%; | ||
background-color: white; | ||
background: linear-gradient(to right, white, transparent); | ||
position: absolute; | ||
left: 0; | ||
} | ||
|
||
&::after { | ||
content: ''; | ||
display: block; | ||
width: 50px; | ||
height: 100%; | ||
background-color: white; | ||
background: linear-gradient(to left, white, transparent); | ||
position: absolute; | ||
right: 0; | ||
} | ||
|
||
li { | ||
.reviewer { | ||
text-align: right; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.arrow-container { | ||
display: flex; | ||
position: absolute; | ||
right: 0; | ||
bottom: 0; | ||
|
||
.arrow { | ||
width: 30px; | ||
height: 30px; | ||
top: 0; | ||
transform: translateY(-50%); | ||
-webkit-transform: translateY(-50%); | ||
fill: #fff; | ||
cursor: pointer; | ||
} | ||
|
||
.arrow--left, | ||
.arrow--right { | ||
background-color: black; | ||
padding: 10% 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useState } from 'react'; | ||
import './Testimonial.scss'; | ||
import { useKeenSlider } from 'keen-slider/react'; | ||
import 'keen-slider/keen-slider.min.css'; | ||
import { TESTIMONIAL_LIST } from './constants'; | ||
|
||
export default function Testimonial() { | ||
const [currentSlide, setCurrentSlide] = useState(0); | ||
const [loaded, setLoaded] = useState(false); | ||
const [sliderRef, instanceRef] = useKeenSlider<HTMLUListElement>({ | ||
loop: true, | ||
slideChanged(slider) { | ||
setCurrentSlide(slider.track.details.rel); | ||
}, | ||
created() { | ||
setLoaded(true); | ||
}, | ||
slides: { | ||
perView: 3, | ||
spacing: 40 | ||
} | ||
}); | ||
|
||
return ( | ||
<div className="testimonials"> | ||
<h3>See some testimonials from previous participants:</h3> | ||
<div className="slider-wrapper"> | ||
<ul ref={sliderRef} className="keen-slider"> | ||
{TESTIMONIAL_LIST.map(testimonial => ( | ||
<li key={testimonial.id} className="keen-slider__slide"> | ||
<p>{testimonial.text}</p> | ||
<p className="reviewer">- PAST UPGRADER</p> | ||
</li> | ||
))} | ||
</ul> | ||
{loaded && instanceRef.current && ( | ||
<div className="arrow-container"> | ||
<Arrow | ||
left | ||
onClick={(e: any) => | ||
e.stopPropagation() || instanceRef.current?.prev() | ||
} | ||
disabled={currentSlide === 0} | ||
/> | ||
<Arrow | ||
onClick={(e: any) => | ||
e.stopPropagation() || instanceRef.current?.next() | ||
} | ||
disabled={ | ||
currentSlide === | ||
instanceRef.current.track.details.slides.length - 1 | ||
} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function Arrow(props: { | ||
disabled: boolean; | ||
left?: boolean; | ||
// eslint-disable-next-line no-unused-vars | ||
onClick: (e: any) => void; | ||
}) { | ||
const disabled = props.disabled ? ' arrow--disabled' : ''; | ||
return ( | ||
<svg | ||
onClick={props.onClick} | ||
className={`arrow ${ | ||
props.left ? 'arrow--left' : 'arrow--right' | ||
} ${disabled}`} | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
> | ||
{props.left && ( | ||
<path d="M16.67 0l2.83 2.829-9.339 9.175 9.339 9.167-2.83 2.829-12.17-11.996z" /> | ||
)} | ||
{!props.left && ( | ||
<path d="M5 3l3.057-3 11.943 12-11.943 12-3.057-3 9-9z" /> | ||
)} | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const TESTIMONIAL_LIST = [ | ||
{ | ||
id: 'testimonial-1', | ||
text: '“Learning about marketing and social media branding was a plus for sure, I feel like I needed an intro to many of the topics covered and there was no better way to do so than taking a part of such a versatile and dedicated team that ranged in skills, talents, and industry knowledge.”' | ||
}, | ||
{ | ||
id: 'testimonial-2', | ||
text: '“Learning about marketing and social media branding was a plus for sure, I feel like I needed an intro to many of the topics covered and there was no better way to do so than taking a part of such a versatile and dedicated team that ranged in skills, talents, and industry knowledge.”' | ||
}, | ||
{ | ||
id: 'testimonial-3', | ||
text: '“Learning about marketing and social media branding was a plus for sure, I feel like I needed an intro to many of the topics covered and there was no better way to do so than taking a part of such a versatile and dedicated team that ranged in skills, talents, and industry knowledge.”' | ||
}, | ||
{ | ||
id: 'testimonial-4', | ||
text: '“Learning about marketing and social media branding was a plus for sure, I feel like I needed an intro to many of the topics covered and there was no better way to do so than taking a part of such a versatile and dedicated team that ranged in skills, talents, and industry knowledge.”' | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters