File tree 2 files changed +110
-0
lines changed 2 files changed +110
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { Global , css } from '@emotion/react'
3
+
4
+ function buildScript ( src , attrs = { } ) {
5
+ const script = document . createElement ( 'script' )
6
+ script . async = true
7
+ Object . keys ( attrs ) . forEach ( attr => script . setAttribute ( attr , attrs [ attr ] ) )
8
+ script . src = src
9
+
10
+ return script
11
+ }
12
+
13
+ export default function CarbonAds ( ) {
14
+ const ref = React . useRef ( )
15
+
16
+ React . useEffect ( ( ) => {
17
+ const script = buildScript (
18
+ '//cdn.carbonads.com/carbon.js?serve=CESDV5QY&placement=emotionsh' ,
19
+ {
20
+ type : 'text/javascript' ,
21
+ id : '_carbonads_js'
22
+ }
23
+ )
24
+
25
+ ref . current . appendChild ( script )
26
+ } , [ ] )
27
+
28
+ return (
29
+ < >
30
+ < Global
31
+ styles = { css `
32
+ # carbonads {
33
+ display : block;
34
+
35
+ overflow : hidden;
36
+ margin-bottom : 2em ;
37
+ }
38
+
39
+ # carbonads a ,
40
+ # carbonads a : hover {
41
+ color : inherit;
42
+ text-decoration : none;
43
+ }
44
+
45
+ # carbonads span {
46
+ display : block;
47
+
48
+ overflow : hidden;
49
+ }
50
+
51
+ # carbonads .carbon-img {
52
+ display : block;
53
+
54
+ line-height : 1 ;
55
+ }
56
+
57
+ # carbonads .carbon-img img {
58
+ display : block;
59
+ border : solid 1px hsla (0 , 0% , 7% , 0.1 );
60
+ }
61
+
62
+ # carbonads .carbon-text {
63
+ display : block;
64
+ margin-top : 0.5em ;
65
+
66
+ font-size : 14px ;
67
+ line-height : 1.35 ;
68
+ }
69
+
70
+ # carbonads .carbon-poweredby {
71
+ display : block;
72
+ margin-top : 0.5em ;
73
+
74
+ font-size : 10px ;
75
+ font-weight : 600 ;
76
+ line-height : 1 ;
77
+ letter-spacing : 0.1ch ;
78
+ text-transform : uppercase;
79
+ }
80
+
81
+ @media only screen and (min-width : 320px ) and (max-width : 759px ) {
82
+ # carbonads {
83
+ position : relative;
84
+ }
85
+
86
+ # carbonads .carbon-wrap {
87
+ display : flex;
88
+ flex-direction : row;
89
+ }
90
+
91
+ # carbonads .carbon-text {
92
+ padding : 0 12px ;
93
+ font-size : 16px ;
94
+ }
95
+
96
+ # carbonads .carbon-poweredby {
97
+ position : absolute;
98
+ left : 142px ;
99
+ bottom : 0 ;
100
+ }
101
+ }
102
+ ` }
103
+ />
104
+ < div ref = { ref } />
105
+ </ >
106
+ )
107
+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import { getDocMap, docList } from '../utils/misc'
15
15
import DocMetadata from './DocMetadata'
16
16
import Search from './Search'
17
17
18
+ import Carbon from './Carbon'
19
+
18
20
let space = constants . space
19
21
const scaleAnimation = keyframes `
20
22
from {
@@ -178,6 +180,7 @@ export default ({
178
180
]
179
181
} ) }
180
182
>
183
+ < Carbon />
181
184
< Search />
182
185
{ docList . map ( item => {
183
186
return (
You can’t perform that action at this time.
0 commit comments