├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── index.js ├── firebase.js ├── App.js ├── app.css └── components │ └── Contact.js ├── README.md ├── .gitignore └── package.json /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanjairaj7/React-contact-form/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanjairaj7/React-contact-form/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanjairaj7/React-contact-form/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | 5 | ReactDOM.render(, document.getElementById("root")); 6 | -------------------------------------------------------------------------------- /src/firebase.js: -------------------------------------------------------------------------------- 1 | import firebase from "firebase"; 2 | 3 | var firebaseApp = firebase.initializeApp({ 4 | // Your firebase credentials 5 | }); 6 | 7 | var db = firebaseApp.firestore(); 8 | 9 | export { db }; 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a Contact form built using React.js and also accepts the front end details on the backend using Firebase Cloud firestore. 2 | 3 | You could clone and contribute to it. 4 | 5 | Please change the credentails of your Firebase project in src/firebase.js 6 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Contact from "./components/Contact"; 3 | import "./app.css"; 4 | 5 | function App() { 6 | return ( 7 |
8 | 9 |
10 | ); 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-boiler", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "firebase": "^7.17.1", 10 | "react": "^16.13.1", 11 | "react-dom": "^16.13.1", 12 | "react-scripts": "3.4.1" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": "react-app" 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/app.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"); 2 | 3 | * { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | } 8 | 9 | body { 10 | background-color: rgb(248, 246, 253); 11 | } 12 | 13 | body, 14 | input, 15 | textarea, 16 | button { 17 | font-family: "Inter", sans-serif; 18 | } 19 | 20 | .app { 21 | width: 400px; 22 | margin: 0 auto; 23 | height: 100vh; 24 | } 25 | 26 | /* Contact.js */ 27 | .form { 28 | height: 100vh; 29 | display: flex; 30 | flex-direction: column; 31 | justify-content: center; 32 | } 33 | 34 | .form > h1 { 35 | margin-bottom: 30px; 36 | } 37 | 38 | .form > input, 39 | textarea { 40 | padding: 20px; 41 | border-radius: 3px; 42 | /* box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.137); */ 43 | margin-bottom: 20px; 44 | border: 1px solid lightgray; 45 | /* border: none; */ 46 | background: #fff; 47 | font-size: 16px; 48 | color: rgb(0, 0, 32); 49 | outline: none; 50 | } 51 | 52 | .form > input:focus, 53 | textarea:focus { 54 | border: 1px solid rgb(0, 0, 196); 55 | } 56 | 57 | .form > textarea { 58 | height: 150px; 59 | max-width: 400px; 60 | min-height: 100px; 61 | } 62 | 63 | .form > label { 64 | padding-bottom: 10px; 65 | color: rgb(0, 0, 32); 66 | font-weight: bold; 67 | } 68 | 69 | .form > button { 70 | padding: 20px; 71 | border: none; 72 | background-color: rgb(2, 2, 110); 73 | font-weight: 500; 74 | font-size: 20px; 75 | border-radius: 3px; 76 | color: #fff; 77 | cursor: pointer; 78 | transition: 0.2s ease-in-out; 79 | margin-top: 10px; 80 | } 81 | 82 | .form > button:hover { 83 | background-color: rgb(0, 0, 196); 84 | } 85 | -------------------------------------------------------------------------------- /src/components/Contact.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import "../app.css"; 3 | import { db } from "../firebase"; 4 | 5 | const Contact = () => { 6 | const [name, setName] = useState(""); 7 | const [email, setEmail] = useState(""); 8 | const [message, setMessage] = useState(""); 9 | 10 | const [loader, setLoader] = useState(false); 11 | 12 | const handleSubmit = (e) => { 13 | e.preventDefault(); 14 | setLoader(true); 15 | 16 | db.collection("contacts") 17 | .add({ 18 | name: name, 19 | email: email, 20 | message: message, 21 | }) 22 | .then(() => { 23 | setLoader(false); 24 | alert("Your message has been submitted👍"); 25 | }) 26 | .catch((error) => { 27 | alert(error.message); 28 | setLoader(false); 29 | }); 30 | 31 | setName(""); 32 | setEmail(""); 33 | setMessage(""); 34 | }; 35 | 36 | return ( 37 |
38 |

Contact Us 🤳

39 | 40 | 41 | setName(e.target.value)} 45 | /> 46 | 47 | 48 | setEmail(e.target.value)} 52 | /> 53 | 54 | 55 | 60 | 61 | 67 |
68 | ); 69 | }; 70 | 71 | export default Contact; 72 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | --------------------------------------------------------------------------------