diff --git a/docs/src/components/FeedbackForm/FeedbackForm.module.css b/docs/src/components/FeedbackForm/FeedbackForm.module.css new file mode 100644 index 0000000000..97ddf07440 --- /dev/null +++ b/docs/src/components/FeedbackForm/FeedbackForm.module.css @@ -0,0 +1,57 @@ +.submitMessage{ + @apply mt-5 mb-10 text-seriousBlack; +} + +.feedbackForm { + @apply mb-5 text-seriousBlack; +} + +.feedbackForm p { + @apply text-lg; +} + +.submit { + @apply font-bold float-right py-1 px-3 mx-1 rounded-lg; +} + +.submit:hover { + @apply bg-whiteIce; +} + +.feedbackForm label { + @apply pr-2; +} + +.formText { + @apply w-full p-4 rounded-md shadow-lg my-4; +} + +.formRadio { + @apply my-5 text-seriousBlack; +} + +.formRadio label + label { + @apply cursor-pointer relative; +} + +.formRadio input[type='radio'] { + @apply hidden absolute; +} + +.formRadio input[type='radio'] + span { + @apply text-gray-400 p-2 rounded-full; + transition: all 0.4s; + -webkit-transition: all 0.4s; +} + +.yes input[type='radio']:checked + span { + @apply text-blue-600; +} + +.no input[type='radio']:checked + span { + @apply text-red-600; +} + +.formRadio input[type='radio']:hover + span { + @apply opacity-60; +} diff --git a/docs/src/components/FeedbackForm/FeedbackForm.tsx b/docs/src/components/FeedbackForm/FeedbackForm.tsx new file mode 100644 index 0000000000..430f14f510 --- /dev/null +++ b/docs/src/components/FeedbackForm/FeedbackForm.tsx @@ -0,0 +1,160 @@ +import React, { useState } from 'react' +import { render } from 'react-dom' +import styles from './FeedbackForm.module.css' + +class FeedbackForm extends React.Component { + constructor(props) { + super(props) + this.state = { + message: '', + helpful: '', + showForm: false, + sendingMessage: false, + messageSent: false, + messageError: false, + } + } + + handleChange = (event) => { + this.setState({ [event.target.name]: event.target.value }) + this.setState({ + showForm: true, + }) + } + + handleSubmit = async (e) => { + e.preventDefault() + this.setState({ + sendingMessage: true, + }) + this.sendMessage() + } + + handleReturnButton = () => { + this.setState({ + showForm: false, + messageSent: false, + messageError: false, + }) + } + + sendMessage = () => { + const apiUrl = + 'https://hooks.zapier.com/hooks/catch/10752880/b1pm58m/?message=' + + this.state.message + + '×tamp=' + + new Date().toLocaleString() + + '&url=' + + document.URL + + '&helpful=' + + this.state.helpful + + async function myFetch() { + await fetch(apiUrl, { + method: 'POST', + }) + } + + myFetch() + .then(() => { + this.setState({ + messageSent: true, + sendingMessage: false, + message: '', + helpful: '', + }) + }) + .catch((err) => { + console.log(err) + this.setState({ + messageError: true, + sendingMessage: false, + }) + }) + } + + returnButton = () => ( + + ) + + render() { + if (this.state.sendingMessage) { + return
Sending...
+ } + + if (this.state.messageSent) { + return ( + +
+

Thank you!

+

We appreciate your feedback.

+ {this.returnButton()} +
+
+ ) + } + + if (this.state.messageError) { + return ( + +
+

Sorry, an error ocurred.

+ {this.returnButton()} +
+
+ ) + } + + return ( + +
+ + + +
+ + {this.state.showForm === true && ( +
+

Additional feedback

+
+