Skip to content

Commit 7d22f7e

Browse files
author
Kent C. Dodds
committed
add codefund
1 parent 362dfde commit 7d22f7e

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

website/siteConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ const siteConfig = {
135135
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
136136
'/js/code-block-buttons.js',
137137
'/js/sidenav.js',
138+
'/js/codefund.js',
138139
],
139140

140141
stylesheets: [

website/static/css/custom.css

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ a {
8383

8484
.tabs .nav-tabs > div.active {
8585
border-bottom: none;
86-
background: #F0F0F0; /* same as code block */
86+
background: #f0f0f0; /* same as code block */
8787
border-top-left-radius: 3px;
8888
border-top-right-radius: 3px;
8989
}
@@ -93,7 +93,7 @@ a {
9393
}
9494

9595
details > summary {
96-
cursor: pointer;
96+
cursor: pointer;
9797
}
9898

9999
/* Responsive */
@@ -123,3 +123,52 @@ details > summary {
123123

124124
@media only screen and (min-width: 1500px) {
125125
}
126+
127+
/* codefund ads */
128+
#codefund-container {
129+
background-color: rgba(255, 255, 255, 0.9);
130+
overflow: hidden;
131+
padding-bottom: 15px;
132+
height: 155px;
133+
font-size: 12px;
134+
z-index: 1;
135+
}
136+
137+
#codefund-container #codefund {
138+
height: 100%;
139+
display: flex;
140+
justify-content: center;
141+
align-items: center;
142+
}
143+
144+
/* mobile */
145+
@media (max-width: 624px) {
146+
#codefund-container #cf {
147+
width: auto !important;
148+
}
149+
#codefund-container .cf-img-wrapper {
150+
float: left;
151+
margin-right: 10px;
152+
}
153+
}
154+
155+
/* tablet */
156+
@media (min-width: 625px) {
157+
#codefund-container {
158+
float: right;
159+
width: 165px;
160+
padding-left: 25px;
161+
height: auto;
162+
}
163+
}
164+
165+
/* desktop */
166+
@media (min-width: 1024px) {
167+
#codefund-container {
168+
position: fixed;
169+
bottom: 0;
170+
right: 0;
171+
padding: 20px;
172+
height: auto;
173+
}
174+
}

website/static/js/codefund.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// add the codefund div
2+
// funds generated from codefund ad revenue are sent directly to the
3+
// Testing Library open collective which are used to help support the project.
4+
document.addEventListener('DOMContentLoaded', () => {
5+
const post = document.querySelector('.mainContainer .wrapper .post')
6+
if (!post) {
7+
// we only put the ad on pages that have a "post"
8+
return
9+
}
10+
const codefundDiv = document.createElement('div')
11+
codefundDiv.id = 'codefund-container'
12+
codefundDiv.innerHTML = `
13+
<div id="codefund">
14+
<div>
15+
Testing Library loads relevant ethical ads via <a href="https://codefund.io" rel="noopener noreferrer">CodeFund.io</a>.
16+
The funds are contributed to <a href="https://opencollective.com/testing-library" rel="noopener noreferrer">our Open Collective</a>.
17+
Please disable your ad blocker for testing-library.com
18+
</div>
19+
</div>
20+
`
21+
post.prepend(codefundDiv)
22+
23+
const scriptEl = document.createElement('script')
24+
scriptEl.src = 'https://codefund.io/properties/389/funder.js'
25+
document.body.appendChild(scriptEl)
26+
})

0 commit comments

Comments
 (0)