Skip to content

Commit 7f6ae00

Browse files
authored
Use CodeSponsor as advertisement provider (codesandbox#428)
1 parent 3fab018 commit 7f6ae00

File tree

3 files changed

+93
-53
lines changed

3 files changed

+93
-53
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.cs__wrapper {
2+
max-width: 330px;
3+
padding: 10px;
4+
margin: 0;
5+
overflow: hidden;
6+
font-size: 13px;
7+
line-height: 1.4;
8+
text-align: left;
9+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
10+
'Helvetica Neue', Arial, sans-serif;
11+
font-weight: normal;
12+
color: #212529;
13+
}
14+
.cs__header {
15+
text-align: center;
16+
font-size: 13px;
17+
line-height: 1.2;
18+
margin-bottom: 10px;
19+
display: block;
20+
text-decoration: none;
21+
color: #51585f;
22+
}
23+
.cs__blurb {
24+
text-align: center;
25+
font-size: 14px;
26+
line-height: 1.4;
27+
margin-bottom: 10px;
28+
display: block;
29+
text-decoration: none;
30+
color: #212529;
31+
}
32+
.cs__image_wrapper {
33+
text-align: center;
34+
display: block;
35+
}
36+
.cs__image {
37+
max-width: 80%;
38+
}
39+
.cs__footer {
40+
margin-top: 8px;
41+
text-align: center;
42+
font-size: 10px;
43+
}
44+
.cs__wrapper.dark {
45+
color: rgba(255, 255, 255, 0.6);
46+
}
47+
.cs__wrapper.dark .cs__header {
48+
color: rgba(255, 255, 255, 0.5);
49+
}
50+
.cs__wrapper.dark .cs__blurb {
51+
color: rgba(255, 255, 255, 0.8);
52+
}
53+
.cs__wrapper.dark .cs__blurb strong {
54+
color: #6caedd;
55+
}
56+
.cs__wrapper.dark .cs__footer {
57+
color: rgba(255, 255, 255, 0.3);
58+
}
59+
.cs__wrapper.dark .cs__footer a {
60+
color: rgba(255, 255, 255, 0.3);
61+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import './CodeSponsor.css';
3+
4+
type Props = {
5+
token: string,
6+
theme: 'dark' | 'light',
7+
};
8+
9+
export default ({ token, theme }: Props) => {
10+
const pixelHref = `https://cs.berry.sh/l/${token}/pixel.png`;
11+
const linkHref = `https://cs.berry.sh/c/${token}`;
12+
13+
return (
14+
<div className={theme === 'dark' ? 'cs__wrapper dark' : 'cs__wrapper'}>
15+
<div className="cs__header">Proudly sponsored by</div>
16+
<a href={linkHref} className="cs__blurb" target="_blank" rel="noopener">
17+
<strong>Rollbar</strong>{' '}
18+
<span>
19+
Real-time error monitoring, alerting, and analytics for developers{' '}
20+
<span aria-label="rocket" role="img">
21+
🚀
22+
</span>
23+
</span>
24+
</a>
25+
<img alt="CodeSponsor" className="cs__pixel" src={pixelHref} />
26+
</div>
27+
);
28+
};
Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,7 @@
11
import React from 'react';
2-
import styled from 'styled-components';
32

4-
const Container = styled.div`
5-
padding: 1rem;
6-
border-top: 1px solid rgba(0, 0, 0, 0.3);
3+
import CodeSponsor from './CodeSponsor';
74

8-
.carbon-text {
9-
text-decoration: none !important;
10-
color: rgba(255, 255, 255, 0.9) !important;
11-
}
12-
13-
.carbon-wrap {
14-
font-size: 0.875rem;
15-
16-
img {
17-
display: block;
18-
margin-bottom: 0.5rem;
19-
}
20-
}
21-
22-
.carbon-poweredby {
23-
display: block;
24-
margin-top: 0.5rem;
25-
26-
font-size: 0.75rem;
27-
text-decoration: none !important;
28-
color: rgba(255, 255, 255, 0.6) !important;
29-
}
30-
`;
31-
32-
export default class Advertisement extends React.PureComponent {
33-
componentDidMount() {
34-
requestAnimationFrame(() => {
35-
const script = document.createElement('script');
36-
script.setAttribute(
37-
'src',
38-
'//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=codesandboxio'
39-
);
40-
script.async = 'true';
41-
document.head.appendChild(script);
42-
});
43-
}
44-
45-
render() {
46-
return (
47-
<Container>
48-
<script
49-
id="_carbonads_js"
50-
src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=codesandboxio"
51-
async="true"
52-
/>
53-
</Container>
54-
);
55-
}
56-
}
5+
export default () => (
6+
<CodeSponsor token="4c558242-bb75-49a4-9b6f-5b393bcc78ed" theme="dark" />
7+
);

0 commit comments

Comments
 (0)