Skip to content

Commit 71c7f99

Browse files
gupta-utkarshdeshraj
authored andcommitted
Add contact us feature (Cloud-CV#28)
1 parent 0b1e40c commit 71c7f99

File tree

8 files changed

+148
-4
lines changed

8 files changed

+148
-4
lines changed

frontend/src/components/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const App = props => {
1919
<Route path="/news" component={HomePageComponent} />
2020
<Route path="/team" component={TeamPageComponent} />
2121
<Route path="/projects" component={ProjectPageComponent} />
22+
<Route path="/contact-us" component={HomePageComponent} />
2223
<Route component={PageNotFoundHandler} />
2324
</Switch>
2425
</main>

frontend/src/components/home/HomeBody.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import HomeAboutUs from "./homeBody/HomeAboutUs";
44
import HomeNews from "./homeBody/HomeNews";
55
import HomeSponsors from "./homeBody/HomeSponsors";
66
import HomeShowcase from "./homeBody/HomeShowcase";
7+
import HomeContactUs from "./homeBody/HomeContactUs";
78
import Button from "../common/Button";
89

910
const HomeBody = props => {
@@ -54,6 +55,7 @@ const HomeBody = props => {
5455
</Link>
5556
</div>
5657
</div>
58+
<HomeContactUs />
5759
</div>
5860
);
5961
};
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React from "react";
2+
import { Link } from "react-router-dom";
3+
import Button from "../../common/Button";
4+
import axios from "axios";
5+
const AJAX_ROOT = process.env.AJAX_ROOT;
6+
7+
const HomeContactUs = props => {
8+
const sendResponse = event => {
9+
event.preventDefault();
10+
let formElement = document.getElementById("contact-us-form");
11+
let formData = new FormData(formElement);
12+
axios({
13+
method: "post",
14+
url: `${process.env.AJAX_ROOT}/api/web/contact/`,
15+
data: formData
16+
}).then(response => {
17+
if (response.status === 201) {
18+
formElement.reset();
19+
document.getElementById("cv-home-form-success").innerHTML =
20+
response.data.message;
21+
}
22+
});
23+
};
24+
const CONTACT_US_TITLE = "Contact Us";
25+
return (
26+
<div className="cv-home-contact-us cv-container" id="contact-us">
27+
<h1 className="cv-home-showcase-heading">
28+
{CONTACT_US_TITLE}
29+
</h1>
30+
<form
31+
className="cv-home-contact-form"
32+
encType="multipart/form-data"
33+
action="http://example.com/cgiscript.pl"
34+
method="post"
35+
id="contact-us-form"
36+
onSubmit={sendResponse}
37+
>
38+
<section className="cv-home-contact-form-elements">
39+
<input
40+
className="cv-input-text"
41+
type="text"
42+
name="name"
43+
placeholder="Name"
44+
required
45+
/>
46+
<br />
47+
<input
48+
className="cv-input-text"
49+
type="email"
50+
name="email"
51+
placeholder="Email"
52+
required
53+
/>
54+
<br />
55+
<input
56+
className="cv-input-text"
57+
type="text"
58+
name="message"
59+
placeholder="Message/Query"
60+
required
61+
/>
62+
<br />
63+
<label className="cv-input-label" htmlFor="image">
64+
Any screenshot/image you would like to add :
65+
</label>
66+
<input className="cv-input-file" type="file" name="image" />
67+
</section>
68+
<input
69+
className="cv-button cv-button-dark"
70+
type="submit"
71+
name="submit"
72+
value="Submit"
73+
/>
74+
<br />
75+
<span className="cv-home-form-success" id="cv-home-form-success" />
76+
</form>
77+
</div>
78+
);
79+
};
80+
81+
export default HomeContactUs;

frontend/src/components/navbar/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ class Navbar extends Component {
5050
firstPath = this.props.location.pathname.substr(1);
5151
}
5252
let projectActive = firstPath === "projects";
53-
let listItems = ["", "Projects", "News", "GSoC", "Team", "Contribute"];
53+
let listItems = [
54+
"",
55+
"Projects",
56+
"News",
57+
"GSoC",
58+
"Team",
59+
"Contribute",
60+
"Contact Us"
61+
];
5462
listItems = listItems.map((path, index) => {
5563
let active = path.toLowerCase() === firstPath;
64+
let formattedPath = path.toLowerCase().replace(/ /g, "-");
5665
return (
5766
<NavbarItem active={active} key={path}>
58-
<Link to={`\/${path.toLowerCase()}`}>
67+
<Link to={`\/${formattedPath}`}>
5968
{path === "" ? "Home" : path}
6069
</Link>
6170
</NavbarItem>

frontend/src/styles/partials/_elements.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
cursor: pointer;
2626
font-family: $heading-font-family;
2727
padding: 1.7*$gutter-width 4.5*$gutter-width;
28+
transition: all 0.2s linear;
2829
}
2930

3031
.cv-button-light {
@@ -34,6 +35,10 @@
3435
.cv-button-dark {
3536
background: linear-gradient(45deg, $heading-color, $heading-color 30%, $secondary-color 70%, $secondary-color);
3637
color: $white;
38+
39+
&:hover {
40+
background: linear-gradient(45deg, $heading-color, $heading-color 50%, $secondary-color 90%, $secondary-color);
41+
}
3742
}
3843

3944
.cv-button-small {
@@ -80,3 +85,25 @@
8085
}
8186
}
8287

88+
/********FORM ELEMENTS********/
89+
90+
.cv-input-text {
91+
margin: 3 * $gutter-width 0 0 0;
92+
padding: 0 0 1 * $gutter-width 0;
93+
border-bottom: 2px solid $secondary-color;
94+
transition: all 0.3s linear;
95+
width: 350px;
96+
97+
&:focus {
98+
border-bottom: 2px solid $heading-color;
99+
}
100+
}
101+
102+
.cv-input-label {
103+
display: block;
104+
padding: 4 * $gutter-width 0 0 0;
105+
}
106+
107+
.cv-input-file {
108+
padding: $gutter-width 0 0 0;
109+
}

frontend/src/styles/partials/_home.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,23 @@
275275
min-width: 70px;
276276
}
277277

278+
.cv-home-contact-us {
279+
padding: 8 * $gutter-width 0 0 0;
280+
}
281+
282+
.cv-home-contact-form {
283+
margin: 3 * $gutter-width 0;
284+
}
285+
.cv-home-contact-form-elements {
286+
margin: 5 * $gutter-width 0;
287+
}
288+
289+
.cv-home-form-success {
290+
padding: 2 * $gutter-width 0;
291+
color: $success-color;
292+
display: block;
293+
}
294+
278295
.cv-home-footer {
279296
margin: 0;
280297
padding: 8 * $gutter-width 0 0 0;

frontend/src/styles/partials/_theme.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
* {
22
@include placeholder {
3-
color: $secondary-color;
3+
@include font-size(1.8, 1.2);
4+
color: $primary-color;
45
}
6+
7+
}
8+
9+
input:not(output):-moz-ui-invalid {
10+
box-shadow:none !important;
511
}
612

713
body, input {

frontend/src/styles/partials/_variables.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ $link-color--visited: hsla(271, 68%, 32%, 1);
4343
$white: hsla(0, 0%, 100%, 1);
4444
$black: hsla(0, 0%, 0%, 1);
4545
$shadow-color: hsla(0, 0%, 60%, 0.5);
46-
$deep-shadow-color: rgb(232, 232, 232);
46+
$deep-shadow-color: hsla(0, 0%, 91%, 1);
47+
$success-color: hsla(116, 46%, 49%, 1);
4748
/******MARGINS******/
4849

4950
$gutter-width: 1rem;

0 commit comments

Comments
 (0)