Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ServicesHome.jsx 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import HoverServices from './shared/graphics/HoverServices';
  2. import { useState, useEffect } from 'react';
  3. import axios from 'axios';
  4. import { motion } from 'framer-motion';
  5. import Animation_Diligent from './../assets/animation_diligent.webm';
  6. import './../styles/hexagon.css';
  7. import Wrapper from '../layout/Wrapper';
  8. const api_url = process.env.REACT_APP_API_URL;
  9. export default function ServicesHome() {
  10. const [hoverIndex, SetHoverIndex] = useState(0);
  11. const [change, SetChange] = useState(true);
  12. const [circle, SetCircle] = useState(0);
  13. const [triangle, SetTriangle] = useState(140);
  14. const [hex, SetHex] = useState(270);
  15. //const [angleTriangle, SetAngleTriangle] = useState(0);
  16. //const [angleHex, SetAngleHex] = useState(0);
  17. const [cntServicesHome, setCntServicesHome] = useState('');
  18. const [isLoaded, setIsLoaded] = useState('');
  19. const [text, setText] = useState(
  20. 'Expand your engineering team effectively with our staff augmentation service. Diligent helps to build dedicated teams tailored to the needs of your project to scale the capacity of your business.',
  21. );
  22. const [ico, setIco] = useState(
  23. `${api_url}/uploads/Group_492_1_0ab4463650.png`,
  24. );
  25. useEffect(() => {
  26. var vid = document.getElementById('sscreen');
  27. vid.playbackRate = 2;
  28. }, []);
  29. useEffect(async () => {
  30. axios
  31. .get(
  32. `${api_url}/api/homepage?populate[0]=services&populate[1]=services.heading&populate[2]=services.serviceHome.icon`,
  33. )
  34. .then(res => {
  35. setCntServicesHome(res.data.data.attributes);
  36. setIsLoaded(true);
  37. })
  38. .catch(err => {
  39. console.log(err);
  40. setIsLoaded(false);
  41. });
  42. if (hoverIndex > 0) {
  43. SetCircle(circle + 30);
  44. SetHex(hex + 30);
  45. SetTriangle(triangle + 30);
  46. }
  47. }, [hoverIndex]);
  48. // useEffect(() => {
  49. // if (change === true) {
  50. // const timer = setTimeout(() => SetChange(true), 1000);
  51. // return () => clearTimeout(timer);
  52. // }
  53. // }, [hoverIndex]);
  54. function handleHover(event) {
  55. if (change == true) {
  56. SetChange(false);
  57. SetHoverIndex(event.target.getAttribute('domIndex'));
  58. const timer = setTimeout(() => {
  59. SetChange(true);
  60. }, 100);
  61. return () => clearTimeout(timer);
  62. }
  63. }
  64. if (!isLoaded) {
  65. return (
  66. <div className="z-50 w-full h-screen bg-white dark:bg-dg-primary-1700 dark:text-white flex items-center justify-center text-3xl font-semibold">
  67. <video id="sscreen" width="540" height="540" autoPlay muted loop>
  68. <source src={Animation_Diligent} type="video/webm" />
  69. Loading...
  70. </video>
  71. </div>
  72. );
  73. }
  74. return (
  75. <section
  76. id="services"
  77. className="bg-white dark:bg-dg-primary-1700 flex flex-col justify-center items-center py-164p"
  78. >
  79. <Wrapper>
  80. <motion.div className="flex justify-center items-center w-full z-20 "
  81. initial={{ y:60, opacity: 0 }}
  82. whileInView={{ y:0, opacity: 1 }}
  83. transition={{ duration: 0.5, ease: 'easeOut' }}
  84. >
  85. <div className="flex flex-col justify-center items-left gap-8p text-left">
  86. {/* Our Services Heading */}
  87. <h6 className="subheading">
  88. {cntServicesHome.services.heading.subheading}
  89. </h6>
  90. <h1 className="heading">
  91. {cntServicesHome.services.heading.heading}
  92. </h1>
  93. {/* Our Services Links */}
  94. <div className="flex flex-col md:flex-row text-center align-center justify-center mt-16 relative">
  95. <div className="hidden h-[80%] w-[2px] bg-dg-primary-900 text-dg-primary-900 dark:text-white absolute top-4 bottom-12 left-[6]"></div>
  96. <ul className="flex flex-col text-left w-full lg:w-1/2 list-none z-10">
  97. {cntServicesHome.services.serviceHome.map((service, i) => (
  98. <li
  99. key={service.id}
  100. domIndex={service.id}
  101. className="group flex flex-row items-center w-fit px-4 mb-4 text-md dark:text-white font-semibold transition-all hover:shadow-md rounded-xl hover:bg-white dark:hover:bg-dg-primary-1600 dark:hover:border dark:hover:border-solid dark:hover:border-dg-primary-1500 p-2 hover:transition-all"
  102. onMouseEnter={e => {
  103. handleHover(e);
  104. setText(service.paragraph);
  105. setIco(api_url + service.icon.data.attributes.formats.thumbnail.url);
  106. }}
  107. >
  108. {i + 1 !== cntServicesHome.services.serviceHome.length && (
  109. <hr className="-z-10 absolute bg-dg-primary-900 rotate-90 w-12 mt-12 -ml-4" />
  110. )}
  111. <div className="hexagon transition-all group-hover:bg-dg-primary-900 group-hover:rotate-90 group-hover:transition-all"></div>
  112. <div
  113. className="min-w-max pl-2"
  114. >
  115. {service.heading}
  116. </div>
  117. </li>
  118. ))}
  119. </ul>
  120. <div
  121. id="services_content"
  122. className="hidden md:block w-full lg:w-1/2 ml-0 lg:ml-16 mt-8 flex flex-col items-center justify-center"
  123. >
  124. <div className="hidden lg:block absolute scale-75 md:scale-100 top-[-80px] right-[-100px]">
  125. <HoverServices circle={circle} triangle={triangle} hex={hex} />
  126. </div>
  127. <div
  128. key={cntServicesHome.services.serviceHome[0].id}
  129. domIndex={cntServicesHome.services.serviceHome[0].id}
  130. className="hidden md:flex w-full flex-col justify-center items-center"
  131. >
  132. <div className='w-[72px] min-h-[80px]'>
  133. <img src={ico} alt="Service's Icon" width={72} />
  134. </div>
  135. <p className="mt-3 text-sm dark:text-white">{text}</p>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </motion.div>
  141. </Wrapper>
  142. </section>
  143. );
  144. }