main-menu.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import { Tooltip } from "@mui/material";
  2. import { useEffect, useRef, useState } from "react";
  3. const contactInfo = [
  4. {
  5. title: "Discord",
  6. icon: "icon-icon-17",
  7. link: "https://discord.gg/wyshSVuvxC",
  8. },
  9. {
  10. title: "x.com",
  11. icon: "icon-tuite3",
  12. link: "https://x.com/safeline_waf",
  13. },
  14. {
  15. title: "Telegram",
  16. icon: "icon-telegram1",
  17. link: "https://t.me/safeline_waf",
  18. },
  19. ];
  20. export default function ManiMenu() {
  21. function highlightLinks() {
  22. const sections = document.querySelectorAll(".page-scroll");
  23. const scrollPos =
  24. window.pageYOffset ||
  25. document.documentElement.scrollTop ||
  26. document.body.scrollTop;
  27. sections.forEach((currLink) => {
  28. const val = currLink.getAttribute("href").slice(1);
  29. if (val[0] !== "#") {
  30. return;
  31. }
  32. const refElement = document.querySelector(val);
  33. if (!refElement) {
  34. return;
  35. }
  36. const scrollTopMinus = scrollPos + 73;
  37. if (
  38. refElement.offsetTop <= scrollTopMinus &&
  39. refElement.offsetTop + refElement.offsetHeight > scrollTopMinus
  40. ) {
  41. setActiveMenuLink(val);
  42. }
  43. });
  44. }
  45. useEffect(() => {
  46. window.addEventListener("scroll", highlightLinks);
  47. return () => {
  48. window.removeEventListener("scroll", highlightLinks);
  49. };
  50. }, []);
  51. const [isMenuActive, setMenuActive] = useState(false);
  52. const menuLinksEl = useRef(null);
  53. function inactivateMenu() {
  54. setMenuActive(false);
  55. if (menuLinksEl.current) {
  56. menuLinksEl.current.classList.remove("show");
  57. }
  58. }
  59. return (
  60. <>
  61. <button
  62. className={`navbar-toggler ${isMenuActive ? "active" : ""}`}
  63. type="button"
  64. data-bs-toggle="collapse"
  65. data-bs-target="#navbarSupportedContent"
  66. aria-cpontrols="navbarSupportedContent"
  67. aria-expanded="false"
  68. aria-label="Toggle navigation"
  69. onClick={() => setMenuActive(!isMenuActive)}
  70. >
  71. <span className="toggler-icon"></span>
  72. <span className="toggler-icon"></span>
  73. <span className="toggler-icon"></span>
  74. </button>
  75. <div
  76. className="collapse navbar-collapse sub-menu-bar"
  77. ref={menuLinksEl}
  78. id="navbarSupportedContent"
  79. >
  80. <div className="ms-auto">
  81. <ul id="nav" className="navbar-nav ms-auto">
  82. <li className="nav-item">
  83. <a href="https://docs.waf.chaitin.com/" target="_blank">
  84. Docs
  85. </a>
  86. </li>
  87. <li
  88. className="nav-item nav-item_tooltip"
  89. style={{ position: "relative" }}
  90. >
  91. <a style={{ color: "rgba(0,0,0,0.2)" }}>Pricing</a>
  92. <div className="nav-btn_tooltip">Comming soon...</div>
  93. </li>
  94. <li
  95. className="nav-item"
  96. style={{ display: "flex", marginLeft: "17px",marginRight: '2px', }}
  97. >
  98. {contactInfo.map((i) => (
  99. <a
  100. key={i.icon}
  101. target="_blank"
  102. className="nav-item_icon"
  103. href={i.link}
  104. style={{ padding: "4px" }}
  105. >
  106. <Tooltip title={i.title}>
  107. <svg
  108. className="icon_svg"
  109. style={{
  110. width: "18px",
  111. height: "18px",
  112. marginRight: "4px",
  113. }}
  114. >
  115. <use xlinkHref={"#" + i.icon} />
  116. </svg>
  117. </Tooltip>
  118. </a>
  119. ))}
  120. </li>
  121. <li className="nav-item">
  122. <a
  123. style={{ paddingLeft: 0 }}
  124. className="nav-item_icon"
  125. href="https://github.com/chaitin/SafeLine"
  126. target="_blank"
  127. >
  128. <svg
  129. className="icon_svg"
  130. style={{ width: "20px", height: "20px" }}
  131. >
  132. <use xlinkHref="#icon-github-fill" />
  133. </svg>
  134. GitHub 10k+
  135. <svg
  136. className="icon_svg"
  137. style={{ width: "16px", height: "16px", marginLeft: "8px" }}
  138. >
  139. <use xlinkHref="#icon-xingxing1" />
  140. </svg>
  141. </a>
  142. </li>
  143. <li className="nav-item nav-item__demo">
  144. <a
  145. href={"https://demo.waf.chaitin.com:9443/"}
  146. className="main-btn btn-hover"
  147. style={{ color: "#fff" }}
  148. target="_blank"
  149. >
  150. Demo
  151. </a>
  152. </li>
  153. </ul>
  154. </div>
  155. </div>
  156. </>
  157. );
  158. }