-
-
Notifications
You must be signed in to change notification settings - Fork 533
/
Copy pathindex.tsx
60 lines (51 loc) · 1.31 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* eslint-disable import/no-unresolved */
import React from 'react'
// @ts-ignore
import LogoFrigade from '@site/static/img/sponsors/frigade.png'
import './styles.css'
declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dataLayer?: any
}
}
const SPONSORS = {
frigade: {
logo: LogoFrigade,
title: 'Frigade',
href: 'https://frigade.com/',
},
}
interface BannerSponsorProps {
sponsorKey: keyof typeof SPONSORS
tier: 'gold' | 'silver'
}
const BannerSponsor = ({ sponsorKey, tier }: BannerSponsorProps) => {
const sponsor = SPONSORS[sponsorKey]
const onClickSponsorBannerEventHandler = () => {
if (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || []
window.dataLayer.push({
event: `click_sponsor_banner`,
place: 'sidebar',
sponsorKey,
sponsorTitle: sponsor.title,
})
}
return true
}
return (
<div className={`sponsor-banner sponsor-banner-${tier}`}>
<a
href={`${sponsor.href}?source=react-tooltip`}
title={sponsor.title}
target="_blank"
rel="noreferrer"
onClick={onClickSponsorBannerEventHandler}
>
<img src={sponsor.logo} alt={sponsor.title} />
</a>
</div>
)
}
export default BannerSponsor