Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/layouts/TopBarNotify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
return warningBarOpen !== 'false';
});

const isBannerClickable = sm && Boolean(currentCampaign?.buttonAction);

useEffect(() => {
if (!currentCampaign) return;

Expand Down Expand Up @@ -113,6 +115,11 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
}
};

const handleBannerClick = () => {
if (!isBannerClickable) return;
handleButtonAction();
};

// Note: hide warnings when mobile menu is open
if (mobileDrawerOpen) return null;

Expand All @@ -137,7 +144,9 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
justifyContent: 'center',
alignItems: 'center',
width: '100%',
cursor: isBannerClickable ? 'pointer' : 'default',
}}
onClick={handleBannerClick}
variant="dense"
>
<Box sx={{ padding: md ? '20px 10px' : '', paddingRight: 0 }}>
Expand All @@ -155,7 +164,7 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
''
)}

{currentCampaign.learnMoreLink && md ? (
{md && currentCampaign.learnMoreLink && !isBannerClickable ? (
typeof currentCampaign.learnMoreLink === 'string' ? (
<Link
sx={{ color: 'white', textDecoration: 'underline', paddingLeft: 2 }}
Expand Down Expand Up @@ -189,7 +198,7 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
</Box>

<Box>
{!md && currentCampaign.buttonText && currentCampaign.buttonAction ? (
{!sm && currentCampaign.buttonText && currentCampaign.buttonAction ? (
<Button
size="small"
onClick={handleButtonAction}
Expand All @@ -207,7 +216,10 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
</Box>
<Button
sx={{ color: 'white', paddingRight: 0 }}
onClick={handleClose}
onClick={(event) => {
event.stopPropagation();
handleClose();
}}
startIcon={<CloseIcon />}
/>
</Toolbar>
Expand Down
Loading