import './pagination.scss';
import {createElement} from "../../_global/scripts/helpers";
import {createButton} from "../button/ButtonComponent";

export const createPagination = ({
  length = 5,
  current = 1,
}) => {
  const pagination = createElement('div', ['pagination', 'variant-base']);
  const ul = createElement('ul', [], null, pagination);
  for (let i = 0; i < length; i++) {
    const li = createElement('li', [], null, ul);
    const btn = createButton({label:(i + 1).toString()});
    if (i === current - 1) {
      btn.classList.add('current');
    }
    li.appendChild(btn);
  }

  return pagination;
}