Skip to content

Commit 6397cd3

Browse files
authored
Merge pull request #3744 from processing/eoy-donation-banner
EOY 2025 Donation Banner
2 parents c581fba + 8158c1d commit 6397cd3

File tree

17 files changed

+80
-7
lines changed

17 files changed

+80
-7
lines changed

client/modules/IDE/components/Banner.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { Trans } from 'react-i18next';
34
import { CrossIcon } from '../../../common/icons';
45

56
/**
@@ -23,12 +24,11 @@ import { CrossIcon } from '../../../common/icons';
2324

2425
const Banner = ({ onClose }) => {
2526
// URL can be updated depending on the opportunity or announcement.
26-
const bannerURL = 'https://openprocessing.org/curation/89576';
27+
const bannerURL = 'https://processingfoundation.org/donate';
28+
2729
const bannerCopy = (
2830
<>
29-
We’re accepting p5.js sketches for a special curation exploring mental
30-
health and the newest features in p5.js 2.0!{' '}
31-
<span style={{ fontWeight: 600 }}>Submit by July 20!</span>
31+
<Trans i18nKey="Banner.Copy" components={{ bold: <strong /> }} />
3232
</>
3333
);
3434

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
setPreferencesTab
2323
} from '../../actions/preferences';
2424
import { majorVersion, p5URL, useP5Version } from '../../hooks/useP5Version';
25-
import p5SoundURL from '../../../../../common/p5URLs';
25+
import { p5SoundURL } from '../../../../../common/p5URLs';
2626
import VersionPicker from '../VersionPicker';
2727
import { updateFileContent } from '../../actions/files';
2828
import { CmControllerContext } from '../../pages/IDEView';

client/modules/IDE/pages/IDEView.jsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ import useIsMobile from '../hooks/useIsMobile';
2929
import Banner from '../components/Banner';
3030
import { P5VersionProvider } from '../hooks/useP5Version';
3131

32+
const BANNER_DISMISS_KEY = 'bannerLastDismissedAt';
33+
const BANNER_COOLDOWN_MINUTES = 30;
34+
35+
function minutesSince(timestamp) {
36+
return (Date.now() - timestamp) / (1000 * 60);
37+
}
38+
3239
function getTitle(project) {
3340
const { id } = project;
3441
return id ? `p5.js Web Editor | ${project.name}` : 'p5.js Web Editor';
@@ -106,7 +113,7 @@ const IDEView = () => {
106113
const [sidebarSize, setSidebarSize] = useState(160);
107114
const [isOverlayVisible, setIsOverlayVisible] = useState(false);
108115
const [MaxSize, setMaxSize] = useState(window.innerWidth);
109-
const [displayBanner, setDisplayBanner] = useState(false);
116+
const [displayBanner, setDisplayBanner] = useState(true);
110117

111118
const cmRef = useRef({});
112119

@@ -151,6 +158,7 @@ const IDEView = () => {
151158
}
152159
};
153160
}, [shouldAutosave, dispatch]);
161+
154162
useEffect(() => {
155163
const updateInnerWidth = (e) => {
156164
setMaxSize(e.target.innerWidth);
@@ -163,6 +171,29 @@ const IDEView = () => {
163171
};
164172
}, [setMaxSize]);
165173

174+
// checks how long banner has been closed for to hide banner
175+
useEffect(() => {
176+
const stored = window.localStorage.getItem(BANNER_DISMISS_KEY);
177+
const lastClosedAt = stored ? Number(stored) : null;
178+
179+
if (!lastClosedAt) {
180+
setDisplayBanner(true);
181+
return;
182+
}
183+
184+
if (minutesSince(lastClosedAt) >= BANNER_COOLDOWN_MINUTES) {
185+
setDisplayBanner(true);
186+
} else {
187+
setDisplayBanner(false);
188+
}
189+
}, []);
190+
191+
const handleBannerClose = () => {
192+
setDisplayBanner(false);
193+
194+
window.localStorage.setItem(BANNER_DISMISS_KEY, String(Date.now()));
195+
};
196+
166197
const consoleCollapsedSize = 29;
167198
const currentConsoleSize = ide.consoleIsExpanded
168199
? consoleSize
@@ -173,7 +204,7 @@ const IDEView = () => {
173204
<Helmet>
174205
<title>{getTitle(project)}</title>
175206
</Helmet>
176-
{displayBanner && <Banner onClose={() => setDisplayBanner(false)} />}
207+
{displayBanner && <Banner onClose={handleBannerClose} />}
177208
<IDEKeyHandlers getContent={() => cmRef.current?.getContent()} />
178209
<WarnIfUnsavedChanges />
179210
<Toast />

translations/locales/en-US/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
"LogOut": "Log Out"
5050
}
5151
},
52+
"Banner": {
53+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
54+
},
5255
"CodemirrorFindAndReplace": {
5356
"ToggleReplace": "Toggle Replace",
5457
"Find": "Find",

translations/locales/es-419/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"LogOut": "Cerrar sesión"
4848
}
4949
},
50+
"Banner": {
51+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
52+
},
5053
"CodemirrorFindAndReplace": {
5154
"ToggleReplace": "Alternar reemplazar",
5255
"Find": "Buscar",

translations/locales/fr-CA/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
"LogOut": "Se déconnecter"
4949
}
5050
},
51+
"Banner": {
52+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
53+
},
5154
"CodemirrorFindAndReplace": {
5255
"ToggleReplace": "Activer/désactiver le remplacement",
5356
"Find": "Rechercher",

translations/locales/hi/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"LogOut": "लॉग आउट"
4848
}
4949
},
50+
"Banner": {
51+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
52+
},
5053
"CodemirrorFindAndReplace": {
5154
"ToggleReplace": "टॉगल बदली करें",
5255
"Find": "खोज",

translations/locales/it/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"LogOut": "Esci"
4848
}
4949
},
50+
"Banner": {
51+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
52+
},
5053
"CodemirrorFindAndReplace": {
5154
"ToggleReplace": "Attiva/disattiva Sostituzione",
5255
"Find": "Cerca",

translations/locales/ja/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"LogOut": "ログアウト"
4848
}
4949
},
50+
"Banner": {
51+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
52+
},
5053
"CodemirrorFindAndReplace": {
5154
"ToggleReplace": "置換の切り替え",
5255
"Find": "検索",

translations/locales/ko/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
"LogOut": "로그아웃"
4949
}
5050
},
51+
"Banner": {
52+
"Copy": "<bold>Donate Today!</bold> Support p5.js and the Processing Foundation."
53+
},
5154
"LoginForm": {
5255
"UsernameOrEmail": "이메일 또는 아이디",
5356
"UsernameOrEmailARIA": "이메일 또는 아이디",

0 commit comments

Comments
 (0)