Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HRProcess.jsx 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import React, { useRef, useEffect } from 'react';
  2. import { useScroll } from 'framer-motion';
  3. const api_url = process.env.REACT_APP_API_URL;
  4. const HRProcess = ({ data }) => {
  5. //console.log(data);
  6. const ref = useRef(null);
  7. const { scrollYProgress } = useScroll({ container: ref });
  8. useEffect(() => {
  9. const imageArray = document.querySelectorAll('.image-switch');
  10. //console.log(imageArray);
  11. const switchImage = scrollYProgress.onChange(value => {
  12. if (value <= 0.1) {
  13. imageArray.forEach(el => el.classList.remove('active-image'));
  14. imageArray[0].classList.add('active-image');
  15. }
  16. if (value > 0.1) {
  17. imageArray.forEach(el => el.classList.remove('active-image'));
  18. imageArray[1].classList.add('active-image');
  19. }
  20. if (value > 0.4) {
  21. imageArray.forEach(el => el.classList.remove('active-image'));
  22. imageArray[2].classList.add('active-image');
  23. }
  24. if (value > 0.6) {
  25. imageArray.forEach(el => el.classList.remove('active-image'));
  26. imageArray[3].classList.add('active-image');
  27. }
  28. if (value > 0.8) {
  29. imageArray.forEach(el => el.classList.remove('active-image'));
  30. imageArray[4].classList.add('active-image');
  31. }
  32. });
  33. return () => {
  34. switchImage();
  35. };
  36. });
  37. return (
  38. <div
  39. ref={ref}
  40. id="steps-container"
  41. className="steps-container no-scrollbar flex flex-col items-center justify-start overflow-auto h-[75vh] pt-72p pl-3"
  42. >
  43. {/* Dynamic Image */}
  44. {data.selection_process.steps.map((item, index) => (
  45. <img
  46. key={index}
  47. src={api_url + item.media.data.attributes.url}
  48. alt={item.media.data.attributes.alternativeText}
  49. className={
  50. 'image-switch bg-fixed hidden sm:block opacity-0 absolute top-1/4 right-10 w-2/5 transition-all' +
  51. (index == 0 ? ' active-image' : '')
  52. }
  53. />
  54. ))}
  55. <div className="local">
  56. {data.selection_process.steps.map((item, index) => (
  57. <>
  58. {/* Section */}
  59. <div
  60. id={item.id}
  61. className="relative flex flex-col sm:flex-row items-start justify-center sm:gap-16 min-h-fit max-h[100vh] mb-28 md:mb-56"
  62. >
  63. {/* Line */}
  64. <hr className="bg-gray-400 w-full absolute -left-1/2 rotate-90" />
  65. {/* Dot */}
  66. <div className="z-10 p-[0.36rem] rounded-full bg-white border-solid border border-dg-primary-900 absolute -left-[0.63%] top-[1%]"></div>
  67. <div className="sm:w-1/2 ml-8">
  68. <h3 className="h3-heading">{item.heading}</h3>
  69. <p className="text-sm text-dark-gray dark:text-white mt-4">
  70. {item.paragraph}
  71. </p>
  72. {item.cto != null && (
  73. <button className="btn-secondary mt-6 min-w-fit">{item.cto}</button>
  74. )}
  75. </div>
  76. <div className="w-1/2"></div>
  77. </div>
  78. </>
  79. ))}
  80. </div>
  81. </div>
  82. );
  83. };
  84. export default HRProcess;