Skip to content

Commit f8e1235

Browse files
authored
Merge pull request #3129 from Aseem22/aseem22/issue#3126
add button to remove banner
2 parents ae8f517 + 173aeba commit f8e1235

File tree

2 files changed

+52
-32
lines changed

2 files changed

+52
-32
lines changed

client/modules/IDE/pages/IDEView.jsx

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
} from '../components/Editor/MobileEditor';
2828
import IDEOverlays from '../components/IDEOverlays';
2929
import useIsMobile from '../hooks/useIsMobile';
30+
import { CrossIcon } from '../../../common/icons';
3031

3132
function 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-
12191
export const CmControllerContext = React.createContext({});
12292

12393
const 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 />

client/styles/layout/_ide.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
}
3030
}
3131

32+
.banner-close-button{
33+
display: flex;
34+
flex-direction: column;
35+
align-items: center;
36+
justify-content: center;
37+
height: 20px;
38+
width:20px;
39+
float: right;
40+
}
41+
3242
.sidebar {
3343
width: 100%;
3444
height: 100%;

0 commit comments

Comments
 (0)