import styled from "styled-components"; import { generateKeys } from "../utils/helper"; interface Props { total: number; currentIndex: number; } interface IndicatorItemProps { isCurrent?: boolean; } const Indicator = ({ total, currentIndex }: Props) => { const renderIndicatorItem = () => { const keys: Array = generateKeys(total); return keys.map((key, index) => { if (index === currentIndex) { return ; } else { return ; } }); }; return ( {total < 10 ? ( renderIndicatorItem() ) : ( {currentIndex + 1} of {total} )} ); }; export default Indicator; const Container = styled.div` box-sizing: border-box; position: absolute; top: 95%; width: 100%; display: flex; justify-content: center; `; const IndicatorItem = styled.span` width: 1rem; height: 1rem; margin: 0.4rem; border-radius: 50%; background: ${(props) => (props.isCurrent ? "#242424d9" : "#585858c2")}; cursor: pointer; `; const TextIndicator = styled.p` color: "#242424d9"; `;