From b59c9267c61b6797d5e19c106e20e5706271a2cf Mon Sep 17 00:00:00 2001 From: Spicer Matthews Date: Mon, 8 Apr 2024 14:18:14 -0700 Subject: [PATCH] Deploying new leaderboard UI. --- src/components/Leaderboard.js | 103 ++++++++++++++++++++++++++++++++++ src/pages/index.js | 55 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 src/components/Leaderboard.js diff --git a/src/components/Leaderboard.js b/src/components/Leaderboard.js new file mode 100644 index 00000000..24a662a8 --- /dev/null +++ b/src/components/Leaderboard.js @@ -0,0 +1,103 @@ +import React, { useState, useEffect } from 'react' +import gtag from 'ga-gtag' +import PropTypes from 'prop-types' +import Modal from '@material-ui/core/Modal' +import IconButton from '@material-ui/core/IconButton' +import CloseIcon from '@material-ui/icons/Close' + +const iframeUrl = + 'https://snowy-stream-wljibw2liswn.vapor-farm-g1.com/newtab/leaderboard?user_id=' + +const Leaderboard = ({ user, openWidgetFunc, onCloseFunc }) => { + const [openWidget, setOpenWidget] = useState(false) + + const onOpen = () => { + setOpenWidget(true) + gtag('event', 'leaderboard_open') + } + + const onClose = () => { + setOpenWidget(false) + onCloseFunc() + gtag('event', 'leaderboard_close') + } + + // If you need to call the function automatically when the parent says so: + useEffect(() => { + if (openWidgetFunc) { + onOpen() + } + }, [openWidgetFunc]) + + if (!user) { + return null + } + + return ( + <> + {iframeUrl && ( + +
+ + + + +
+