Skip to content

Commit 05204f3

Browse files
committedSep 8, 2023
feat: submit button functionality + styling
1 parent 883a88d commit 05204f3

File tree

2 files changed

+85
-24
lines changed

2 files changed

+85
-24
lines changed
 

‎components/subfooter-form.vue

+82-24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="subfooter-form">
3-
<div class="inner-content form-field-container">
3+
<div :class="['form-field-container', { error: fieldError}]">
44

55
<div class="detail-wrapper">
66
<svg
77
width="400"
8-
:viewBox="`0 0 400 ${detailHeight}`"
8+
viewBox="0 0 400 41"
99
fill="none"
1010
xmlns="http://www.w3.org/2000/svg"
1111
class="detail">
@@ -23,23 +23,23 @@
2323
class="email"
2424
:placeholder="placeholder"
2525
type="email"
26-
required="true" />
27-
28-
<!-- @input="updateInputValue($event.target.value, 'organization')" /> -->
26+
required="true"
27+
@input="updateValue($event.target.value)" />
2928
</div>
3029
</div>
3130

3231
<ButtonCta
3332
:class="['submit-button', { submitted: formSubmitted }]"
34-
theme="secondary">
35-
<!-- @clicked="submitForm"> -->
33+
theme="secondary"
34+
@clicked="submitForm">
3635
<span class="button-label"> {{ buttonText }} </span>
3736
</ButtonCta>
3837

3938
</div>
4039
</template>
4140

4241
<script setup>
42+
const SINGULARITY_DEMO_SIGNUPS_TOKEN = import.meta.env.VITE_AIRTABLE_SINGULARITY_DEMO_TOKEN
4343
// ======================================================================= Props
4444
const props = defineProps({
4545
form: {
@@ -54,6 +54,10 @@ const props = defineProps({
5454
}
5555
})
5656
57+
// ======================================================================== Data
58+
const formSubmitted = ref(false)
59+
const fieldError = ref(false)
60+
const field = ref(false)
5761
// ==================================================================== Computed
5862
const path = computed(() => {
5963
if (props.variant === 'large') {
@@ -69,6 +73,42 @@ const placeholder = computed(() => { return props.form.placeholder })
6973
7074
const buttonText = computed(() => { return props.form.submit_button_text })
7175
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+
72112
</script>
73113

74114
<style lang="scss" scoped>
@@ -77,22 +117,8 @@ const buttonText = computed(() => { return props.form.submit_button_text })
77117
display: flex;
78118
justify-content: space-between;
79119
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;
96122
}
97123
}
98124
@@ -144,6 +170,26 @@ const buttonText = computed(() => { return props.form.submit_button_text })
144170
border-bottom-right-radius: toRem(5);
145171
@include transitionDefault;
146172
}
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+
}
147193
}
148194
149195
.field-email {
@@ -160,5 +206,17 @@ const buttonText = computed(() => { return props.form.submit_button_text })
160206
}
161207
162208
// /////////////////////////////////////////////////////////////// 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+
}
164222
</style>

‎public/images/checkmark.svg

+3
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.