-
Notifications
You must be signed in to change notification settings - Fork 38
first update #17
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
base: main
Are you sure you want to change the base?
first update #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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@]+$/; | ||
| if (email === "") { | ||
| emailInput.style.borderColor = "#ccc"; | ||
| emailInput.style.backgroundColor = "white"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
| } | ||
| }); | ||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See how in this id selector and also in 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| 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> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. notice that you have a |
||
|
|
||
| </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> | ||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
emailPatternfor clarity