forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarouselIndicators.js
More file actions
40 lines (35 loc) · 1.08 KB
/
Copy pathCarouselIndicators.js
File metadata and controls
40 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules } from './utils';
const CarouselIndicators = (props) => {
const { items, activeIndex, cssModule, onClickHandler, className } = props;
const listClasses = mapToCssModules(classNames(className, 'carousel-indicators'), cssModule);
const indicators = items.map((item, idx) => {
const indicatorClasses = mapToCssModules(classNames(
{ active: activeIndex === idx }
), cssModule);
return (
<li
key={`${item.key || item.src}${item.caption}${item.altText}`}
onClick={(e) => {
e.preventDefault();
onClickHandler(idx);
}}
className={indicatorClasses}
/>);
});
return (
<ol className={listClasses}>
{indicators}
</ol>
);
};
CarouselIndicators.propTypes = {
items: PropTypes.array.isRequired,
activeIndex: PropTypes.number.isRequired,
cssModule: PropTypes.object,
onClickHandler: PropTypes.func.isRequired,
className: PropTypes.string,
};
export default CarouselIndicators;