import { dsButtonToggle } from '@bonniernews/dn-design-system-web/components/button/button-interactions.js';

export { dsBylineList, dsBylineListAll };

function dsBylineList(listElements = []) {
  if (!listElements.length) return;
  listElements.forEach((listEl) => {
    const toggleElements = Array.from(listEl.getElementsByClassName('ds-btn--toggle'));
    dsButtonToggle(toggleElements);
    if (listEl.classList.contains('ds-btn--toggle')) {
      dsButtonToggle(listEl);
    }
  });
}

function dsBylineListAll() {
  const listElements = Array.from(document.getElementsByClassName('ds-byline-list__item__content'));
  dsBylineList(listElements);
}
