@@ -10,6 +10,7 @@ import PreviewFrame from '../components/PreviewFrame';
1010import Console from '../components/Console' ;
1111import Toast from '../components/Toast' ;
1212import { updateFileContent } from '../actions/files' ;
13+ import { CrossIcon } from '../../../common/icons' ;
1314
1415import {
1516 autosaveProject ,
@@ -114,6 +115,79 @@ const IDEView = () => {
114115 dispatch ( updateFileContent ( file . id , file . content ) ) ;
115116 } ;
116117
118+ const Banner = ( ) => {
119+ // temporary banner to display funding opportunities
120+ const textObj = {
121+ copy :
122+ 'Help us raise $20K to continue our mission of building equitable and accessible creative coding tools!' ,
123+ url : 'https://p5js.org/donate/'
124+ } ;
125+
126+ const [ isBannerVisible , setIsBannerVisible ] = useState ( true ) ;
127+
128+ // eslint-disable-next-line consistent-return
129+ useEffect ( ( ) => {
130+ const script = document . createElement ( 'script' ) ;
131+ script . type = 'text/javascript' ;
132+ script . defer = true ;
133+ script . src = 'https://donorbox.org/install-popup-button.js' ;
134+ script . id = 'donorbox-popup-button-installer' ;
135+ script . setAttribute (
136+ 'data-href' ,
137+ 'https://donorbox.org/building-together?default_interval=o'
138+ ) ;
139+ script . setAttribute (
140+ 'data-style' ,
141+ // eslint-disable-next-line max-len
142+ 'background: rgb(85, 1, 164); color: rgb(255, 255, 255); text-decoration: none; font-family: Verdana, sans-serif; display: flex; font-size: 16px; padding: 8px 22px 8px 18px; border-radius: 0px 0px 5px 5px; gap: 8px; width: fit-content; line-height: 24px; position: fixed; top: 70%; transform-origin: center center; z-index: 9999; overflow: hidden; left: 20px; transform: translate(-50%, -50%) rotate(-90deg);'
143+ ) ;
144+ script . setAttribute (
145+ 'data-img-src' ,
146+ 'https://donorbox.org/images/white_logo.svg'
147+ ) ;
148+
149+ document . body . appendChild ( script ) ;
150+
151+ return ( ) => {
152+ const existingScript = document . getElementById (
153+ 'donorbox-popup-button-installer'
154+ ) ;
155+ if ( existingScript ) {
156+ existingScript . remove ( ) ;
157+ }
158+ } ;
159+ } , [ ] ) ;
160+
161+ const handleCloseBanner = ( ) => {
162+ setIsBannerVisible ( false ) ;
163+
164+ const existingScript = document . getElementById (
165+ 'donorbox-popup-button-installer'
166+ ) ;
167+ if ( existingScript ) {
168+ existingScript . remove ( ) ;
169+ }
170+
171+ const popupButton = document . querySelector ( '.dbox-donation-button' ) ;
172+ if ( popupButton ) {
173+ popupButton . remove ( ) ;
174+ }
175+ } ;
176+
177+ return (
178+ isBannerVisible && (
179+ < div className = "banner" >
180+ < a href = { textObj . url } target = "_blank" rel = "noopener noreferrer" >
181+ { textObj . copy }
182+ </ a >
183+ < button className = "banner-close-button" onClick = { handleCloseBanner } >
184+ < CrossIcon />
185+ </ button >
186+ </ div >
187+ )
188+ ) ;
189+ } ;
190+
117191 useEffect ( ( ) => {
118192 dispatch ( clearPersistedState ( ) ) ;
119193 } , [ dispatch ] ) ;
@@ -170,6 +244,7 @@ const IDEView = () => {
170244 < Helmet >
171245 < title > { getTitle ( project ) } </ title >
172246 </ Helmet >
247+ < Banner />
173248 < IDEKeyHandlers getContent = { ( ) => cmRef . current ?. getContent ( ) } />
174249 < WarnIfUnsavedChanges />
175250 < Toast />
0 commit comments