Skip to content

Commit

Permalink
Add href attribute to carousel items
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbegley committed Sep 4, 2023
1 parent 696f5fb commit 36784ca
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/carousel/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ const Carousel = props => {
? item.imgClassName
: 'd-block w-100';

const additionalProps = item.href ? {href: item.href} : {};

return (
<RBCarousel.Item key={item.key}>
<RBCarousel.Item
key={item.key}
as={item.href ? 'a' : 'div'}
{...additionalProps}
>
<img
src={item.src}
className={item.img_class_name || item.imgClassName}
Expand Down Expand Up @@ -148,7 +154,11 @@ Carousel.propTypes = {
*
* The class name for the header and caption container
*/
captionClassName: PropTypes.string
captionClassName: PropTypes.string,
/**
* Optional hyperlink to add to the item.
*/
href: PropTypes.string
})
).isRequired,

Expand Down

0 comments on commit 36784ca

Please sign in to comment.