import './topic-teaser.scss';
import {createElement} from "../../_global/scripts/helpers";
import {createLinkList} from "../linklist/LinkListComponent";

export const createTopicTeaser = ({
  type = 'single-topic',
  title = 'Hallo Welt',
  link = '#',
  icon = 'Eule Doktorhut',
  linklistData = null,
}) => {
  const tile = createElement(type === 'single-topic' ? 'a' : 'div', ['tile', 'topic-teaser','variant-base', type], null);
  tile.href = link;
  createElement('div', ['icon-box', 'pictogram-' + icon.toLowerCase().split(' ').join('-')], null, tile);
  const textBox = createElement('div', ['text-box'], null, tile);
  createElement('h4', ['title'], title, textBox);

  if (type === 'topic-linklist') {
    const data = linklistData ? linklistData : {};
    const ll = createLinkList(data);
    textBox.appendChild(ll);
  }

  return tile;
}