Skip to content

Commit

Permalink
alternative widget option
Browse files Browse the repository at this point in the history
  • Loading branch information
raclim committed Nov 29, 2024
1 parent e1aa530 commit 28fb954
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 57 deletions.
68 changes: 47 additions & 21 deletions client/modules/IDE/pages/IDEView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,11 @@ const IDEView = () => {
};

const Banner = () => {
// temporary banner to display funding opportunities
const textObj = {
copy:
'Help us raise $20K to continue our mission of building equitable and accessible creative coding tools!',
url: 'https://p5js.org/donate/'
};

const [isBannerVisible, setIsBannerVisible] = useState(true);

// eslint-disable-next-line consistent-return
useEffect(() => {
if (!isBannerVisible) return;

const script = document.createElement('script');
script.type = 'text/javascript';
script.defer = true;
Expand All @@ -148,6 +142,7 @@ const IDEView = () => {

document.body.appendChild(script);

// eslint-disable-next-line consistent-return
return () => {
const existingScript = document.getElementById(
'donorbox-popup-button-installer'
Expand All @@ -156,7 +151,7 @@ const IDEView = () => {
existingScript.remove();
}
};
}, []);
}, [isBannerVisible]);

const handleCloseBanner = () => {
setIsBannerVisible(false);
Expand All @@ -174,18 +169,49 @@ const IDEView = () => {
}
};

return (
isBannerVisible && (
<div className="banner">
<a href={textObj.url} target="_blank" rel="noopener noreferrer">
{textObj.copy}
</a>
<button className="banner-close-button" onClick={handleCloseBanner}>
<CrossIcon />
</button>
</div>
)
);
return isBannerVisible ? (
<div
style={{
position: 'fixed',
top: '0',
right: '23%',
zIndex: 10000,
display: 'flex',
alignItems: 'center',
gap: '10px',
padding: '8px 18px',
borderRadius: '5px'
}}
>
<button
style={{
background: 'transparent',
border: 'none',
color: 'white',
fontSize: '16px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
fontFamily: 'Verdana, sans-serif',
padding: '8px 22px 8px 18px',
borderRadius: '0px 0px 5px 5px',
gap: '8px',
width: 'fit-content',
lineHeight: '24px',
position: 'fixed',
top: '61%',
left: '20px',
transform: 'translate(-50%, -50%) rotate(-90deg)',
zIndex: 9999,
overflow: 'hidden'
}}
onClick={handleCloseBanner}
aria-label="Close Banner"
>
<CrossIcon />
</button>
</div>
) : null;
};

useEffect(() => {
Expand Down
36 changes: 0 additions & 36 deletions client/styles/layout/_ide.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,6 @@
height: 100%;
}

.banner {
width: 100%;
min-height: 2.2rem;
text-align: center;
padding: 0.5rem;
font-weight: bold;
border-bottom: 1px dashed #A6A6A6;
color: #FFF;

// @include themify() {
// background-color: getThemifyVariable('logo-color');
// & a {
// color: getThemifyVariable('logo-background-color');
// }
// }

@media (max-width: 770px) {
min-height: 3.3rem;
}
}

.banner-close-button {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 20px;
width:20px;
float: right;

// & path {
// @include themify() {
// fill: getThemifyVariable('logo-background-color');
// }
// }
}

@media print {
.sidebar {
Expand Down

0 comments on commit 28fb954

Please sign in to comment.