-
Notifications
You must be signed in to change notification settings - Fork 38
Pro1 #31
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?
Pro1 #31
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,123 @@ | ||
| body { | ||
| height: 100vh; | ||
| margin: 0; | ||
| padding: 0; | ||
| background-color: #2c2e47; | ||
| font-family: Arial, sans-serif; | ||
| } | ||
|
|
||
| .maincontainer { | ||
| margin-top: 32%; | ||
|
Member
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. Will this be responsive? |
||
| height: 100vh; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .center { | ||
| padding: 20px; | ||
| width: 750px; | ||
| background: white; | ||
| border-radius: 20px; | ||
| display: flex; | ||
| box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); | ||
|
Member
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. Same comment about the color in here and in every other place |
||
| overflow: hidden; | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| #successCard { | ||
| display: none; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| width: 381px; | ||
| } | ||
|
|
||
| .text { | ||
| flex: 1; | ||
| padding: 40px; | ||
| } | ||
|
|
||
| .text h1 { | ||
|
Member
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. You could give the |
||
| margin-top: 0; | ||
| font-size: 32px; | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .text p { | ||
| color: #555; | ||
| margin-bottom: 15px; | ||
| } | ||
|
|
||
| .text ul { | ||
| list-style: none; | ||
| padding: 0; | ||
| margin-bottom: 30px; | ||
| } | ||
|
|
||
| .text ul li { | ||
| margin-bottom: 10px; | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 10px; | ||
| } | ||
|
|
||
| .text label { | ||
| font-size: 12px; | ||
| font-weight: bold; | ||
| display: block; | ||
| margin-bottom: 6px; | ||
| } | ||
|
|
||
| .text input { | ||
| width: 100%; | ||
| padding: 12px; | ||
| margin-bottom: 20px; | ||
| border-radius: 6px; | ||
| border: 1px solid #ccc; | ||
| font-size: 14px; | ||
| } | ||
|
|
||
| #subscribeBtn { | ||
| width: 110%; | ||
|
Member
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. Can you use class instead? id will override all of the other css rules made by class. |
||
| padding: 14px; | ||
| border-radius: 6px; | ||
| border: none; | ||
| background-color: #1d223a; | ||
| color: white; | ||
| font-size: 14px; | ||
| cursor: pointer; | ||
| font-weight: bold; | ||
| transition: 0.3s ease; | ||
| } | ||
|
|
||
| #subscribeBtn.valid { | ||
| background: linear-gradient(to right, #ff6f91, #ff9671); | ||
| } | ||
|
|
||
| #dismissBtn:hover { | ||
| opacity: 0.9; | ||
| } | ||
|
|
||
| #errorMsg { | ||
| display: none; | ||
| color: red; | ||
| font-size: 9px; | ||
| margin-bottom: 5px; | ||
| text-align: right; | ||
| margin-right: -23px; | ||
| } | ||
|
|
||
| #dismissBtn { | ||
| width: 110%; | ||
| padding: 14px; | ||
| border-radius: 6px; | ||
| border: none; | ||
| background-color: #1d223a; | ||
| color: white; | ||
| font-size: 14px; | ||
| cursor: pointer; | ||
| font-weight: bold; | ||
| margin-top: 20px; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,61 @@ | ||
| <!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 --> | ||
|
|
||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <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> | ||
| <link rel="stylesheet" href="index.css"> | ||
| <title>Newsletter Sign-up</title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| <!-- Sign-up form start --> | ||
| <div class="maincontainer"> | ||
|
Member
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. You could use the |
||
|
|
||
| Stay updated! | ||
| <div id="formCard" class="center"> | ||
|
Member
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. Why do you need both id and class? |
||
|
|
||
| Join 60,000+ product managers receiving monthly updates on: | ||
| <div class="text"> | ||
| <h1>Stay updated!</h1> | ||
| <p>Join 60,000+ product managers receiving monthly updates on:</p> | ||
|
|
||
| Product discovery and building what matters | ||
| Measuring to ensure updates are a success | ||
| And much more! | ||
| <ul> | ||
| <li><img src="./assets/images/icon-list.svg" class="list-icon"> Product discovery and building what matters</li> | ||
|
Member
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. You should add alt attribute for accessibility |
||
| <li><img src="./assets/images/icon-list.svg" class="list-icon"> Measuring to ensure updates are a success</li> | ||
| <li><img src="./assets/images/icon-list.svg" class="list-icon"> And much more!</li> | ||
| </ul> | ||
|
|
||
| Email address | ||
| email@company.com | ||
| <label>Email address</label> | ||
| <p id="errorMsg">Valid email required</p> | ||
| <input id="emailInput" type="email" placeholder="email@company.com"> | ||
|
|
||
| Subscribe to monthly newsletter | ||
| <button id="subscribeBtn">Subscribe to monthly newsletter</button> | ||
| </div> | ||
|
|
||
| <!-- Sign-up form end --> | ||
| <div class="imager"> | ||
| <img src="./assets/images/illustration-sign-up-desktop.svg" alt="Sign Up Illustration"> | ||
|
Member
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. This is good usage of alt |
||
| </div> | ||
|
|
||
| <!-- Success message start --> | ||
| </div> | ||
|
|
||
| Thanks for subscribing! | ||
| <div id="successCard" class="center"> | ||
| <div class="success-content"> | ||
| <img src="./assets/images/icon-success.svg" class="success-icon" alt=""> | ||
|
|
||
| A confirmation email has been sent to ash@loremcompany.com. | ||
| Please open it and click the button inside to confirm your subscription. | ||
| <h1>Thanks for subscribing!</h1> | ||
|
|
||
| Dismiss message | ||
| <p> | ||
| A confirmation email has been sent. | ||
| Please open it and click the button inside to confirm your subscription. | ||
| </p> | ||
|
|
||
| <button id="dismissBtn">Dismiss message</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- 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="index.js"></script> | ||
| </body> | ||
| </html> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| const input = document.getElementById("emailInput"); | ||
| const error = document.getElementById("errorMsg"); | ||
| const btn = document.getElementById("subscribeBtn"); | ||
| const formCard = document.querySelector("#formCard"); | ||
| const successCard = document.querySelector("#successCard"); | ||
|
|
||
| input.addEventListener("input", function () { | ||
| const email = input.value; | ||
|
|
||
| if (!email.includes("@")) { | ||
| btn.classList.remove("valid"); | ||
| return; | ||
| } | ||
|
|
||
| const [, domain] = email.split("@"); | ||
|
Member
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. What are you doing in here? how is this syntax called? and why are you doing it only to access the second array elemnt? You could access the array that split is returning |
||
|
|
||
| if (domain === "gmail.com" || domain === "colman.com") { | ||
|
Member
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. Hardcoded strings should be saved inside constants |
||
| btn.classList.add("valid"); | ||
| } else { | ||
|
Member
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. You could add return here to avoid the else |
||
| btn.classList.remove("valid"); | ||
| } | ||
| }); | ||
|
|
||
| btn.onclick = function () { | ||
|
Member
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. Why do you need to do it like this? you are already using even listeners, dont override the default on click function |
||
| const email = input.value; | ||
|
|
||
| if (!email.includes("@")) { | ||
| error.style.display = "block"; | ||
|
Member
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. Never style stuff from your js, use it via classes and css |
||
| return; | ||
| } | ||
|
|
||
| const parts = email.split("@"); | ||
| const domain = parts[1]; | ||
|
|
||
| if (domain !== "gmail.com" && domain !== "colman.com") { | ||
| error.style.display = "block"; | ||
| return; | ||
| } | ||
|
|
||
| error.style.display = "none"; | ||
| formCard.style.display = "none"; | ||
| successCard.style.display = "flex"; | ||
| }; | ||
|
|
||
| const dismissBtn = document.getElementById("dismissBtn"); | ||
|
Member
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. You should place all of your elements on the top of the file |
||
|
|
||
| dismissBtn.onclick = function () { | ||
| successCard.style.display = "none"; | ||
| formCard.style.display = "flex"; | ||
| }; | ||
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.
colors should come from css vairables