Skip to content

Commit 8f213e0

Browse files
author
Ives van Hoorne
committed
Fix Stripe & Add CodeSponsor
1 parent 6ed267c commit 8f213e0

File tree

7 files changed

+84
-29
lines changed

7 files changed

+84
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
"react-router-dom": "^4.1.1",
146146
"react-router-redux": "next",
147147
"react-split-pane": "^0.1.63",
148-
"react-stripe-elements": "^0.0.2",
148+
"react-stripe-elements": "^0.1.0",
149149
"react-tippy": "^0.14.0",
150150
"redbox-react": "^1.4.3",
151151
"redux": "^3.7.1",

src/app/components/user/SubscribeForm/CheckoutForm.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ class CheckoutForm extends React.PureComponent {
131131
<Label>Card</Label>
132132
{errors.stripe != null && <ErrorText>{errors.stripe}</ErrorText>}
133133
<CardContainer>
134-
<CardElement style={{ base: { color: 'white', fontWeight: 300 } }} />
134+
<CardElement
135+
style={{ base: { color: 'white', fontWeight: '500' } }}
136+
/>
135137
</CardContainer>
136138

137139
<Button

src/app/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<!-- End Google Tag Manager -->
3939
<script src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
4040
<script async src="//cdn.headwayapp.co/widget.js"></script>
41-
<script async src="https://js.stripe.com/v3/"></script>
4241

4342
<!-- AMD Loader for Monaco -->
4443
<script src="/public/vs/loader.js"></script>

src/app/pages/Patron/index.js

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,56 @@ const Content = styled.div`
1717
color: white;
1818
`;
1919

20-
export default function Support() {
21-
document.title = 'Patron - CodeSandbox';
22-
return (
23-
<MaxWidth>
24-
<Margin vertical={1.5} horizontal={1.5}>
25-
<Navigation title="Become a Patron" />
26-
<Content>
27-
<MaxWidth width={1024}>
28-
<Title>Become a CodeSandbox Patron!</Title>
29-
<SubTitle>
30-
You can support us by paying a monthly amount of your choice.
31-
<br />
32-
The money goes to all expenses of CodeSandbox.
33-
</SubTitle>
34-
35-
<Centered horizontal>
36-
<PricingModal />
37-
</Centered>
38-
</MaxWidth>
39-
</Content>
40-
</Margin>
41-
</MaxWidth>
42-
);
20+
type State = {
21+
stripeLoaded: boolean,
22+
};
23+
24+
export default class Patron extends React.PureComponent<void, State> {
25+
constructor() {
26+
super();
27+
const stripeLoaded = Boolean(window.Stripe);
28+
29+
if (!stripeLoaded) {
30+
const script = document.createElement('script');
31+
script.setAttribute('src', 'https://js.stripe.com/v3/');
32+
script.async = false;
33+
document.head.appendChild(script);
34+
35+
script.onload = () => {
36+
this.setState({ stripeLoaded: true });
37+
};
38+
}
39+
40+
this.state = {
41+
stripeLoaded,
42+
};
43+
}
44+
45+
render() {
46+
document.title = 'Patron - CodeSandbox';
47+
48+
if (!this.state.stripeLoaded) return null;
49+
50+
return (
51+
<MaxWidth>
52+
<Margin vertical={1.5} horizontal={1.5}>
53+
<Navigation title="Become a Patron" />
54+
<Content>
55+
<MaxWidth width={1024}>
56+
<Title>Become a CodeSandbox Patron!</Title>
57+
<SubTitle>
58+
You can support us by paying a monthly amount of your choice.
59+
<br />
60+
The money goes to all expenses of CodeSandbox.
61+
</SubTitle>
62+
63+
<Centered horizontal>
64+
<PricingModal />
65+
</Centered>
66+
</MaxWidth>
67+
</Content>
68+
</Margin>
69+
</MaxWidth>
70+
);
71+
}
4372
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
3+
export default class Advertisement extends React.PureComponent {
4+
componentDidMount() {
5+
requestAnimationFrame(() => {
6+
const script = document.createElement('script');
7+
script.setAttribute(
8+
'src',
9+
'https://app.codesponsor.io/scripts/o81cdkzTVQe3UbTW0J2EQw?theme=dark&height=120&image=hide'
10+
);
11+
script.async = true;
12+
document.head.appendChild(script);
13+
});
14+
}
15+
16+
render() {
17+
return (
18+
<div>
19+
<div id="code-sponsor-widget" />
20+
</div>
21+
);
22+
}
23+
}

src/app/pages/Sandbox/Editor/Workspace/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import WorkspaceItem from './WorkspaceItem';
2626
import SandboxActions from './SandboxActions';
2727
import Logo from './Logo';
2828
import ConnectionNotice from './ConnectionNotice';
29+
import Advertisement from './Advertisement';
2930

3031
const Container = styled.div`
3132
position: absolute;
@@ -153,6 +154,7 @@ const Workspace = ({
153154
</div>
154155

155156
<div>
157+
{!isPatron && <Advertisement />}
156158
<ConnectionNotice />
157159
<TermsContainer>
158160
By using CodeSandbox you agree to our{' '}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7187,9 +7187,9 @@ react-split-pane@^0.1.63:
71877187
prop-types "^15.5.10"
71887188
react-style-proptype "^3.0.0"
71897189

7190-
react-stripe-elements@^0.0.2:
7191-
version "0.0.2"
7192-
resolved "https://registry.yarnpkg.com/react-stripe-elements/-/react-stripe-elements-0.0.2.tgz#57ec82e086a236482d5ad1599e58234ee9e3a881"
7190+
react-stripe-elements@^0.1.0:
7191+
version "0.1.0"
7192+
resolved "https://registry.yarnpkg.com/react-stripe-elements/-/react-stripe-elements-0.1.0.tgz#1cddd0b33ea341f83de0956d9bbd94386e3189d1"
71937193
dependencies:
71947194
prop-types "^15.5.8"
71957195

0 commit comments

Comments
 (0)