You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
1.1 KiB

  1. import './topic-teaser.scss';
  2. import {createElement} from "../../_global/scripts/helpers";
  3. import {createLinkList} from "../linklist/LinkListComponent";
  4. import lottie from 'lottie-web';
  5. export const createTopicTeaser = ({
  6. type = 'single-topic',
  7. title = 'Hallo Welt',
  8. link = '#',
  9. icon = 'Eule Doktorhut',
  10. lottieFile = null,
  11. linklistData = null,
  12. }) => {
  13. const tile = createElement(type === 'single-topic' ? 'a' : 'div', ['tile', 'topic-teaser','variant-base', type], null);
  14. tile.href = link;
  15. const iconBox = createElement('div', ['icon-box', ...(lottieFile ? ['icon-box--lottie'] : ['pictogram-topic-' + icon.toLowerCase().split(' ').join('-')])], null, tile);
  16. if (lottieFile) {
  17. lottie.loadAnimation({ container: iconBox, renderer: 'svg', loop: true, autoplay: true, path: lottieFile });
  18. }
  19. const textBox = createElement('div', ['text-box'], null, tile);
  20. createElement('h4', ['title'], title, textBox);
  21. if (type === 'topic-linklist') {
  22. const data = linklistData ? linklistData : {};
  23. const ll = createLinkList(data);
  24. textBox.appendChild(ll);
  25. }
  26. return tile;
  27. }