Skip to content

Commit

Permalink
Merge pull request #1019 from the-hideout/donation-banner
Browse files Browse the repository at this point in the history
Enable banner asking for donations
  • Loading branch information
Razzmatazzz authored Dec 12, 2024
2 parents 99c1291 + 30a4aaa commit 196a857
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/components/menu/alert-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const alertConfig = {
// set this bool if the site alert should be enabled or not
alertEnabled: false,
alertEnabled: true,

// if alert should show on page load even if the user has closed it
alwaysShow: true,

// valid alert colors
alertColors: {
Expand All @@ -15,7 +18,8 @@ const alertConfig = {

// The text to display in the alert banner
//text: '🌟 Flea market scanners are currently being leveled, and data for the {{patchVersion}} patch should be appearing soon! 🌟 If you enjoy using tarkov.dev, please consider donating to help keep it running. All donations go directly towards server costs and operational expenses. This banner will only be up for a week. Thank you! ❤️',
text: '🌟 Flea market scanners have been leveled, and flea market prices are being updated for patch {{patchVersion}}! 🌟 If you enjoy using tarkov.dev, please consider donating to help keep it running. All donations go directly towards server costs and operational expenses. This banner will only be up for a week. Thank you! ❤️',
//text: '🌟 Flea market scanners have been leveled, and flea market prices are being updated for patch {{patchVersion}}! 🌟 If you enjoy using tarkov.dev, please consider donating to help keep it running. All donations go directly towards server costs and operational expenses. This banner will only be up for a week. Thank you! ❤️',
text: 'We want to keep Tarkov.dev and its API free for all and without ads, but we\'ve been struggling with increased expenses. If you enjoy using tarkov.dev, please consider donating to help keep it running. All donations go directly towards server costs and operational expenses. Thank you! ❤️',
textVariables: {patchVersion: '0.15.0'},
linkEnabled: true,
linkText: 'Donate',
Expand All @@ -24,7 +28,7 @@ const alertConfig = {
// when a banner with a specific key is hidden, it never shows for that user again
// (unless they clear their browser cache)
// use a different key to force new banners to display again
bannerKey: 'alertBanner-0.15.0-scanning'
bannerKey: 'alertBanner-0.15.0-funding'
}

export default alertConfig
13 changes: 8 additions & 5 deletions src/components/menu/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useMemo, useState } from 'react';
import useStateWithLocalStorage from '../../hooks/useStateWithLocalStorage.jsx';
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -52,7 +52,8 @@ const Menu = () => {
setIsOpen(!isOpen);
};*/
const { t } = useTranslation();
const [open, setOpen] = useStateWithLocalStorage(alertConfig.bannerKey, true);
const [alertOpen, setAlertOpen] = useStateWithLocalStorage(alertConfig.bannerKey, true);
const [alertStateOpen, setAlertStateOpen] = useState(alertOpen || alertConfig.alwaysShow);

const uniqueMaps = useMapImagesSortedArray();
for (const map of uniqueMaps) {
Expand All @@ -74,9 +75,9 @@ const Menu = () => {
return (
<>
{/* ALERT BANNER SECTION */}
{alertConfig?.alertEnabled && alertConfig.alertEnabled === true && (
{alertConfig?.alertEnabled === true && (
<Box>
<Collapse in={open}>
<Collapse in={alertStateOpen}>
<Alert
severity={alertConfig.alertLevel}
variant='filled'
Expand All @@ -87,7 +88,8 @@ const Menu = () => {
color="inherit"
size="small"
onClick={() => {
setOpen(false);
setAlertOpen(false);
setAlertStateOpen(false);
}}
>
<Icon path={mdiClose} size={0.8} className="icon-with-text" />
Expand All @@ -102,6 +104,7 @@ const Menu = () => {
<Link
to={alertConfig.link}
style={{ color: 'inherit', textDecoration: 'underline' }}
target="_blank"
>
{t(alertConfig.linkText)}
</Link>
Expand Down

0 comments on commit 196a857

Please sign in to comment.