import React, { useMemo } from "react";
import * as S from "./dots.style";
function makeData(dots, shift, width) {
const normShift = shift >= 0 ? shift : shift - dots.length * shift;
return dots.map((dot, index) => ({
key: dot,
isFirst: index === 0,
isLast: index === dots.length - 1,
left: ((normShift + index) % dots.length) * width
}));
}
export const Dots = ({ dots, shift }) => {
const data = useMemo(() => makeData(dots, shift, 25), [dots, shift]);
return (
<S.Container>
{data.map(({ key, left, children }) => (
<S.Dot key={key} left={left}>
{key}
</S.Dot>
))}
</S.Container>
);
};