Skip to content
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
Binary file added .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions newsletter-sign-up-with-success-message-main/email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const emailInput = document.getElementById("email");

emailInput.addEventListener("input", function () {
const email = emailInput.value;
const pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually when you have such an ugly regex expression in your code, its important to leave a note and say what is it doing, otherwise if someone else would try to read your code it would be impossible to understand what is it doing unless you send it to some ai

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also call this variable emailPattern for clarity

if (email === "") {
emailInput.style.borderColor = "#ccc";
emailInput.style.backgroundColor = "white";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider having a global constant for these things which might repeat multiple times

having something like `const WHITE = "white" , would make your code look nicer and more readable

return;
}

if (pattern.test(email)) {
emailInput.style.borderColor = "green";
emailInput.style.backgroundColor = "#e6ffe6";
} else {
emailInput.style.borderColor = "red";
emailInput.style.backgroundColor = "#ffe6e6";
}
});

emailInput.addEventListener("blur", function () {
if (emailInput.value.trim() === "") {
emailInput.style.borderColor = "#ccc";
emailInput.style.backgroundColor = "white";
}
});
118 changes: 118 additions & 0 deletions newsletter-sign-up-with-success-message-main/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
@font-face {
font-family:Roboto ;
src: url(./assets/fonts/Roboto-Regular.ttf);
}




body {
background-color: hsl(234, 29%, 20%);
height: 100vh;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Roboto';
}


.container {
display: flex;
background: white;
width: 843px;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually its not recommended to give fixed dimensions to containers, it makes them unresponsive to changes in dimensions, consider controlling the dimensions of the container with vertical and horizontal paddings

height: 592px;
border-radius: 25px;
overflow: hidden;
box-shadow: 0 10px 35px rgba(0,0,0,0.25);
}

#left-side {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how in this id selector and also in #right-side you have given the same centering styles,
I would suggest you styling these with classes instead of ids then you could have a

.flex-center { 
display: flex;
justify-content: center;
align-items: center;
}

this makes you use DO NOT REPEAT YOURSELF principle

display: flex;
flex-direction: column;
justify-content: center;
padding: 50px;
width: 350px;
margin-left:15px;

}

#left-side h1 {
font-size: 50px;
margin-bottom: 20px;
}

#left-side p {
font-size: 14px;
margin-bottom: 20px;
line-height:1.45;
}
#left-side ul {
padding: 0;
margin: 0 0 30px 0;
}

#left-side li {
list-style: none;
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
font-size: 15px;
}

#left-side img {
width: 20px;
}

label {
font-size: 12px;
font-weight: bold;
margin-bottom: 8px;
}

input {
padding: 12px;
border-radius: 8px;
border: 1px solid #ccc;
width: 95%;
font-size: 14px;
margin-bottom: 15px;
transition: 0.3s ease;
}

button {
background-color: hsl(234, 29%, 20%);
color: white;
padding: 14px;
border-radius: 8px;
border: none;
font-size: 14px;
cursor: pointer;
width: 103%;
}

button:hover {
background-color: hsl(4, 100%, 67%);
}


#right-side {
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #ff4664, #ff8f40);
width: 390px;
margin-top: 20px;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

margin-top + margin-bottom = margin vertical

I know you know that but just a reminder :)

margin-bottom: 20px;
margin-right: 20px;
border-radius: 15px;
}

#right-side img {
width: 100%;
height: auto;

}


70 changes: 32 additions & 38 deletions newsletter-sign-up-with-success-message-main/index.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->

<link rel="icon" type="image/png" sizes="32x32" href="./assets/images/favicon-32x32.png">

<title>Frontend Mentor | Newsletter sign-up form with success message</title>

<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
<style>
.attribution { font-size: 11px; text-align: center; }
.attribution a { color: hsl(228, 45%, 44%); }
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asher Pe'er</title>
<link rel="stylesheet" href="index.css">
<link rel="font" href="https://fonts.google.com/specimen/Roboto">
</head>
<body>

<!-- Sign-up form start -->

Stay updated!

Join 60,000+ product managers receiving monthly updates on:

Product discovery and building what matters
Measuring to ensure updates are a success
And much more!

Email address
email@company.com

Subscribe to monthly newsletter

<!-- Sign-up form end -->

<!-- Success message start -->

Thanks for subscribing!
<body>

A confirmation email has been sent to ash@loremcompany.com.
Please open it and click the button inside to confirm your subscription.
<div class="container">
<div id="left-side">
<h1>Stay update!</h1>
<p>
Join 60,000+ product managers receiving monthly updates on:
</p>

<ul>
<li><img src="assets/images/icon-list.svg" alt="">Product discovery and building what matters</li>
<li><img src="assets/images/icon-list.svg" alt="">Measuring to ensure updates are a success</li>
<li> <img src="assets/images/icon-list.svg" alt="">And much more!</li>
</ul>

<label for="email">Email address</label>
<input type="email" id="email" placeholder="email@company.com">

<button type="submit">Subscribe to monthly newsletter</button>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notice that you have a <button type="submit> element but its not wrapped in a <form> so it would behave like a normal button, I would suggest wrapping this in an actual form element which would give you some things which you will have to use JavaScript to get out of the box


</div>

<div id="right-side">
<img src="assets/images/illustration-sign-up-desktop.svg" alt="">
</div>
</div>

Dismiss message

<!-- Success message end -->

<div class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="#">Your Name Here</a>.
</div>
<script src="email.js"></script>
</body>

</html>