35 |
36 |
37 |
38 |
39 | ```
40 |
41 | All examples make use partially of code blocks defined below
42 |
43 |
44 | Example 1: using `onReady` as emit
45 |
46 | ```vue
47 |
48 |
54 |
55 | ```
56 |
57 |
58 |
59 |
60 | Example 2: using `onReady` as callback
61 |
62 | ```vue
63 |
64 |
70 |
71 | ```
72 |
73 |
74 |
75 |
76 | Example 3: inject CSS via options
77 |
78 | ```tsx
79 | import { CreateOptions } from '@jagaad/vue-hubspot-form';
80 |
81 | // these values are fake, add your own
82 | const options: CreateOptions = {
83 | // ...
84 | // Read the official docs for more info
85 | cssRequired: `.hubspot-link__container { display: none }`,
86 | // ...
87 | };
88 | ```
89 |
90 |
91 |
92 |
93 | Example 4: inject CSS in `onReady` callback
94 |
95 | ```tsx
96 | import { Payload } from '@jagaad/vue-hubspot-form';
97 |
98 | function onReady({ iframeDocument: doc }: Payload) {
99 | const element = doc.createElement('style');
100 | const styles = `.hubspot-link__container { display: none }`;
101 | element.appendChild(doc.createTextNode(styles));
102 | doc.head.appendChild(element);
103 | }
104 | ```
105 |
106 |
107 |
108 |
109 |
110 |
111 | Example 5: inject CSS using JSS via options
112 |
113 | ```tsx
114 | import jss, { Rule } from 'jss';
115 |
116 | jss.use({
117 | // this will make JSS to use selectors as names
118 | onCreateRule(name, _decl, options) {
119 | options.selector = name;
120 | return null as unknown as Rule;
121 | },
122 | });
123 |
124 | const styleSheet = jss.createStyleSheet({
125 | '.hubspot-link__container': {
126 | display: 'none',
127 | },
128 | });
129 |
130 | const options = {
131 | // ...
132 | cssRequired: styleSheet.toString(),
133 | };
134 | ```
135 |
136 |
137 |
138 |
139 | Code Blocks
140 |
141 | **Options:**
142 |
143 | ```tsx
144 | import { CreateOptions } from '@jagaad/vue-hubspot-form';
145 |
146 | // these values are fake, add your own
147 | const options: CreateOptions = {
148 | region: 'eu1',
149 | portalId: '83991272',
150 | formId: '25f1e214-1236-45c3-810m-d8dk31736c72',
151 | // ...
152 | };
153 | ```
154 |
155 | **On Ready callback:**
156 |
157 | ```tsx
158 | import { Payload } from '@jagaad/vue-hubspot-form';
159 |
160 | const onReady = (payload: Payload) => console.log(payload);
161 | ```
162 |
163 | **Fallback Components:**
164 |
165 | ```tsx
166 | import { defineComponent } from 'vue';
167 |
168 | // Loading Component
169 | const fallback = defineComponent({
170 | /* ... */
171 | });
172 | // Error Component
173 | const error = defineComponent({
174 | /* ... */
175 | });
176 | ```
177 |
178 |
179 |
180 | ## Contributing
181 |
182 | ```shell
183 | git clone git@github.com:jagaad/vue-hubspot-form.git
184 | cd vue-hubspot-form
185 | npm install
186 | ```
187 |
188 | - Create a copy of `.env` file to `.env.local`
189 | - Adjust `.env.local` to your HubSpot values
190 |
191 | ```
192 | npm run dev
193 | ```
194 |
195 | ## Links
196 |
197 | - https://developers.hubspot.com/docs/cms/building-blocks/forms
198 | - https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options
199 | - https://github.com/escaladesports/react-hubspot-form/blob/master/src/index.js
200 |
201 | # Vue 3 + Typescript + Vite
202 |
203 | This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `
12 |