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

221 строка
9.1 KiB

  1. import './marketingheader.scss';
  2. import '../../components/artwork/artwork.scss';
  3. import '../slider/slider.scss';
  4. import $ from 'jquery';
  5. import {createElement, createImage} from "../../_global/scripts/helpers";
  6. import {createArtwork} from "../../components/artwork/ArtworkComponent";
  7. import {createSearchInput} from "../../atoms/search-input/SearchInputComponent";
  8. import {createSearchButton} from "../../atoms/search-button/SearchButtonComponent";
  9. import IHKSearchTypeahead from "./marketingheader-typeahead";
  10. import {createButton} from "../../atoms/button/ButtonComponent";
  11. import IHKMHSlider from "./marketingheaderslider";
  12. import {searchData, teaserData, sliderData} from "./MarketingHeaderData";
  13. import {createMiniTeaser} from "../../components/mini-teaser/MiniTeaserComponent";
  14. import IHKSearchAccordion from "./searchAccordion";
  15. export const createMarketingHeader =
  16. ({
  17. artworkStyle = 'artwork-both-sides',
  18. placeholder = 'Hier Ihr Thema finden',
  19. api = 'services/search/{SEARCHTERM}.json',
  20. tiles = searchData,
  21. kicker = 'Noch 7 Tage offen',
  22. headline = 'Jetzt und digital mitreden',
  23. copy = 'Mit der digitalen Beteiligung erhalten Mitgliedsunternehmen die Möglichkeit, sich einfach und schnell über laufende Verfahren und Abstimmungen zu informieren und sich aktiv daran zu beteiligen.',
  24. moreCta = {
  25. label: 'Mehr Infos',
  26. link: '#',
  27. target: '_self',
  28. },
  29. buttonCta = {
  30. label: 'Jetzt beteiligen',
  31. link: '#',
  32. target: '_self',
  33. },
  34. showProgress = true,
  35. progress = 60,
  36. backgroundImage = null,
  37. pictoImage = null,
  38. pictoImageMobile = null,
  39. isFirstElement = false,
  40. searchAllButton = false,
  41. slides = sliderData,
  42. teasers = teaserData,
  43. maxItems = 3,
  44. type = 'infoteaser',
  45. }) => {
  46. const section = createElement('section', ['marketingheader', type], null);
  47. const search = createElement('div', ['search','variant-subtle-primary'], null, section);
  48. if (searchAllButton) {
  49. search.classList.add('has-button-wrapper');
  50. }
  51. if (backgroundImage && backgroundImage.length > 0) {
  52. search.style = 'background-image: url(' + backgroundImage + ');';
  53. search.classList.add('background-image');
  54. }
  55. if (pictoImage && pictoImage.length > 0 && pictoImageMobile && pictoImageMobile.length > 0) {
  56. search.classList.add('picto-image');
  57. const styleElement = document.createElement('style');
  58. styleElement.textContent = `
  59. .picto-image {background-image: url("${pictoImage}");}
  60. @media (max-width: 767px) {
  61. .picto-image {background-image: url("${pictoImageMobile}");}
  62. }
  63. `;
  64. search.parentNode.insertBefore(styleElement, search.nextSibling);
  65. }
  66. const artwork = createArtwork({type: artworkStyle});
  67. search.appendChild(artwork);
  68. search.dataset.type = artworkStyle;
  69. const container = createElement('div', ['container', 'small'], null, search);
  70. const row = createElement('div', ['row'], null, container);
  71. const col = createElement('div', ['col'], null, row);
  72. const form = createElement('form', [], null, col);
  73. const label = createElement('label', ['visually-hidden'], 'IHK durchsuchen', form);
  74. label.for = 'search-term';
  75. form.appendChild(createSearchInput({api: api, placeholder: placeholder}));
  76. form.appendChild(createSearchButton({}));
  77. form.action = '#';
  78. const tilesContainer = createElement('div', ['tiles'], null, col);
  79. tiles.map((tile) => {
  80. if (tile.type) {
  81. const div = createElement('div', ['tile', tile.type, 'variant-base'], null, tilesContainer);
  82. const outer = createElement('div', ['outer'], null, div);
  83. const inner = createElement('div', ['inner'], null, outer);
  84. const p = createElement('p', [], null, inner);
  85. const a = createElement('a', [], tile.title + (tile.count ? ' (' + tile.count + ')' : ''), p);
  86. a.href = tile.link;
  87. if (tile.items && tile.items.length > 0) {
  88. const ul = createElement('ul', [], null, inner);
  89. tile.items.slice(0, 2).map((item) => {
  90. const li = createElement('li', [], null, ul);
  91. const itemA = createElement('a', [], item.title, li);
  92. itemA.href = item.link;
  93. itemA.title = item.title;
  94. });
  95. }
  96. } else {
  97. const div = createElement('div', ['tile','variant-base'], null, tilesContainer);
  98. const a = createElement('a', [], tile.title, div);
  99. a.href = tile.link;
  100. }
  101. });
  102. if (searchAllButton) {
  103. const allButtonWrapper = createElement('span', ['all-button-wrapper'], null, col);
  104. const searchAllBtn = createElement('div', ['btn', 'has-icon', 'icon-small-arrow-right-simple'], 'Alle Suchergebnisse', allButtonWrapper);
  105. }
  106. if (api) {
  107. new IHKSearchTypeahead($(form).find('input.typeahead'));
  108. }
  109. /* Accordion */
  110. const sc = createElement('div', ['container','sc'], null, search);
  111. $(document).ready(() => {
  112. new IHKSearchAccordion($(search));
  113. })
  114. createElement('button', ['close-search'], '', sc);
  115. /* SLIDER */
  116. const container2 = createElement('div', ['container', 'mainstage'], null, section);
  117. if (type === 'hero-fullwidth') {
  118. container2.classList.add('variant-solid');
  119. }
  120. const row2 = createElement('div', ['row'], null, container2);
  121. const colslider = createElement('div', ['col', 'slidercontainer', 'rotation'], null, row2);
  122. const sliderComponent = createElement('div', ['slider', 'btnanimation'], null, colslider);
  123. slides.map((slideData, index) => {
  124. const slide = createElement('div', ['slide'], null, sliderComponent);
  125. const outer = createElement('outer', ['outer'], null, slide);
  126. const contextBoxContent = slideData.context ? slideData.context : '';
  127. const contextBoxContentImg = slideData.contextImg ? slideData.contextImg : '';
  128. // Image-Box wird IMMER erstellt
  129. const imageBox = createElement('div', ['image-box'], null, outer);
  130. // Bild wird nur gerendert, wenn imageSrc vorhanden
  131. if (slideData.imageSrc && slideData.imageSrc.length > 0) {
  132. const picture = createElement('picture', [], null, imageBox);
  133. const src1 = createElement('source', [], null, picture);
  134. src1.setAttribute('media','(min-width: 1000px)');
  135. src1.setAttribute('srcset',slideData.imageSrc);
  136. const src2 = createElement('source', [], null, picture);
  137. src2.setAttribute('media','(min-width: 901px)');
  138. src2.setAttribute('srcset',slideData.imageSrc);
  139. createImage(slideData.imageSrc, 900, 600, 'Slide ' + index, [], picture);
  140. const copyright = createElement('span', ['copyright'], 'Copyright-Angabe', imageBox);
  141. copyright.setAttribute("aria-hidden", "true");
  142. createElement('span', ['sr-only'], 'Copyright-Angabe', imageBox);
  143. } else {
  144. const textInImageBox = createElement('div', ['text-in-image-box'], null, imageBox);
  145. createElement('div', ['icon', 'pictogram-bueroklammer'], null, textInImageBox);
  146. createElement('p', [], 'Wachstum durch Innovation lorem ipsum dolor sit amet', textInImageBox);
  147. }
  148. // Context-Box immer in image-box (egal ob Bild oder nicht)
  149. if (contextBoxContentImg) {
  150. const contentBoxImg = createElement('div', ['context-box', 'variant-solid', 'context-box--image'], null, imageBox);
  151. createImage(contextBoxContentImg, 200, 50, '', [], contentBoxImg);
  152. } else if (contextBoxContent) {
  153. createElement('div', ['context-box', 'variant-solid'], contextBoxContent, imageBox);
  154. }
  155. const textBox = createElement('div', ['text-box'], null, outer);
  156. // Klasse 'context' hinzufügen, wenn kein Bild vorhanden
  157. if (!slideData.imageSrc || slideData.imageSrc.length <= 0) {
  158. if (contextBoxContent || contextBoxContentImg) {
  159. textBox.classList.add('context');
  160. }
  161. }
  162. if (slideData.kicker && slideData.kicker.length > 0) {
  163. createElement('span', ['kicker'], slideData.kicker, textBox);
  164. }
  165. if (slideData.headline && slideData.headline.length > 0) {
  166. createElement('div', ['like-h2'], slideData.headline, textBox);
  167. }
  168. if (slideData.copy && slideData.copy.length > 0) {
  169. createElement('p', [], slideData.copy, textBox);
  170. }
  171. if (slideData.cta && slideData.link) {
  172. const buttonP = createElement('p', [], '', textBox);
  173. const btn = createButton({
  174. color: 'white', icon: 'pfeil-simple-rechts', iconPosition: 'icon-right', label: slideData.cta, size: 'small',
  175. });
  176. buttonP.appendChild(btn);
  177. }
  178. });
  179. new IHKMHSlider($(sliderComponent));
  180. if (type === 'infoteaser') {
  181. const col3 = createElement('div', ['col'], null, row2);
  182. teasers.map((t, i) => {
  183. if (i < maxItems) {
  184. var typ = 'standard';
  185. if (i == 0 && t.type == 'infoteaser'){
  186. typ = 'infoteaser';
  187. section.classList.add('miniinfoteaser');
  188. }
  189. const col4 = createElement('div', ['mt'], null, col3);
  190. const tea = createMiniTeaser({
  191. type : typ,
  192. })
  193. col4.appendChild(tea);
  194. }
  195. })
  196. }
  197. return section;
  198. }