Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

109 Zeilen
3.2 KiB

  1. import './teasers.scss';
  2. import $ from 'jquery';
  3. import {createElement} from "../../_global/scripts/helpers";
  4. import {createTeaser} from "../../components/teaser/TeaserComponent";
  5. import {teasersData} from "./TeasersData";
  6. import Masonry from "../../_global/scripts/masonry";
  7. import {createTeaserSocial} from "../../components/teaser-social/TeaserSocialComponent";
  8. export const createTeasersSection = ({
  9. type = 'regular',
  10. background = null,
  11. headline = '',
  12. teasers = teasersData,
  13. showReadingTime = false,
  14. hideKicker = false,
  15. maxItems = -1,
  16. includeChart = false,
  17. includeSocial = false,
  18. }) => {
  19. const baseTeaser = {
  20. type: 'regular',
  21. kicker: 'Fachkräfte',
  22. headline: 'Anteil der Frauen im Bereich Engineering steigt',
  23. 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. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita, no sea takimata sanctus est.',
  24. imageSrc: 'https://source.unsplash.com/0K7GgiA8lVE/600x400',
  25. copyright: '@ shutterstock.com',
  26. showReadingTime: false,
  27. link: '#',
  28. imageSize: 'large',
  29. };
  30. switch (type) {
  31. case 'regular':
  32. maxItems = maxItems === -1 ? 3 : maxItems;
  33. break;
  34. case 'text':
  35. maxItems = maxItems === -1 ? 3 : maxItems;
  36. break;
  37. case 'hero':
  38. maxItems = maxItems === -1 ? 2 : maxItems;
  39. break;
  40. case 'fullwidth':
  41. maxItems = 1;
  42. break;
  43. case 'magazine':
  44. maxItems = teasers.length;
  45. break;
  46. }
  47. const section = createElement('section', type === 'magazine' ? ['teasers', 'magazine-style'] : ['teasers']);
  48. if (type !== 'magazine') {
  49. section.dataset.items = maxItems > 3 ? '3' : maxItems.toString();
  50. }
  51. if (background && background.length > 0) {
  52. section.dataset.background = background;
  53. }
  54. const container = createElement('div', ['container'], null, section);
  55. if (headline && headline.length > 0) {
  56. createElement('h2', [], headline, container);
  57. }
  58. const row = createElement('div', ['row'], null, container);
  59. function getType(index) {
  60. if (includeChart && index === maxItems - 1) {
  61. return 'chart';
  62. }
  63. return type === 'magazine' ? 'regular' : type;
  64. }
  65. if (includeSocial) {
  66. maxItems -= 1;
  67. }
  68. teasers.map((teaserData, index) => {
  69. if (index >= maxItems) {
  70. return;
  71. }
  72. const col = createElement('div', ['col'], null, row);
  73. const teaser = createTeaser({
  74. ...baseTeaser,
  75. ...teaserData,
  76. type: getType(index),
  77. showReadingTime: type === 'magazine' || type === 'fullwidth' ? true : showReadingTime,
  78. kicker: hideKicker ? null : teaserData.kicker,
  79. })
  80. col.appendChild(teaser);
  81. })
  82. if (includeSocial) {
  83. const col = createElement('div', ['col'], null, row);
  84. col.appendChild(createTeaserSocial({kicker: hideKicker ? null : 'Ihre IHK bei Twitter'}));
  85. }
  86. if (type === 'magazine') {
  87. $(document).ready(() => {
  88. const btnText = window.ihk.translations.loadMoreArticles;
  89. section.dataset.type = 'masonry';
  90. new Masonry($(row), btnText, [
  91. {minWidth: 0, batchSize: 2},
  92. {minWidth: 567, batchSize: 3},
  93. {minWidth: 1000, batchSize: 6}
  94. ])
  95. })
  96. }
  97. return section;
  98. }