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.
 
 
 
 

38 lines
1.3 KiB

  1. import '../slider/slider.scss';
  2. import './quick-facts.scss';
  3. import $ from 'jquery';
  4. import {QuickFactsData} from "./QuickFactsData";
  5. import {createElement, formatNumber} from "../../_global/scripts/helpers";
  6. import IHKQuickFacts from "./quick-facts";
  7. export const createQuickFacts = ({
  8. headline = 'Quick Facts',
  9. facts = QuickFactsData,
  10. }) => {
  11. const section = createElement('section', ['quick-facts']);
  12. const container = createElement('div', ['container'], null, section);
  13. if (headline && headline.length > 0) {
  14. createElement('h2', [], headline, container);
  15. }
  16. const slider = createElement('div', ['slider'], null, container);
  17. facts.map((fact) => {
  18. const slide = createElement('div', ['slide'], null, slider);
  19. if (fact.counter) {
  20. const p = createElement('p', [], null, slide);
  21. const targetValue = formatNumber(fact.counter.to, fact.counter.decimals);
  22. const counter = createElement('span', ['counter'], targetValue, p);
  23. counter.dataset.from = fact.counter.from;
  24. counter.dataset.to = fact.counter.to;
  25. counter.dataset.duration = fact.counter.duration;
  26. counter.dataset.decimals = fact.counter.decimals;
  27. createElement('span', ['fact-label'], fact.label, p);
  28. } else {
  29. createElement('p', ['like-h4'], fact.label, slide);
  30. }
  31. })
  32. new IHKQuickFacts($(section));
  33. return section;
  34. }