Skip to content

Commit

Permalink
update: testimonials sections mobile view
Browse files Browse the repository at this point in the history
  • Loading branch information
jaaaaavier committed Dec 23, 2024
1 parent 771aa3a commit ef1806d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/assets/lang/de/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "Was Experten über uns sagen",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/en/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "What experts are saying about us",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/es/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "Lo que los expertos dicen sobre nosotros",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/fr/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "Ce que les experts disent de nous",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/it/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "Cosa dicono gli esperti di noi",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/ru/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "Что говорят о нас эксперты",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/zh-tw/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"TestimonialsSection": {
"title": "專家對我們的評價",
"betweenDots": "...",
"testimonials": [
{
"imageBrandName": "techradar",
Expand Down
1 change: 1 addition & 0 deletions src/assets/types/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface TestimonialsSection {

export interface Testimonial {
imageBrandName: string;
betweenDots: string;
brand: string;
review: string;
}
Expand Down
57 changes: 37 additions & 20 deletions src/components/business/TestimonialsSectionForBusiness.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const TestimonialsSectionForBusiness = ({ textContent }: TestimonialsSect

const [currentIndex, setCurrentIndex] = useState(0);
const [isTransitioning, setIsTransitioning] = useState(false);
const [mobileIndex, setMobileIndex] = useState(0);

const onLeftArrowClick = () => {
const newIndex = currentIndex === 0 ? testimonialsParts.length - 1 : currentIndex - 1;
Expand All @@ -27,6 +28,15 @@ export const TestimonialsSectionForBusiness = ({ textContent }: TestimonialsSect
const newIndex = currentIndex === testimonialsParts.length - 1 ? 0 : currentIndex + 1;
onTabSelectorButtonClicked(newIndex);
};
const onLeftMobileArrowClick = () => {
const newIndex = mobileIndex === 0 ? textContent.testimonials.length - 1 : mobileIndex - 1;
setMobileIndex(newIndex);
};

const onRightMobileArrowClick = () => {
const newIndex = mobileIndex === textContent.testimonials.length - 1 ? 0 : mobileIndex + 1;
setMobileIndex(newIndex);
};

const onTabSelectorButtonClicked = (index: number) => {
if (currentIndex !== index) {
Expand Down Expand Up @@ -80,28 +90,35 @@ export const TestimonialsSectionForBusiness = ({ textContent }: TestimonialsSect
</div>

{/*Mobile/Tablet View*/}
<div className="scrollbar-thumb-primary scrollbar-track-white flex w-full snap-x snap-mandatory flex-row justify-start gap-6 overflow-scroll xl:hidden">
{textContent.testimonials.map((testimonial) => (
<div
className="mx-auto flex w-full max-w-[375px] shrink-0 snap-center flex-col justify-start rounded-3xl bg-white p-8"
key={testimonial.review}
>
<div className="flex h-full flex-col justify-between gap-3" key={testimonial.review}>
<div className="flex flex-col gap-3">
<FiveStars totalStars={5} />
<p className="text-xl text-gray-80">{testimonial.review}</p>
</div>
<div className="flex h-full items-end">
<Image
src={getImage(`/images/business/logos-b2b/${testimonial.imageBrandName}.svg`)}
alt={testimonial.imageBrandName}
width={185}
height={30}
/>
</div>
<div className="flex w-full snap-x snap-mandatory flex-row flex-col justify-start gap-6 xl:hidden">
<div className="flex items-center justify-center space-x-2 text-center">
<button onClick={onLeftMobileArrowClick} className="flex items-center">
<CaretLeft size={24} />
<span className="ml-2 text-gray-100">{textContent.betweenDots}</span>
</button>
<button onClick={onRightMobileArrowClick} className="flex items-center">
<CaretRight size={24} />
</button>
</div>

<div className="mx-auto flex w-full max-w-[375px] shrink-0 snap-center flex-col justify-start rounded-3xl bg-white p-8">
<div className="flex h-full flex-col justify-between gap-3">
<div className="flex flex-col gap-3">
<FiveStars totalStars={5} />
<p className="text-xl text-gray-80">{textContent.testimonials[mobileIndex].review}</p>
</div>
<div className="flex h-full items-end">
<Image
src={getImage(
`/images/business/logos-b2b/${textContent.testimonials[mobileIndex].imageBrandName}.svg`,
)}
alt={textContent.testimonials[mobileIndex].imageBrandName}
width={185}
height={30}
/>
</div>
</div>
))}
</div>
</div>
</div>
</section>
Expand Down

0 comments on commit ef1806d

Please sign in to comment.