mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-04 20:05:50 +00:00
rm moment-timezone, use static date instead of countdown
This commit is contained in:
@@ -6,7 +6,6 @@ import { Link } from "@redocly/theme/components/Link/Link";
|
|||||||
import { ColorModeSwitcher } from "@redocly/theme/components/ColorModeSwitcher/ColorModeSwitcher";
|
import { ColorModeSwitcher } from "@redocly/theme/components/ColorModeSwitcher/ColorModeSwitcher";
|
||||||
import { Search } from "@redocly/theme/components/Search/Search";
|
import { Search } from "@redocly/theme/components/Search/Search";
|
||||||
import arrowUpRight from "../../../static/img/icons/arrow-up-right-custom.svg";
|
import arrowUpRight from "../../../static/img/icons/arrow-up-right-custom.svg";
|
||||||
import moment from "moment-timezone";
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
@@ -15,63 +14,25 @@ const alertBanner = {
|
|||||||
message: "APEX 2025",
|
message: "APEX 2025",
|
||||||
button: "REGISTER",
|
button: "REGISTER",
|
||||||
link: "https://www.xrpledgerapex.com/?utm_source=xrplwebsite&utm_medium=direct&utm_campaign=xrpl-event-ho-xrplapex-glb-2025-q1_xrplwebsite_ari_arp_bf_rsvp&utm_content=cta_btn_english_pencilbanner",
|
link: "https://www.xrpledgerapex.com/?utm_source=xrplwebsite&utm_medium=direct&utm_campaign=xrpl-event-ho-xrplapex-glb-2025-q1_xrplwebsite_ari_arp_bf_rsvp&utm_content=cta_btn_english_pencilbanner",
|
||||||
targetDate: "2025-06-11 08:00:00", // June 11, 2025 at 8AM Singapore time
|
date: "JUNE 10-12",
|
||||||
};
|
};
|
||||||
|
|
||||||
function useCountdown(targetDate: string) {
|
export function AlertBanner({ message, button, link, show, date }) {
|
||||||
const [timeLeft, setTimeLeft] = React.useState("");
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
const calculateTimeLeft = () => {
|
|
||||||
// Create target date in Singapore timezone (Asia/Singapore)
|
|
||||||
const target = moment.tz(targetDate, "YYYY-MM-DD HH:mm:ss", "Asia/Singapore");
|
|
||||||
const now = moment();
|
|
||||||
const diff = target.diff(now);
|
|
||||||
|
|
||||||
if (diff <= 0) {
|
|
||||||
setTimeLeft("EVENT STARTED");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const duration = moment.duration(diff);
|
|
||||||
const days = Math.floor(duration.asDays());
|
|
||||||
const hours = duration.hours();
|
|
||||||
const minutes = duration.minutes();
|
|
||||||
const seconds = duration.seconds();
|
|
||||||
|
|
||||||
const formattedTime = `${days.toString().padStart(2, '0')}:${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
|
||||||
setTimeLeft(`IN ${formattedTime}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Calculate immediately
|
|
||||||
calculateTimeLeft();
|
|
||||||
|
|
||||||
// Update every second
|
|
||||||
const interval = setInterval(calculateTimeLeft, 1000);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [targetDate]);
|
|
||||||
|
|
||||||
return timeLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AlertBanner({ message, button, link, show, targetDate }) {
|
|
||||||
const { useTranslate } = useThemeHooks();
|
const { useTranslate } = useThemeHooks();
|
||||||
const { translate } = useTranslate();
|
const { translate } = useTranslate();
|
||||||
const bannerRef = React.useRef(null);
|
const bannerRef = React.useRef(null);
|
||||||
const countdown = useCountdown(targetDate);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const banner = bannerRef.current;
|
const banner = bannerRef.current;
|
||||||
if (!banner) return;
|
if (!banner) return;
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
banner.classList.add('has-hover');
|
banner.classList.add("has-hover");
|
||||||
};
|
};
|
||||||
// Attach the event listener
|
// Attach the event listener
|
||||||
banner.addEventListener('mouseenter', handleMouseEnter);
|
banner.addEventListener("mouseenter", handleMouseEnter);
|
||||||
// Clean up the event listener on unmount
|
// Clean up the event listener on unmount
|
||||||
return () => {
|
return () => {
|
||||||
banner.removeEventListener('mouseenter', handleMouseEnter);
|
banner.removeEventListener("mouseenter", handleMouseEnter);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -87,11 +48,15 @@ export function AlertBanner({ message, button, link, show, targetDate }) {
|
|||||||
>
|
>
|
||||||
<div className="banner-event-details">
|
<div className="banner-event-details">
|
||||||
<div className="event-info">{translate(message)}</div>
|
<div className="event-info">{translate(message)}</div>
|
||||||
<div className="event-date">{countdown}</div>
|
<div className="event-date">{date}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="banner-button">
|
<div className="banner-button">
|
||||||
<div className="button-text">{translate(button)}</div>
|
<div className="button-text">{translate(button)}</div>
|
||||||
<img className="button-icon" src={arrowUpRight} alt="Get Tickets Icon" />
|
<img
|
||||||
|
className="button-icon"
|
||||||
|
src={arrowUpRight}
|
||||||
|
alt="Get Tickets Icon"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
@@ -131,7 +96,6 @@ export function Navbar(props) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
// Turns out jQuery is necessary for firing events on Bootstrap v4
|
// Turns out jQuery is necessary for firing events on Bootstrap v4
|
||||||
// dropdowns. These events set classes so that the search bar and other
|
// dropdowns. These events set classes so that the search bar and other
|
||||||
@@ -179,7 +143,7 @@ export function Navbar(props) {
|
|||||||
<NavItems>
|
<NavItems>
|
||||||
{navItems}
|
{navItems}
|
||||||
<div id="topnav-search" className="nav-item search">
|
<div id="topnav-search" className="nav-item search">
|
||||||
<Search className="topnav-search"/>
|
<Search className="topnav-search" />
|
||||||
</div>
|
</div>
|
||||||
<div id="topnav-language" className="nav-item">
|
<div id="topnav-language" className="nav-item">
|
||||||
<LanguagePicker
|
<LanguagePicker
|
||||||
|
|||||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -20,7 +20,6 @@
|
|||||||
"five-bells-condition": "^5.0.1",
|
"five-bells-condition": "^5.0.1",
|
||||||
"lottie-react": "^2.4.0",
|
"lottie-react": "^2.4.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"moment-timezone": "^0.6.0",
|
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-alert": "^7.0.3",
|
"react-alert": "^7.0.3",
|
||||||
@@ -5941,18 +5940,6 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/moment-timezone": {
|
|
||||||
"version": "0.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.6.0.tgz",
|
|
||||||
"integrity": "sha512-ldA5lRNm3iJCWZcBCab4pnNL3HSZYXVb/3TYr75/1WCTWYuTqYUb5f/S384pncYjJ88lbO8Z4uPDvmoluHJc8Q==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"moment": "^2.29.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mri": {
|
"node_modules/mri": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
"five-bells-condition": "^5.0.1",
|
"five-bells-condition": "^5.0.1",
|
||||||
"lottie-react": "^2.4.0",
|
"lottie-react": "^2.4.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"moment-timezone": "^0.6.0",
|
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-alert": "^7.0.3",
|
"react-alert": "^7.0.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user