forked from ReactTooltip/react-tooltip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
150 lines (139 loc) · 4.72 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* eslint-disable react/require-default-props */
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable global-require */
import React from 'react'
import clsx from 'clsx'
import styles from './styles.module.css'
type FeatureItem = {
title: string
Svg?: React.ComponentType<React.ComponentProps<'svg'>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any, react/no-unused-prop-types
src?: any
// eslint-disable-next-line react/no-unused-prop-types
eventTitle?: string
link: string
}
type SponsorItem = FeatureItem & {
tier: 'gold' | 'silver'
}
const FeatureList: FeatureItem[] = [
{
title: 'Digital Ocean',
Svg: require('@site/static/img/digital-ocean-powered-by.svg').default,
link: 'https://www.digitalocean.com/?refcode=0813b3be1161&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge',
},
{
title: 'Algolia',
Svg: require('@site/static/img/Algolia-logo.svg').default,
link: 'https://docsearch.algolia.com/',
},
]
const SponsorList: SponsorItem[] = [
{
title: 'Frigade',
src: require('@site/static/img/sponsors/frigade.png').default,
link: 'https://frigade.com/?source=react-tooltip',
eventTitle: 'frigade',
tier: 'gold',
},
// {
// title: 'Slot',
// src: require('@site/static/img/sponsors/slot.png').default,
// link: '#',
// eventTitle: 'slot',
// tier: 'silver',
// },
]
function Feature({ title, Svg, link }: FeatureItem) {
let svgClassName = styles.featureSvg
if (Svg === require('@site/static/img/Algolia-logo.svg').default) {
svgClassName = `${styles.featureSvg} ${styles.AlgoliaLogo}`
}
return (
<div className={clsx('col col--6')}>
<div className="text--center">
<a href={link} title={title} target="_blank" rel="noreferrer" aria-label={title}>
<Svg className={svgClassName} role="img"/>
</a>
</div>
</div>
)
}
export default function HomepageSponsored(): JSX.Element {
const onClickSponsorBannerEventHandler = (title: string) => {
if (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || []
window.dataLayer.push({
event: `click_${title}_banner`,
place: 'home',
})
}
return true
}
const goldSponsors = SponsorList.filter(({ tier }) => tier === 'gold')
const silverSponsors = SponsorList.filter(({ tier }) => tier === 'silver')
return (
<section className={styles.features}>
<div className="container">
<div className={styles.sponsoredBy}>
<div>
<h1 className={styles.sponsoredTitle}>Gold Sponsors 🌟</h1>
<div className="row">
{goldSponsors.map(({ link, title, src, eventTitle }, idx) => (
// eslint-disable-next-line react/no-array-index-key
<div key={idx} className={clsx(`col col--${12 / goldSponsors.length}`)}>
<div className="text--center">
<a
href={link}
title={title}
target="_blank"
rel="noreferrer"
onClick={() => {
onClickSponsorBannerEventHandler(eventTitle)
}}
>
<img src={src} alt={title} width={480} />
</a>
</div>
</div>
))}
</div>
</div>
<div>
<h2 className={styles.sponsoredTitle}>Silver Sponsors ✪</h2>
<div className="row">
{silverSponsors.map(({ link, title, src, eventTitle }, idx) => (
// eslint-disable-next-line react/no-array-index-key
<div key={idx} className={clsx(`col col--${12 / silverSponsors.length}`)}>
<div className="text--center">
<a
href={link}
title={title}
target="_blank"
rel="noreferrer"
onClick={() => {
onClickSponsorBannerEventHandler(eventTitle)
}}
>
<img src={src} alt={title} width={200} />
</a>
</div>
</div>
))}
</div>
</div>
</div>
</div>
<div className="container">
<h1 className={styles.sponsoredTitle}>Powered by</h1>
<div className="row">
{FeatureList.map((props, idx) => (
// eslint-disable-next-line react/no-array-index-key
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
)
}