1
1
<template >
2
2
<div class =" subfooter-form" >
3
- <div class =" inner-content form-field-container" >
3
+ <div : class =" [' form-field-container', { error: fieldError}] " >
4
4
5
5
<div class =" detail-wrapper" >
6
6
<svg
7
7
width =" 400"
8
- : viewBox =" ` 0 0 400 ${detailHeight}` "
8
+ viewBox =" 0 0 400 41 "
9
9
fill =" none"
10
10
xmlns =" http://www.w3.org/2000/svg"
11
11
class =" detail" >
23
23
class =" email"
24
24
:placeholder =" placeholder"
25
25
type =" email"
26
- required =" true" />
27
-
28
- <!-- @input="updateInputValue($event.target.value, 'organization')" /> -->
26
+ required =" true"
27
+ @input =" updateValue($event.target.value)" />
29
28
</div >
30
29
</div >
31
30
32
31
<ButtonCta
33
32
:class =" ['submit-button', { submitted: formSubmitted }]"
34
- theme =" secondary" >
35
- <!-- @clicked="submitForm"> -- >
33
+ theme =" secondary"
34
+ @clicked =" submitForm" >
36
35
<span class =" button-label" > {{ buttonText }} </span >
37
36
</ButtonCta >
38
37
39
38
</div >
40
39
</template >
41
40
42
41
<script setup>
42
+ const SINGULARITY_DEMO_SIGNUPS_TOKEN = import .meta.env.VITE_AIRTABLE_SINGULARITY_DEMO_TOKEN
43
43
// ======================================================================= Props
44
44
const props = defineProps ({
45
45
form: {
@@ -54,6 +54,10 @@ const props = defineProps({
54
54
}
55
55
})
56
56
57
+ // ======================================================================== Data
58
+ const formSubmitted = ref (false )
59
+ const fieldError = ref (false )
60
+ const field = ref (false )
57
61
// ==================================================================== Computed
58
62
const path = computed (() => {
59
63
if (props .variant === ' large' ) {
@@ -69,6 +73,42 @@ const placeholder = computed(() => { return props.form.placeholder })
69
73
70
74
const buttonText = computed (() => { return props .form .submit_button_text })
71
75
76
+ // ===================================================================== Methods
77
+ /**
78
+ * @method updateValue
79
+ */
80
+ const updateValue = (val ) => {
81
+ if (fieldError) { fieldError .value = false }
82
+ field .value = val
83
+ }
84
+ /**
85
+ * @method submitForm
86
+ */
87
+ const submitForm = async () => {
88
+ if (field .value ) {
89
+ const body = {
90
+ records: [
91
+ {
92
+ fields: {
93
+ email: field .value
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ const headers = {
99
+ ' Content-Type' : ' application/json' ,
100
+ ' Authorization' : ` Bearer ${ SINGULARITY_DEMO_SIGNUPS_TOKEN } `
101
+ }
102
+ const res = await $fetch (' https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblSB1NYasWQIDGlp' , {
103
+ method: ' POST' ,
104
+ body,
105
+ headers
106
+ })
107
+ if (res) { formSubmitted .value = true ; return }
108
+ }
109
+ if (! field .value ) { fieldError .value = true }
110
+ }
111
+
72
112
</script >
73
113
74
114
<style lang="scss" scoped>
@@ -77,22 +117,8 @@ const buttonText = computed(() => { return props.form.submit_button_text })
77
117
display : flex ;
78
118
justify-content : space-between ;
79
119
white-space : nowrap ;
80
- & :not (.disabled ) {
81
- & :hover {
82
- .stroke-path {
83
- stroke : $chardonnay ;
84
- }
85
- .form-field-container {
86
- & ::before {
87
- border-top-color : $chardonnay ;
88
- border-right-color : $chardonnay ;
89
- border-bottom-color : $chardonnay ;
90
- }
91
- }
92
- }
93
- & :focus-visible {
94
- @include focusBoxShadow ;
95
- }
120
+ & :focus-visible {
121
+ @include focusBoxShadow ;
96
122
}
97
123
}
98
124
@@ -144,6 +170,26 @@ const buttonText = computed(() => { return props.form.submit_button_text })
144
170
border-bottom-right-radius : toRem (5 );
145
171
@include transitionDefault ;
146
172
}
173
+ & :hover {
174
+ .stroke-path {
175
+ stroke : $chardonnay ;
176
+ }
177
+ & ::before {
178
+ border-top-color : $chardonnay ;
179
+ border-right-color : $chardonnay ;
180
+ border-bottom-color : $chardonnay ;
181
+ }
182
+ }
183
+ & .error {
184
+ .stroke-path {
185
+ stroke : $burntSienna ;
186
+ }
187
+ & ::before {
188
+ border-top-color : $burntSienna ;
189
+ border-right-color : $burntSienna ;
190
+ border-bottom-color : $burntSienna ;
191
+ }
192
+ }
147
193
}
148
194
149
195
.field-email {
@@ -160,5 +206,17 @@ const buttonText = computed(() => { return props.form.submit_button_text })
160
206
}
161
207
162
208
// /////////////////////////////////////////////////////////////// Submit Button
163
-
209
+ .submit-button.submitted {
210
+ :deep (.button-label ) {
211
+ color : $sageGreen ;
212
+ }
213
+ :deep(.button-content ) {
214
+ & ::after {
215
+ color : transparent !important ;
216
+ background-image : url (' /images/checkmark.svg' );
217
+ background-position : center ;
218
+ background-repeat : no-repeat ;
219
+ }
220
+ }
221
+ }
164
222
</style >
0 commit comments