parent
504ee8cf5e
commit
9b73d60c5d
6 changed files with 50 additions and 97 deletions
@ -1,57 +0,0 @@ |
||||
--- |
||||
import type { GAEventType } from '../Analytics/analytics'; |
||||
import Icon from '../AstroIcon.astro'; |
||||
|
||||
export type SponsorType = { |
||||
url: string; |
||||
title: string; |
||||
imageUrl: string; |
||||
description: string; |
||||
event: GAEventType; |
||||
}; |
||||
|
||||
export interface Props { |
||||
sponsor: SponsorType; |
||||
} |
||||
|
||||
const { |
||||
sponsor: { title, url, description, imageUrl, event }, |
||||
} = Astro.props; |
||||
--- |
||||
|
||||
<script src='./sponsor.js'></script> |
||||
|
||||
<a |
||||
href={url} |
||||
id='sponsor-ad' |
||||
target='_blank' |
||||
rel='noopener sponsored nofollow' |
||||
ga-category={event?.category} |
||||
ga-action={event?.action} |
||||
ga-label={event?.label} |
||||
class='fixed bottom-[15px] right-[15px] outline-transparent z-50 bg-white max-w-[350px] shadow-lg outline-0 hidden' |
||||
> |
||||
<button |
||||
class='absolute top-1.5 right-1.5 text-gray-300 hover:text-gray-800' |
||||
aria-label='Close' |
||||
close-sponsor |
||||
> |
||||
<Icon icon='close' class='h-4' /> |
||||
</button> |
||||
<img src={imageUrl} class='h-[150px] lg:h-[169px]' alt='Sponsor Banner' /> |
||||
<span class='text-sm flex flex-col justify-between'> |
||||
<span class='p-[10px]'> |
||||
<span class='font-semibold mb-0.5 block'>{title}</span> |
||||
<span class='text-gray-500 block'>{description}</span> |
||||
</span> |
||||
<span class='sponsor-footer'>Partner Content</span> |
||||
</span> |
||||
</a> |
||||
|
||||
<script> |
||||
document.querySelector('[close-sponsor]')?.addEventListener('click', (e) => { |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
document.getElementById('sponsor-ad')?.classList.add('hidden'); |
||||
}); |
||||
</script> |
@ -1,22 +0,0 @@ |
||||
import { sponsorHidden } from '../../stores/page'; |
||||
|
||||
function showHideSponsor(shouldHide) { |
||||
const ad = document.querySelector('#sponsor-ad'); |
||||
if (!ad) { |
||||
return; |
||||
} |
||||
|
||||
if (shouldHide) { |
||||
ad.classList.add('hidden'); |
||||
ad.classList.remove('flex'); |
||||
} else { |
||||
ad.classList.remove('hidden'); |
||||
ad.classList.add('flex'); |
||||
} |
||||
} |
||||
|
||||
sponsorHidden.listen(showHideSponsor); |
||||
|
||||
window.setTimeout(() => { |
||||
showHideSponsor(false); |
||||
}, 500); |
Loading…
Reference in new issue