Skip to content

Commit 6e68f17

Browse files
authoredJul 3, 2020
refactor(www): Turn HubspotForm to function component (#25495)
* Turn HubspotForm to function component * fix error
1 parent 88cfa77 commit 6e68f17

File tree

2 files changed

+57
-65
lines changed

2 files changed

+57
-65
lines changed
 

‎docs/blog/2018-08-01-partner-program/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Fill out the form below to let us know your interest in the Gatsby Partner Progr
4040
### Partner application form:
4141

4242
<HubspotForm
43-
portal-id="4731712"
44-
form-id="bbad5044-d31d-4473-bd57-62cb64fdc811"
45-
sfdc-campaign-id="701f4000000VDrYAAW"
43+
portalId="4731712"
44+
formId="bbad5044-d31d-4473-bd57-62cb64fdc811"
45+
sfdcCampaignId="701f4000000VDrYAAW"
4646
/>

‎www/src/components/hubspot-form.js

+54-62
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,60 @@
11
/** @jsx jsx */
22
import { jsx } from "theme-ui"
3-
import { Component } from "react"
43

5-
import HubspotForm from "./react-hubspot-form"
4+
import ReactHubspotForm from "./react-hubspot-form"
65
import { formInput, formInputFocus, buttonStyles } from "../utils/styles"
76

8-
export default class GatsbyHubspotForm extends Component {
9-
render() {
10-
const portalId = this.props.portalId || this.props[`portal-id`]
11-
const formId = this.props.formId || this.props[`form-id`]
12-
const sfdcCampaignId =
13-
this.props.sfdcCampaignId || this.props[`sfdc-campaign-id`]
14-
15-
// See https://designers.hubspot.com/docs/cos/hubspot-form-markup#styling-forms for information on how to style the form
16-
return (
17-
<div
18-
sx={{
19-
"& form": {
20-
margin: 0,
21-
},
22-
"& .hs-form fieldset": {
23-
maxWidth: `none`,
24-
width: `100%`,
25-
},
26-
"& .hs-form-field": {
27-
pb: 5,
28-
},
29-
"& ul.hs-error-msgs": {
30-
listStyleType: `none`,
31-
margin: 0,
32-
color: `warning`,
33-
fontSize: 1,
34-
},
35-
"& .hs-form input": {
36-
...formInput,
37-
},
38-
'& .hs-form input[type="text"], .hs-form input[type="email"], .hs-form input[type="number"]': {
39-
width: `100% !important`,
40-
":focus": {
41-
...formInputFocus,
42-
},
43-
},
44-
"& label": {
45-
// a bit unsure about the implications of the next line
46-
display: `inline-block`,
47-
fontSize: 1,
48-
pb: 1,
49-
},
50-
"& .hs-form-required": {
51-
color: `textMuted`,
52-
},
53-
"& .hs-button.primary": {
54-
...buttonStyles().default,
55-
},
56-
}}
57-
>
58-
<HubspotForm
59-
portalId={portalId}
60-
formId={formId}
61-
sfdcCampaignId={sfdcCampaignId}
62-
loading="Loading..."
63-
{...{ css: `` }}
64-
/>
65-
</div>
66-
)
67-
}
7+
export default function HubspotForm({ portalId, formId, sfdcCampaignId }) {
8+
// See https://designers.hubspot.com/docs/cos/hubspot-form-markup#styling-forms for information on how to style the form
9+
return (
10+
<div
11+
sx={{
12+
"& form": {
13+
margin: 0,
14+
},
15+
"& .hs-form fieldset": {
16+
maxWidth: `none`,
17+
width: `100%`,
18+
},
19+
"& .hs-form-field": {
20+
pb: 5,
21+
},
22+
"& ul.hs-error-msgs": {
23+
listStyleType: `none`,
24+
margin: 0,
25+
color: `warning`,
26+
fontSize: 1,
27+
},
28+
"& .hs-form input": {
29+
...formInput,
30+
},
31+
'& .hs-form input[type="text"], .hs-form input[type="email"], .hs-form input[type="number"]': {
32+
width: `100% !important`,
33+
":focus": {
34+
...formInputFocus,
35+
},
36+
},
37+
"& label": {
38+
// a bit unsure about the implications of the next line
39+
display: `inline-block`,
40+
fontSize: 1,
41+
pb: 1,
42+
},
43+
"& .hs-form-required": {
44+
color: `textMuted`,
45+
},
46+
"& .hs-button.primary": {
47+
...buttonStyles().default,
48+
},
49+
}}
50+
>
51+
<ReactHubspotForm
52+
portalId={portalId}
53+
formId={formId}
54+
sfdcCampaignId={sfdcCampaignId}
55+
loading="Loading..."
56+
{...{ css: `` }}
57+
/>
58+
</div>
59+
)
6860
}

0 commit comments

Comments
 (0)
Please sign in to comment.