|
|
@ -3,6 +3,7 @@ import { useScrollPosition } from '../../hooks/use-scroll-position.ts'; |
|
|
|
import { X } from 'lucide-react'; |
|
|
|
import { X } from 'lucide-react'; |
|
|
|
import type { StickyTopSponsorType } from './PageSponsors.tsx'; |
|
|
|
import type { StickyTopSponsorType } from './PageSponsors.tsx'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
import { isOnboardingStripHidden } from '../../stores/page.ts'; |
|
|
|
|
|
|
|
|
|
|
|
type StickyTopSponsorProps = { |
|
|
|
type StickyTopSponsorProps = { |
|
|
|
sponsor: StickyTopSponsorType; |
|
|
|
sponsor: StickyTopSponsorType; |
|
|
@ -22,6 +23,15 @@ export function StickyTopSponsor(props: StickyTopSponsorProps) { |
|
|
|
const [isImpressionLogged, setIsImpressionLogged] = useState(false); |
|
|
|
const [isImpressionLogged, setIsImpressionLogged] = useState(false); |
|
|
|
const [isHidden, setIsHidden] = useState(false); |
|
|
|
const [isHidden, setIsHidden] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if (!sponsor) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// hide the onboarding strip when the sponsor is visible
|
|
|
|
|
|
|
|
isOnboardingStripHidden.set(true); |
|
|
|
|
|
|
|
}, [sponsor]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (scrollY < SCROLL_DISTANCE || isImpressionLogged) { |
|
|
|
if (scrollY < SCROLL_DISTANCE || isImpressionLogged) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -42,25 +52,29 @@ export function StickyTopSponsor(props: StickyTopSponsorProps) { |
|
|
|
onClick={onSponsorClick} |
|
|
|
onClick={onSponsorClick} |
|
|
|
className={cn( |
|
|
|
className={cn( |
|
|
|
'fixed left-0 right-0 top-0 z-[91] flex min-h-[45px] w-full flex-row items-center justify-center px-14 pb-2 pt-1.5 text-base font-medium text-yellow-950', |
|
|
|
'fixed left-0 right-0 top-0 z-[91] flex min-h-[45px] w-full flex-row items-center justify-center px-14 pb-2 pt-1.5 text-base font-medium text-yellow-950', |
|
|
|
'bg-gradient-to-b from-purple-700 to-purple-800 text-white', |
|
|
|
|
|
|
|
)} |
|
|
|
)} |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
backgroundImage: `linear-gradient(to bottom, ${sponsor.style?.fromColor}, ${sponsor.style?.toColor})`, |
|
|
|
|
|
|
|
color: sponsor.style?.textColor, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<img className="h-[23px]" src={sponsor.imageUrl} alt={'ad'} /> |
|
|
|
|
|
|
|
<span className="mx-3 truncate">{sponsor.description}</span> |
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
className="flex-truncate rounded-md px-3 py-1 text-sm transition-colors" |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
backgroundColor: sponsor.style?.buttonBackgroundColor, |
|
|
|
|
|
|
|
color: sponsor.style?.buttonTextColor, |
|
|
|
|
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
<img |
|
|
|
{sponsor.buttonText} |
|
|
|
className="h-[23px]" |
|
|
|
|
|
|
|
src={'https://tpc.googlesyndication.com/simgad/915843892126714634?'} |
|
|
|
|
|
|
|
alt={'ad'} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<span className="mx-3 truncate"> |
|
|
|
|
|
|
|
Register for our free cloud workshop |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
<button className="flex-truncate rounded-md bg-yellow-400 px-3 py-1 text-sm text-purple-900 transition-colors hover:bg-yellow-300"> |
|
|
|
|
|
|
|
Register now |
|
|
|
|
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<button |
|
|
|
<button |
|
|
|
type="button" |
|
|
|
type="button" |
|
|
|
className="absolute right-5 top-1/2 ml-1 -translate-y-1/2 px-1 py-1 opacity-70 hover:opacity-100" |
|
|
|
className="absolute right-5 top-1/2 ml-1 -translate-y-1/2 px-1 py-1 opacity-70 hover:opacity-100" |
|
|
|
onClick={(e) => { |
|
|
|
onClick={(e) => { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
|
|
|
|
setIsHidden(true); |
|
|
|
setIsHidden(true); |
|
|
|
onSponsorHidden(); |
|
|
|
onSponsorHidden(); |
|
|
|