Add email form from https://github.com/chaoocharles/react-email.js
This commit is contained in:
parent
9a2212f93e
commit
40a9df4c97
|
@ -19,3 +19,10 @@ To do:
|
|||
- Add a splash of colour 🤷♂️
|
||||
- Get proper artwork into database.
|
||||
- Modify about page with proper info, info dependendant on what is requested.
|
||||
|
||||
|
||||
OTHER NOTES:
|
||||
|
||||
This project uses an email react form that is on the contact form, created by "Chaoo Charles"
|
||||
https://github.com/chaoocharles/react-email.js
|
||||
https://www.youtube.com/watch?v=bMq2riFCF90
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"name": "hello",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@emailjs/browser": "^3.12.1",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
|
@ -2356,6 +2357,14 @@
|
|||
"postcss-selector-parser": "^6.0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@emailjs/browser": {
|
||||
"version": "3.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@emailjs/browser/-/browser-3.12.1.tgz",
|
||||
"integrity": "sha512-C5nK07CgSCFx3onsuRt/ZaaMvIi0T3SHHanM7fKozjSvbZu+OjHHP9W608fYpic0OavF7yIlfy4+lRDO33JdbA==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emotion/is-prop-valid": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz",
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@emailjs/browser": "^3.12.1",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
|
||||
import React, { useRef } from "react";
|
||||
import emailjs from "@emailjs/browser";
|
||||
import styled from "styled-components";
|
||||
|
||||
const Contact = () => {
|
||||
const form = useRef();
|
||||
|
||||
|
||||
|
||||
const sendEmail = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
emailjs
|
||||
.sendForm(
|
||||
"replace with service id",
|
||||
"replace with template id",
|
||||
form.current,
|
||||
"replace with user id"
|
||||
)
|
||||
.then(
|
||||
(result) => {
|
||||
console.log(result.text);
|
||||
console.log("message sent");
|
||||
},
|
||||
(error) => {
|
||||
console.log(error.text);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledContactForm>
|
||||
<form ref={form} onSubmit={sendEmail}>
|
||||
<label>Name</label>
|
||||
<input type="text" name="user_name" />
|
||||
<label>Email</label>
|
||||
<input type="email" name="user_email" />
|
||||
<label>Message</label>
|
||||
<textarea name="message" />
|
||||
<input type="submit" value="Send" />
|
||||
</form>
|
||||
</StyledContactForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default Contact;
|
||||
|
||||
// Styles
|
||||
const StyledContactForm = styled.div`
|
||||
width: 400px;
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
height: 35px;
|
||||
padding: 7px;
|
||||
outline: none;
|
||||
border-radius: 5px;
|
||||
border: 1px solid rgb(220, 220, 220);
|
||||
|
||||
&:focus {
|
||||
border: 2px solid rgba(0, 206, 158, 1);
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
width: 100%;
|
||||
max-height: 100px;
|
||||
min-height: 100px;
|
||||
padding: 7px;
|
||||
outline: none;
|
||||
border-radius: 5px;
|
||||
border: 1px solid rgb(220, 220, 220);
|
||||
|
||||
&:focus {
|
||||
border: 2px solid rgba(0, 206, 158, 1);
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
margin-top: 2rem;
|
||||
cursor: pointer;
|
||||
background: rgb(249, 105, 14);
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
`;
|
|
@ -1,3 +1,6 @@
|
|||
// import required component
|
||||
import Contact from "./components/EmailContactForm"
|
||||
|
||||
export function Contact ( props ) {
|
||||
return ( <h1>{props.greeting} </h1>)
|
||||
}
|
Loading…
Reference in New Issue