Skip to content

Commit 162fa67

Browse files
authored
Merge pull request #1084 from ReactTooltip/docs/carbon-ads
chore: use carbon ads instead of google ads
2 parents 29c4168 + 23e4b79 commit 162fa67

File tree

6 files changed

+125
-36
lines changed

6 files changed

+125
-36
lines changed

docs/docusaurus.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ const config = {
3838
// src: '/js/gpt.js',
3939
// async: true,
4040
// },
41-
{
42-
src: '/js/ads.js',
43-
async: true,
44-
},
41+
// {
42+
// src: '/js/ads.js',
43+
// async: true,
44+
// },
4545
],
4646

4747
presets: [
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
import React, { useEffect } from 'react'
2-
import styles from './styles.module.css'
1+
import React, { useEffect, useRef } from 'react'
2+
import './styles.css'
3+
4+
const AdsContainerElement = () => {
5+
const containerRef = useRef<any>()
36

4-
const AdsContainerElement = ({ id }) => {
57
useEffect(() => {
68
if (typeof window !== 'undefined') {
7-
window.dispatchEvent(new CustomEvent('AdsContainerMounted', { detail: { id } }))
9+
const scriptElement = document.createElement('script')
10+
scriptElement.src = '//cdn.carbonads.com/carbon.js?serve=CWYD553L&placement=react-tooltipcom'
11+
scriptElement.id = '_carbonads_js'
12+
scriptElement.async = true
13+
14+
if (containerRef?.current) {
15+
containerRef.current.innerHTML = ''
16+
containerRef.current.appendChild(scriptElement)
17+
}
818
}
919
}, [])
1020

11-
return <div id={id} className={styles.adsContainer} />
21+
return <div className="carbon-ads" ref={containerRef} />
1222
}
1323

1424
export default AdsContainerElement
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.carbon-ads {
2+
position: fixed;
3+
}
4+
5+
#carbonads * {
6+
margin: initial;
7+
padding: initial;
8+
line-height: initial;
9+
}
10+
11+
#carbonads {
12+
--carbon-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
13+
Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;
14+
--carbon-font-size: 14px;
15+
--carbon-padding: 1.5ch;
16+
--carbon-max-char: 20ch;
17+
--carbon-bg-primary: hsl(0, 0%, 98%);
18+
--carbon-bg-secondary: hsl(0, 0%, 92%);
19+
--carbon-text-color: hsl(0, 0%, 20%);
20+
z-index: 10;
21+
font-size: var(--carbon-font-size);
22+
font-family: var(--carbon-font-family);
23+
}
24+
25+
#carbonads > span {
26+
display: flex;
27+
flex-direction: column;
28+
min-inline-size: 130px;
29+
max-inline-size: calc(130px + var(--carbon-max-char) + 8ch);
30+
padding: var(--carbon-padding);
31+
gap: var(--carbon-padding);
32+
background-color: var(--carbon-bg-primary);
33+
box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.085), 0 0 2px hsl(0deg 0% 0% / 0.085),
34+
0 0 4px hsl(0deg 0% 0% / 0.085), 0 0 8px hsl(0deg 0% 0% / 0.085);
35+
}
36+
37+
#carbonads a {
38+
color: var(--carbon-text-color);
39+
text-decoration: none;
40+
}
41+
42+
#carbonads a:hover {
43+
color: var(--carbon-text-color);
44+
}
45+
46+
#carbonads .carbon-wrap {
47+
display: flex;
48+
flex-wrap: wrap;
49+
gap: 1.5ex;
50+
}
51+
52+
#carbonads .carbon-img {
53+
flex: 0 0 130px;
54+
}
55+
56+
#carbonads .carbon-img img {
57+
display: block;
58+
}
59+
60+
#carbonads .carbon-text {
61+
flex-grow: 1;
62+
flex-basis: var(--carbon-max-char);
63+
line-height: 1.4;
64+
text-align: left;
65+
}
66+
67+
#carbonads .carbon-poweredby {
68+
padding: 6px 8px;
69+
background: var(--carbon-bg-secondary);
70+
color: var(--carbon-text-color);
71+
font-weight: 600;
72+
font-size: 0.6em;
73+
line-height: 1.4;
74+
letter-spacing: 0.2ch;
75+
text-align: center;
76+
text-transform: uppercase;
77+
}
78+
79+
@media (prefers-color-scheme: dark) {
80+
#carbonads {
81+
--carbon-bg-primary: hsl(0, 0%, 12%);
82+
--carbon-bg-secondary: hsl(0, 0%, 15%);
83+
--carbon-text-color: hsl(0, 0%, 90%);
84+
}
85+
}

docs/src/components/AdsContainerElement/styles.module.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/theme/Footer/index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/* eslint-disable import/no-unresolved */
2-
import React, { useEffect } from 'react'
2+
import React from 'react'
33
import Footer from '@theme-original/Footer'
44
// import AdsContainerElement from '@site/src/components/AdsContainerElement'
55

66
export default function FooterWrapper(props) {
7-
useEffect(() => {
8-
if (typeof window !== 'undefined') {
9-
const scriptElement = document.createElement('script')
10-
scriptElement.src =
11-
'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7420210265158247'
12-
scriptElement.async = true
13-
scriptElement.onload = () => {
14-
if (typeof window !== 'undefined') {
15-
window.onload = () => {
16-
;(window.adsbygoogle = window.adsbygoogle || []).push({})
17-
}
18-
}
19-
}
20-
document.body.appendChild(scriptElement)
21-
}
22-
}, [])
7+
// useEffect(() => {
8+
// if (typeof window !== 'undefined') {
9+
// const scriptElement = document.createElement('script')
10+
// scriptElement.src =
11+
// 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7420210265158247'
12+
// scriptElement.async = true
13+
// scriptElement.onload = () => {
14+
// if (typeof window !== 'undefined') {
15+
// window.onload = () => {
16+
// ;(window.adsbygoogle = window.adsbygoogle || []).push({})
17+
// }
18+
// }
19+
// }
20+
// document.body.appendChild(scriptElement)
21+
// }
22+
// }, [])
2323

2424
return (
2525
<>

docs/src/theme/TOC/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* eslint-disable import/no-unresolved */
22
import React from 'react'
33
import TOC from '@theme-original/TOC'
4-
// import AdsContainerElement from '@site/src/components/AdsContainerElement'
4+
import AdsContainerElement from '@site/src/components/AdsContainerElement'
55

66
export default function TOCWrapper(props) {
77
return (
88
<>
99
<TOC {...props} />
10-
{/* <AdsContainerElement id="right-sidebar-ads" /> */}
11-
<ins
10+
<AdsContainerElement />
11+
{/* <ins
1212
className="adsbygoogle"
1313
style={{ display: 'block', position: 'fixed', width: '300px', height: '600px' }}
1414
data-ad-client="ca-pub-7420210265158247"
1515
data-ad-slot="8711379942"
1616
data-ad-format="auto"
1717
data-full-width-responsive="true"
18-
/>
18+
/> */}
1919
</>
2020
)
2121
}

0 commit comments

Comments
 (0)