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.
 
 
 
 

73 line
3.1 KiB

  1. import './slider.scss';
  2. import {createElement, createImage} from "../../_global/scripts/helpers";
  3. import $ from 'jquery';
  4. import {createButton} from "../../atoms/button/ButtonComponent";
  5. import IHKSlider from "./slider";
  6. import {sliderData} from "./SliderData";
  7. export const createSlider =
  8. ({
  9. slides = sliderData,
  10. }) => {
  11. const section = createElement('section', ['rotation'], null);
  12. const container = createElement('div', ['container'], null, section);
  13. const sliderComponent = createElement('div', ['slider'], null, container);
  14. slides.map((slideData, index) => {
  15. const slide = createElement('div', ['slide'], null, sliderComponent);
  16. const outer = createElement('outer', ['outer'], null, slide);
  17. const contextBoxContent = slideData.context ? slideData.context : '';
  18. const contextBoxContentImg = slideData.contextImg ? slideData.contextImg : '';
  19. if (slideData.imageSrc && slideData.imageSrc.length > 0) {
  20. const imageBox = createElement('div', ['image-box'], null, outer);
  21. createImage(slideData.imageSrc, 900, 600, 'Slide ' + index, [], imageBox);
  22. if (slideData.copyright && slideData.copyright.length > 0) {
  23. const copy = createElement('span', ['copyright'], slideData.copyright, imageBox);
  24. copy.setAttribute("aria-hidden", "true");
  25. createElement('span', ['sr-only'], slideData.copyright, imageBox);
  26. }
  27. if (contextBoxContentImg) {
  28. const contentBoxImg = createElement('div', ['context-box', 'context-box--image'], null, imageBox);
  29. createImage(contextBoxContentImg, 200, 50, '', [], contentBoxImg);
  30. } else if (contextBoxContent) {
  31. createElement('div', ['context-box'], contextBoxContent, imageBox);
  32. }
  33. }
  34. const textBox = createElement('div', ['text-box'], null, outer);
  35. if (slideData.kicker && slideData.kicker.length > 0) {
  36. createElement('span', ['kicker'], slideData.kicker, textBox);
  37. }
  38. if (slideData.headline && slideData.headline.length > 0) {
  39. createElement('h3', ['like-h2'], slideData.headline, textBox);
  40. }
  41. if (slideData.kicker && slideData.kicker.length > 0) {
  42. createElement('p', [], slideData.copy, textBox);
  43. }
  44. if (slideData.cta && slideData.link) {
  45. const buttonP = createElement('p', [], '', textBox);
  46. const btn = createButton({
  47. color: 'white', icon: 'pfeil-simple-rechts', iconPosition: 'icon-right', label: slideData.cta
  48. });
  49. buttonP.appendChild(btn);
  50. }
  51. if (!slideData.imageSrc || slideData.imageSrc.length <= 0) {
  52. if (contextBoxContent) {
  53. textBox.classList.add('context');
  54. if (contextBoxContentImg) {
  55. const contentBox = createElement('div', ['context-box', 'context-box--image'], null, textBox);
  56. createImage(contextBoxContentImg, 200, 50, '', [], contentBox);
  57. } else if (contextBoxContent) {
  58. createElement('div', ['context-box'], contextBoxContent, textBox);
  59. }
  60. }
  61. }
  62. })
  63. new IHKSlider($(sliderComponent));
  64. return section;
  65. }