generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #933 from FaheemOnHub/fix/faheemonhub/update-meshe…
…ry-cloud-design feat: add similar design by type
- Loading branch information
Showing
10 changed files
with
192 additions
and
63 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,57 @@ | ||
import { ChevronLeft, ChevronRight } from '@mui/icons-material'; | ||
import React, { ReactNode, useRef } from 'react'; | ||
|
||
interface CarouselProps { | ||
items: ReactNode[]; | ||
title?: string; | ||
scrollAmount?: number; | ||
showNavButtons?: boolean; | ||
itemClassName?: string; | ||
} | ||
|
||
import { CarouselButton, CarouselContainer, CarouselWrapper } from './style'; | ||
|
||
const Carousel: React.FC<CarouselProps> = ({ | ||
items, | ||
scrollAmount = 300, | ||
showNavButtons = true, | ||
itemClassName = 'carousel-item' | ||
}) => { | ||
const carouselRef = useRef<HTMLDivElement>(null); | ||
|
||
// Skip rendering if no items | ||
if (!items.length) return null; | ||
|
||
const scroll = (direction: 'left' | 'right') => { | ||
if (carouselRef.current) { | ||
carouselRef.current.scrollBy({ | ||
left: direction === 'left' ? -scrollAmount : scrollAmount, | ||
behavior: 'smooth' | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<CarouselWrapper> | ||
{showNavButtons && ( | ||
<CarouselButton onClick={() => scroll('left')}> | ||
<ChevronLeft /> | ||
</CarouselButton> | ||
)} | ||
<CarouselContainer ref={carouselRef}> | ||
{items.map((item, index) => ( | ||
<div key={`carousel-item-${index}`} className={itemClassName}> | ||
{item} | ||
</div> | ||
))} | ||
</CarouselContainer> | ||
{showNavButtons && ( | ||
<CarouselButton onClick={() => scroll('right')}> | ||
<ChevronRight /> | ||
</CarouselButton> | ||
)} | ||
</CarouselWrapper> | ||
); | ||
}; | ||
|
||
export default Carousel; |
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
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
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
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
Oops, something went wrong.