Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

64 строки
2.5 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. banner.setAttribute('aria-label', headline + ' - ' + kicker);
  19. if (imageSrc && imageSrcMobile && imageSrc.length > 0 && imageSrcMobile.length > 0) {
  20. const imageBox = createElement('div', ['image-box'], null, banner);
  21. const picture = createElement('picture', [], null, imageBox);
  22. const mobileSource = createElement('source', [], null, picture);
  23. createImage(imageSrc, 1340, 240, 'Infobanner Hintergrundbild', [], picture);
  24. mobileSource.srcset = imageSrcMobile;
  25. mobileSource.media = '(max-width: 567px)';
  26. }
  27. if (kicker.length > 0 || headline.length > 0 || copy.length > 0 || buttonText.length > 0) {
  28. const textWrapper = createElement('div', ['text-wrapper'], null, banner);
  29. const textBox = createElement('div', ['text-box'], null, textWrapper);
  30. if (kicker && kicker.length > 0) {
  31. createElement('span', ['kicker'], kicker, textBox);
  32. }
  33. if (headline && headline.length > 0) {
  34. createElement('h2', ['like-h2'], headline, textBox);
  35. }
  36. if (copy && copy.length > 0) {
  37. createElement('p', [], copy, textBox);
  38. }
  39. if (buttonText && buttonText.length > 0) {
  40. const buttonBox = createElement('div', ['button-box'], null, textWrapper);
  41. const btn = createButton({
  42. elementType: 'span',
  43. icon: 'pfeil-simple-rechts',
  44. color: 'white',
  45. label: buttonText,
  46. iconPosition: 'icon-right',
  47. })
  48. buttonBox.appendChild(btn);
  49. }
  50. }
  51. if (isCommercial) {
  52. createElement('span', ['is-commercial'], 'Werbung', banner);
  53. }
  54. banner.href = link;
  55. return section;
  56. }