Skip to content

Commit 5ddda47

Browse files
committed
feat: form submit switched to use cta component + styling
1 parent 121dc57 commit 5ddda47

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

Diff for: components/button/cta.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
d="M 24 40 H 2.0441 C 1.3963 40 0.9194 39.3934 1 38.7639 L 7.0927 13.9863 C 9 6 16 1 24 1"
2828
stroke="#FFC582"
2929
stroke-width="2"
30-
shape-rendering="crispEdges" />
30+
shape-rendering="crispEdges"
31+
class="stroke-path" />
3132
</svg>
3233

3334
<div :class="['button-content', { hide: loading }]">

Diff for: components/signup-card.vue

+43-23
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@
9090
<span v-if="fieldError.country" class="error message" v-html="errorMessage" />
9191
</div>
9292

93-
<ZeroButton
94-
class="submit-button"
93+
<ButtonCta
94+
:class="['submit-button', { submitted: formSubmitted }]"
95+
theme="primary"
9596
@clicked="submitForm">
96-
<span class="button-label"> Register </span>
97-
</ZeroButton>
97+
<span class="button-label"> {{ submitButtonLabel }} </span>
98+
</ButtonCta>
9899

99100
</div>
100101

@@ -114,6 +115,7 @@ const props = defineProps({
114115
})
115116
116117
// ======================================================================== Data
118+
const formSubmitted = ref(false)
117119
const errorMessage = '[ Field is required ]'
118120
const fieldError = ref({
119121
firstName: false,
@@ -150,6 +152,8 @@ const orgField = computed(() => { return props.signupCard.signup_form.org })
150152
151153
const countryField = computed(() => { return props.signupCard.signup_form.country })
152154
155+
const submitButtonLabel = computed(() => { return formSubmitted.value ? 'Success' : 'Submit' })
156+
153157
// ===================================================================== Methdos
154158
/**
155159
* @method updateInputValue
@@ -206,19 +210,19 @@ const submitForm = async () => {
206210
'Content-Type': 'application/json',
207211
'Authorization': `Bearer ${SINGULARITY_DEMO_SIGNUPS_TOKEN}`
208212
}
209-
await $fetch('https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblDUSr66nczukX9Y', {
213+
const res = await $fetch('https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblDUSr66nczukX9Y', {
210214
method: 'POST',
211215
body,
212216
headers
213217
})
214-
} else {
215-
if(!firstName.value) { fieldError.value.firstName = true }
216-
if(!lastName.value) { fieldError.value.lastName = true }
217-
if(!email.value) { fieldError.value.email = true }
218-
if(!organization.value) { fieldError.value.organization = true }
219-
if(!organization.value) { fieldError.value.organization = true }
220-
if(!country.value) { fieldError.value.country = true }
221-
}
218+
if (res) { formSubmitted.value = true; return }
219+
}
220+
if(!firstName.value) { fieldError.value.firstName = true }
221+
if(!lastName.value) { fieldError.value.lastName = true }
222+
if(!email.value) { fieldError.value.email = true }
223+
if(!organization.value) { fieldError.value.organization = true }
224+
if(!organization.value) { fieldError.value.organization = true }
225+
if(!country.value) { fieldError.value.country = true }
222226
}
223227
</script>
224228

@@ -256,6 +260,11 @@ const submitForm = async () => {
256260
}
257261
// //////////////////////////////////////////////////////////////////////// Form
258262
//---------------------------------------------------------------------- General
263+
.signup-form {
264+
display: flex;
265+
flex-direction: column;
266+
}
267+
259268
.form-field {
260269
border: var(--brand-color) 1px solid;
261270
border-radius: toRem(5);
@@ -268,14 +277,12 @@ const submitForm = async () => {
268277
border-color: var(--error);
269278
}
270279
}
271-
272280
.message {
273281
position: absolute;
274282
right: 0;
275283
bottom: -1.3rem;
276284
@include formFieldErrorMessage;
277285
}
278-
279286
.error {
280287
color: var(--error);
281288
}
@@ -287,8 +294,26 @@ const submitForm = async () => {
287294
}
288295
289296
.submit-button {
290-
297+
align-self: flex-end;
298+
&.submitted {
299+
filter: drop-shadow(0px 2px 14px rgba(203, 221, 187, 0.32));
300+
:deep(.fill-path) {
301+
opacity: 1;
302+
fill: var(--brand-color);
303+
}
304+
:deep(.stroke-path) {
305+
stroke: var(--brand-color);
306+
}
307+
&::before {
308+
border-color: var(--brand-color);
309+
background-color: var(--brand-color);
310+
}
311+
:deep(.button-content) {
312+
color: var(--background-color);
313+
}
314+
}
291315
}
316+
292317
//----------------------------------------------------------------- Input Fields
293318
.name-fields {
294319
display: flex;
@@ -302,6 +327,7 @@ const submitForm = async () => {
302327
303328
.input-field {
304329
@include formFieldText;
330+
color: var(--primary-text-color);
305331
width: 100%;
306332
&::placeholder {
307333
@include formFieldPlaceholder;
@@ -310,10 +336,6 @@ const submitForm = async () => {
310336
}
311337
312338
//-------------------------------------------------------------- Dropdown Fields
313-
// .dropdown-field {
314-
// padding: 0;
315-
// }
316-
317339
.toggle-button {
318340
display: flex;
319341
align-items: center;
@@ -326,9 +348,9 @@ const submitForm = async () => {
326348
padding-bottom: toRem(4);
327349
}
328350
}
329-
330351
.toggle-button-label {
331352
@include formFieldPlaceholder;
353+
color: var(--primary-text-color);
332354
&.selected {
333355
@include formFieldText;
334356
}
@@ -346,7 +368,6 @@ const submitForm = async () => {
346368
border-bottom-left-radius: toRem(5);
347369
border-bottom-right-radius: toRem(5);
348370
}
349-
350371
.option {
351372
@include formFieldPlaceholder;
352373
cursor: pointer;
@@ -357,5 +378,4 @@ const submitForm = async () => {
357378
color: var(--background-color);
358379
}
359380
}
360-
361381
</style>

0 commit comments

Comments
 (0)