diff --git a/src/components/notification/Notification.js b/src/components/notification/Notification.js index a21cba31..732bd7ec 100644 --- a/src/components/notification/Notification.js +++ b/src/components/notification/Notification.js @@ -21,7 +21,7 @@ if (isBrowser) { // Example Overrides: ?notification-override=leaderboard-change-flat // Example Overrides: ?notification-override=leaderboard-change-down // Example Overrides: ?notification-override=leaderboard-change-up -const Notification = ({ slot, user }) => { +const Notification = ({ slot, user, onOpenLeaderboard }) => { const [show, setShow] = useState(true) const [height, setHeight] = useState(0) @@ -51,6 +51,21 @@ const Notification = ({ slot, user }) => { setHeight(0) } + // See if we have any actions + if (event.data.action) { + switch (event.data.action) { + case 'leaderboard-open': + if (onOpenLeaderboard) { + onOpenLeaderboard() + } + break + + // Default do nothing + default: + break + } + } + // Log or use the received message // console.log('Received message from child:', event.data, event.origin) } @@ -83,8 +98,12 @@ Notification.propTypes = { user: PropTypes.shape({ userId: PropTypes.string, }).isRequired, + + onOpenLeaderboard: PropTypes.func, } -Notification.defaultProps = {} +Notification.defaultProps = { + onOpenLeaderboard: null, +} export default Notification diff --git a/src/pages/index.js b/src/pages/index.js index 44e8175d..eee20356 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -766,6 +766,10 @@ const Index = ({ data: fallbackData, userAgent }) => { setShowLeaderboardFunc(false) } + const openLeaderboard = () => { + setShowLeaderboardFunc(true) + } + return ( <> @@ -864,9 +868,7 @@ const Index = ({ data: fallbackData, userAgent }) => { backgroundColor: 'white', boxShadow: '0px 2px 4px grey', }} - onClick={() => - setShowLeaderboardFunc(!showLeaderboardFunc) - } + onClick={openLeaderboard} >
{ * that appear via the UserImpact component. */}
- + {/*