Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

63 řádky
2.4 KiB

  1. import './infobanner.scss';
  2. import {createElement, createImage} from "../../_global/scripts/helpers";
  3. import {createButton} from "../../atoms/button/ButtonComponent";
  4. export const createInfoBanner =
  5. ({
  6. kicker = 'Dachzeile des Infobanners',
  7. headline = 'Die Headline des Infobanners',
  8. copy = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.',
  9. buttonText = 'Call to action',
  10. link = '#',
  11. imageSrc = './dummy/placeholder-4-3.svg',
  12. imageSrcMobile = './dummy/placeholder-1-1.svg',
  13. isCommercial = true,
  14. }) => {
  15. const section = createElement('section', ['infobanner'], null);
  16. const container = createElement('div', ['container'], null, section);
  17. const banner = createElement('a', ['banner'], null, container);
  18. if (imageSrc && imageSrcMobile && imageSrc.length > 0 && imageSrcMobile.length > 0) {
  19. const imageBox = createElement('div', ['image-box'], null, banner);
  20. const picture = createElement('picture', [], null, imageBox);
  21. const mobileSource = createElement('source', [], null, picture);
  22. createImage(imageSrc, 1340, 240, 'Infobanner Hintergrundbild', [], picture);
  23. mobileSource.srcset = imageSrcMobile;
  24. mobileSource.media = '(max-width: 567px)';
  25. }
  26. if (kicker.length > 0 || headline.length > 0 || copy.length > 0 || buttonText.length > 0) {
  27. const textWrapper = createElement('div', ['text-wrapper'], null, banner);
  28. const textBox = createElement('div', ['text-box'], null, textWrapper);
  29. if (kicker && kicker.length > 0) {
  30. createElement('span', ['kicker'], kicker, textBox);
  31. }
  32. if (headline && headline.length > 0) {
  33. createElement('h2', ['like-h2'], headline, textBox);
  34. }
  35. if (copy && copy.length > 0) {
  36. createElement('p', [], copy, textBox);
  37. }
  38. if (buttonText && buttonText.length > 0) {
  39. const buttonBox = createElement('div', ['button-box'], null, textWrapper);
  40. const btn = createButton({
  41. elementType: 'span',
  42. icon: 'pfeil-simple-rechts',
  43. color: 'white',
  44. label: buttonText,
  45. iconPosition: 'icon-right',
  46. })
  47. buttonBox.appendChild(btn);
  48. }
  49. }
  50. if (isCommercial) {
  51. createElement('span', ['is-commercial'], 'Werbung', banner);
  52. }
  53. banner.href = link;
  54. return section;
  55. }