Skip to content

Commit f7c058f

Browse files
authored
chore: Added Scarf Tag For Tracking (#246)
Signed-off-by: Hrishav <[email protected]>
1 parent 6c65876 commit f7c058f

File tree

4 files changed

+196
-0
lines changed

4 files changed

+196
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
3+
const ScarfTag = () => {
4+
return (
5+
<img
6+
alt="scarf"
7+
referrerPolicy="no-referrer-when-downgrade"
8+
src="https://static.scarf.sh/a.png?x-pxid=a56ed60e-6f2d-465c-ab2a-409f2086abc5"
9+
/>
10+
)
11+
}
12+
13+
export { ScarfTag }

website/src/components/scarf/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Scarf'

website/src/theme/Footer/index.js

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
import React from 'react'
8+
import clsx from 'clsx'
9+
import Link from '@docusaurus/Link'
10+
import { useThemeConfig } from '@docusaurus/theme-common'
11+
import useBaseUrl from '@docusaurus/useBaseUrl'
12+
import isInternalUrl from '@docusaurus/isInternalUrl'
13+
import styles from './styles.module.css'
14+
import ThemedImage from '@theme/ThemedImage'
15+
import IconExternalLink from '@theme/IconExternalLink'
16+
import { ScarfTag } from '../../components/scarf'
17+
18+
function FooterLink({ to, href, label, prependBaseUrlToHref, ...props }) {
19+
const toUrl = useBaseUrl(to)
20+
const normalizedHref = useBaseUrl(href, {
21+
forcePrependBaseUrl: true
22+
})
23+
return (
24+
<Link
25+
className="footer__link-item"
26+
{...(href
27+
? {
28+
href: prependBaseUrlToHref ? normalizedHref : href
29+
}
30+
: {
31+
to: toUrl
32+
})}
33+
{...props}>
34+
{href && !isInternalUrl(href) ? (
35+
<span>
36+
{label}
37+
<IconExternalLink />
38+
</span>
39+
) : (
40+
label
41+
)}
42+
</Link>
43+
)
44+
}
45+
46+
function FooterLogo({ sources, alt, width, height }) {
47+
return <ThemedImage className="footer__logo" alt={alt} sources={sources} width={width} height={height} />
48+
}
49+
50+
function MultiColumnLinks({ links }) {
51+
return (
52+
<>
53+
{links.map((linkItem, i) => (
54+
<div key={i} className="col footer__col">
55+
<div className="footer__title">{linkItem.title}</div>
56+
<ul className="footer__items">
57+
{linkItem.items.map((item, key) =>
58+
item.html ? (
59+
<li
60+
key={key}
61+
className="footer__item" // Developer provided the HTML, so assume it's safe.
62+
// eslint-disable-next-line react/no-danger
63+
dangerouslySetInnerHTML={{
64+
__html: item.html
65+
}}
66+
/>
67+
) : (
68+
<li key={item.href || item.to} className="footer__item">
69+
<FooterLink {...item} />
70+
</li>
71+
)
72+
)}
73+
</ul>
74+
</div>
75+
))}
76+
</>
77+
)
78+
}
79+
80+
function SimpleLinks({ links }) {
81+
return (
82+
<div className="footer__links">
83+
{links.map((item, key) => (
84+
<>
85+
{item.html ? (
86+
<span
87+
key={key}
88+
className="footer__link-item" // Developer provided the HTML, so assume it's safe.
89+
// eslint-disable-next-line react/no-danger
90+
dangerouslySetInnerHTML={{
91+
__html: item.html
92+
}}
93+
/>
94+
) : (
95+
<FooterLink {...item} />
96+
)}
97+
{links.length !== key + 1 && <span className="footer__link-separator">·</span>}
98+
</>
99+
))}
100+
</div>
101+
)
102+
}
103+
104+
function isMultiColumnFooterLinks(links) {
105+
return 'title' in links[0]
106+
}
107+
108+
function Footer() {
109+
const { footer } = useThemeConfig()
110+
const { copyright, links = [], logo = {} } = footer || {}
111+
const sources = {
112+
light: useBaseUrl(logo.src),
113+
dark: useBaseUrl(logo.srcDark || logo.src)
114+
}
115+
116+
if (!footer) {
117+
return null
118+
}
119+
120+
return (
121+
<footer
122+
className={clsx('footer', {
123+
'footer--dark': footer.style === 'dark'
124+
})}>
125+
<div className="container container-fluid">
126+
{links &&
127+
links.length > 0 &&
128+
(isMultiColumnFooterLinks(links) ? (
129+
<div className="row footer__links">
130+
<MultiColumnLinks links={links} />
131+
</div>
132+
) : (
133+
<div className="footer__links text--center">
134+
<SimpleLinks links={links} />
135+
</div>
136+
))}
137+
{(logo || copyright) && (
138+
<div className="footer__bottom text--center">
139+
{logo && (logo.src || logo.srcDark) && (
140+
<div className="margin-bottom--sm">
141+
{logo.href ? (
142+
<Link href={logo.href} className={styles.footerLogoLink}>
143+
<FooterLogo alt={logo.alt} sources={sources} width={logo.width} height={logo.height} />
144+
</Link>
145+
) : (
146+
<FooterLogo alt={logo.alt} sources={sources} />
147+
)}
148+
</div>
149+
)}
150+
{copyright ? (
151+
<div
152+
className="footer__copyright" // Developer provided the HTML, so assume it's safe.
153+
// eslint-disable-next-line react/no-danger
154+
dangerouslySetInnerHTML={{
155+
__html: copyright
156+
}}
157+
/>
158+
) : null}
159+
</div>
160+
)}
161+
</div>
162+
<ScarfTag />
163+
</footer>
164+
)
165+
}
166+
167+
export default React.memo(Footer)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
.footerLogoLink {
9+
opacity: 0.5;
10+
transition: opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default);
11+
}
12+
13+
.footerLogoLink:hover {
14+
opacity: 1;
15+
}

0 commit comments

Comments
 (0)