Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarifagowani\front-end-challenge #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
## Headstorm Interview

Welcome to the Headstorm interview challenge! This repository is designed for candidates to [fork and create Pull Requests](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork) with their solutions. There are two types of 'take-home' problems here:

### Challenges
These are domain specific problems that can be submitted individually. You can choose from backend, frontend, databases, or data-science. You can submit a PR for one, many, or all the challenges.

### Interviews
These are language specific interview questions and you can choose the language in which you implement your solution.
## front end challenge
This is my attempt for the front end challenge. I had some issues with reCAPTCHA v3, so I used v2. This was my first time using reCAPTCHA, it may not be perfect.
Would love to hear any feedback you have for me and ways I can improve.
53 changes: 53 additions & 0 deletions contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="favicon.ico">
<link rel="stylesheet" href="./src/style.css">
<script src="scripts.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<title>Contact us</title>
</head>

<body>

<div class="wrapper">
<h1>Contact us</h1>
<div id="error_message"></div>
<form id="contactform" onSubmit="return validation()">
<div class="input_field">
<input type="text" placeholder="Full Name" id="name"></input>
</div>

<div class="input_field">
<input type="text" placeholder="Email" id="email"></input>
</div>

<div class="input_field">
<input type="text" placeholder="Phone number" id="phone"></input>
</div>

<div class="input_field">
<input type="text" placeholder="Subject" id="subject"></input>
</div>

<div class="input_field">
<textarea id="message" placeholder="Message"></textarea>
</div>

<!-- recaptcha on submit -->
<form method="post" onsubmit="return submitUserForm();">
<div class="g-recaptcha" data-sitekey="6LdAFCobAAAAAEFBNa4wo5dUAvw35XJOaUhceCxr" data-callback="verifyCaptcha"></div>
<div id="g-recaptcha-error"></div>
<div class="button">
<input type="submit">
</div>
</form>
</form>
</div>
</body>

</html>
Binary file added favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon.ico
Binary file not shown.
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel = "icon" type="image/png" sizes="32x32" href = "favicon.ico">
<link rel = "stylesheet" href="./src/style.css">
<script src="scripts.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<title>Yellowberry</title>
</head>
<body>
<div class = "logo">
<img src="./src/yellowberryLogo_clear_yellow.png" alt="Yellowberry Logo">
</div>
<div class = "title">
<h1>Yellowberry</h1><br>
</div>

<p class = "paragraph"> Eating better made simple</p>

<ul class="contact">
<a href="contact.html"> Contact Us</a>
</ul>

</body>
</html>
58 changes: 58 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function validation() {
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var phone = document.getElementById("phone").value;
var subject = document.getElementById("subject").value;
var message = document.getElementById("message").value;
var error_message = document.getElementById("error_message");
var text;

error_message.style.padding = "10px";

if(name.length <5) {
text= "Please Enter a Valid Name";
error_message.innerHTML= text;
return false;
}

if(isNaN(phone) || phone.length !=10) {
text= "Please Enter a Valid Number";
error_message.innerHTML= text;
return false;
}

if(email.indexOf("@") == -1 || email.length <6){
text= "Please Enter a Valid Email";
error_message.innerHTML= text;
return false;
}

if(subject.length <6) {
text = "Please Ellaborate";
error_message.innerHTML= text;
return false;
}

if(message.length <= 150) {
text = "Please Enter More Than 150 Characters";
error_message.innerHTML= text;
return false;
}


alert("Form was Submitted Successfully! \n We'll be in touch soon.");
return true;
}

function submitUserForm() {
var response = grecaptcha.getResponse();
if(response.length == 0) {
document.getElementById('g-recaptcha-error').innerHTML = '<span style="color:red;">This field is required.</span>';
return false;
}
return true;
}

function verifyCaptcha() {
document.getElementById('g-recaptcha-error').innerHTML = '';
}
112 changes: 112 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
@import url('https://fonts.googleapis.com/css2?family=Josefin+Slab:wght@100&display=swap');

body {
background: yellow;
}

.logo img {
height: 10em;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
max-width: 350px;
}

.title {
text-align: center;
padding-top: 30px;
}

p {
text-align: center;
color: black;
font-weight: bold;
}

a {
border-radius: 2px;
padding: 7px;
text-transform: uppercase;
top: 50%;
left: 50%;
letter-spacing: 5%;
transform: translate(-50%, -50%);
max-width: 120px;
background-color: lightgray;
display: block;
text-align: center;
position: absolute;
color: black;
font-weight: bold;

}

*{
margin:0;
padding:0;
box-sizing: border-box;
outline: none;
font-family:'Josefin Slab', serif;

}

.wrapper {
position: absolute;
top: 50%;
left: 50%;
letter-spacing: 5%;
transform: translate(-50%, -50%);
max-width: 350px;
width: 100%;
background-color: #ffffff;
padding: 25px;
border-radius: 5px;
}

.wrapper h1 {
text-align: center;
margin-bottom: 20px;
text-transform: uppercase;
letter-spacing: 3px;
color: black;
}

.wrapper .input_field{
margin-bottom: 10px;
}

.wrapper .input_field input[type= "text"],
.wrapper textarea{
width: 100%;
border: 1px solid #e0e0e0e0;
padding: 10px;
}

.wrapper textarea {
height: 110px;
resize: none;
}

.wrapper .button input[type="submit"] {
border: 0;
margin-top: 20px;
padding:10px;
width: 100%;
background: black;
color:white;
text-transform: uppercase;
letter-spacing: 5px;
font-weight: bold;
border-radius: 25px;
cursor: pointer;
}

.wrapper #error_message {
margin-bottom: 20px;
padding: 0;
background: pink;
text-align: center;
font-size: 14px;
transition: all 0.5s ease;
}
Binary file added src/yellowberryLogo_clear_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.