@@ -27,6 +27,7 @@ import {
2727} from '../components/Editor/MobileEditor' ;
2828import IDEOverlays from '../components/IDEOverlays' ;
2929import useIsMobile from '../hooks/useIsMobile' ;
30+ import { CrossIcon } from '../../../common/icons' ;
3031
3132function getTitle ( project ) {
3233 const { id } = project ;
@@ -87,37 +88,6 @@ function WarnIfUnsavedChanges() {
8788 ) ;
8889}
8990
90- function Banner ( ) {
91- // temporary banner to display funding opportunities
92- const [ textObj , setTextObj ] = useState ( { } ) ;
93-
94- useEffect ( ( ) => {
95- const grant1 = {
96- copy :
97- 'Learn to make art with AI with the Social Software High School Summer Institute. Apply by June 1!' ,
98- url : 'https://summer.ucla.edu/program/social-software-summer-institute/'
99- } ;
100-
101- const grant2 = {
102- copy :
103- 'Join us in contributing to p5.js——receive a $10,000 opportunity to grow within the contributor community!' ,
104- url : 'https://processingfoundation.org/grants'
105- } ;
106-
107- const allMessages = [ grant1 , grant2 ] ;
108- const randomIndex = Math . floor ( Math . random ( ) * allMessages . length ) ;
109- const randomMessage = allMessages [ randomIndex ] ;
110-
111- setTextObj ( randomMessage ) ;
112- } , [ ] ) ;
113-
114- return (
115- < div className = "banner" >
116- < a href = { textObj . url } > { textObj . copy } </ a >
117- </ div >
118- ) ;
119- }
120-
12191export const CmControllerContext = React . createContext ( { } ) ;
12292
12393const IDEView = ( ) => {
@@ -135,6 +105,7 @@ const IDEView = () => {
135105 const [ sidebarSize , setSidebarSize ] = useState ( 160 ) ;
136106 const [ isOverlayVisible , setIsOverlayVisible ] = useState ( false ) ;
137107 const [ MaxSize , setMaxSize ] = useState ( window . innerWidth ) ;
108+ const [ displayBanner , setDisplayBanner ] = useState ( true ) ;
138109
139110 const cmRef = useRef ( { } ) ;
140111
@@ -145,6 +116,45 @@ const IDEView = () => {
145116 dispatch ( updateFileContent ( file . id , file . content ) ) ;
146117 } ;
147118
119+ const Banner = ( ) => {
120+ // temporary banner to display funding opportunities
121+ const [ textObj , setTextObj ] = useState ( { } ) ;
122+
123+ useEffect ( ( ) => {
124+ const grant1 = {
125+ copy :
126+ 'Learn to make art with AI with the Social Software High School Summer Institute. Apply by June 1!' ,
127+ url : 'https://summer.ucla.edu/program/social-software-summer-institute/'
128+ } ;
129+
130+ const grant2 = {
131+ copy :
132+ 'Join us in contributing to p5.js——receive a $10,000 opportunity to grow within the contributor community!' ,
133+ url : 'https://processingfoundation.org/grants'
134+ } ;
135+
136+ const allMessages = [ grant1 , grant2 ] ;
137+ const randomIndex = Math . floor ( Math . random ( ) * allMessages . length ) ;
138+ const randomMessage = allMessages [ randomIndex ] ;
139+
140+ setTextObj ( randomMessage ) ;
141+ } , [ ] ) ;
142+
143+ return (
144+ < div className = "banner" >
145+ < a href = { textObj . url } > { textObj . copy } </ a >
146+ < button
147+ className = "banner-close-button"
148+ onClick = { ( ) => {
149+ setDisplayBanner ( ! displayBanner ) ;
150+ } }
151+ >
152+ < CrossIcon />
153+ </ button >
154+ </ div >
155+ ) ;
156+ } ;
157+
148158 useEffect ( ( ) => {
149159 dispatch ( clearPersistedState ( ) ) ;
150160 } , [ dispatch ] ) ;
@@ -201,7 +211,7 @@ const IDEView = () => {
201211 < Helmet >
202212 < title > { getTitle ( project ) } </ title >
203213 </ Helmet >
204- < Banner />
214+ { displayBanner && < Banner /> }
205215 < IDEKeyHandlers getContent = { ( ) => cmRef . current ?. getContent ( ) } />
206216 < WarnIfUnsavedChanges />
207217 < Toast />
0 commit comments