@@ -27,6 +27,7 @@ import {
27
27
} from '../components/Editor/MobileEditor' ;
28
28
import IDEOverlays from '../components/IDEOverlays' ;
29
29
import useIsMobile from '../hooks/useIsMobile' ;
30
+ import { CrossIcon } from '../../../common/icons' ;
30
31
31
32
function getTitle ( project ) {
32
33
const { id } = project ;
@@ -87,37 +88,6 @@ function WarnIfUnsavedChanges() {
87
88
) ;
88
89
}
89
90
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
-
121
91
export const CmControllerContext = React . createContext ( { } ) ;
122
92
123
93
const IDEView = ( ) => {
@@ -135,6 +105,7 @@ const IDEView = () => {
135
105
const [ sidebarSize , setSidebarSize ] = useState ( 160 ) ;
136
106
const [ isOverlayVisible , setIsOverlayVisible ] = useState ( false ) ;
137
107
const [ MaxSize , setMaxSize ] = useState ( window . innerWidth ) ;
108
+ const [ displayBanner , setDisplayBanner ] = useState ( true ) ;
138
109
139
110
const cmRef = useRef ( { } ) ;
140
111
@@ -145,6 +116,45 @@ const IDEView = () => {
145
116
dispatch ( updateFileContent ( file . id , file . content ) ) ;
146
117
} ;
147
118
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
+
148
158
useEffect ( ( ) => {
149
159
dispatch ( clearPersistedState ( ) ) ;
150
160
} , [ dispatch ] ) ;
@@ -201,7 +211,7 @@ const IDEView = () => {
201
211
< Helmet >
202
212
< title > { getTitle ( project ) } </ title >
203
213
</ Helmet >
204
- < Banner />
214
+ { displayBanner && < Banner /> }
205
215
< IDEKeyHandlers getContent = { ( ) => cmRef . current ?. getContent ( ) } />
206
216
< WarnIfUnsavedChanges />
207
217
< Toast />
0 commit comments