mainmatter/playbook

Add contact form to /contact page

Opened this issue · 0 comments

In order to make it easier for people to reach out to us, we want to add a contact form to the existing /contact page. That way people can send messages directly from the site without having to leave their browser.

74815454-892d4080-52f9-11ea-8eda-8f67df295851

The form has 3 fields for name, email and message and a send button. Once the message has been sent, the complete form is replaced by a confirmation text (along with the option of sending another message):

Bildschirmfoto 2021-11-22 um 14 15 48

The form has states for success, sending and error (see linked designs). The only field that is required to be filled in is the email which can be validated using HTML5 form validation. We send the email via an AWS Lambda function that is already running (see API documentation below).

TODOs

  • add a new loading state for the <Button> component that prevents clicks on the button while active and changes the button's visual appearance (see designs below)
  • add a new <ContactForm> component that implements the form with inputs for name (input[type="text"]), email(input[type="email"]), and message(textarea), as well as a submit button
    • while the form is submitting, enable the <Button> component's loading state and disable all fields
    • once the form has submitted successfully, show the success message instead of the input elements (see designs below)
      • when clicking the button for sending another message in the success message, switch the component back to its original state to show the input elements instead of the success message (reset all previously captured values so the fields are cleared)
    • if the form fails to submit, show the error state (see designs below)
    • disable submission of the form when the user's browser is offline (and re-enable when it comes back online):
      • in the component's constructor, register event handlers for the window's "online" and "offline" events and enable/disable submission of the form accordingly (leaving the input elements active)
      • remove the event handlers when the component is destroyed to avoid memory leaks (using the willDestroy method)
  • add the component to the /contact page

Resources