diff --git a/newsletter-sign-up-with-success-message-main/index.html b/newsletter-sign-up-with-success-message-main/index.html index 8e7329b..a0576be 100644 --- a/newsletter-sign-up-with-success-message-main/index.html +++ b/newsletter-sign-up-with-success-message-main/index.html @@ -4,8 +4,11 @@ + - + + + Frontend Mentor | Newsletter sign-up form with success message @@ -18,35 +21,50 @@ - Stay updated! +
+
+

Stay updated!

+ + +

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

- 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!

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

Email address

valid email required

+ + - Email address - email@company.com + +
+
+
- Subscribe to monthly newsletter +
+ - + - + +

Thanks for subscribing!

- Thanks for subscribing! +

A confirmation email has been sent to ash@loremcompany.com. + Please open it and click the button inside to confirm your subscription.

- A confirmation email has been sent to ash@loremcompany.com. - Please open it and click the button inside to confirm your subscription. +
+
- Dismiss message + +
+
Challenge by Frontend Mentor. - Coded by Your Name Here. + Coded by Shahar Akiva.
\ No newline at end of file diff --git a/newsletter-sign-up-with-success-message-main/script.js b/newsletter-sign-up-with-success-message-main/script.js new file mode 100644 index 0000000..c4fe914 --- /dev/null +++ b/newsletter-sign-up-with-success-message-main/script.js @@ -0,0 +1,41 @@ +//check validity of input +const checkEmailValidity = () => { +let txt = document.querySelector(".mail"); + +// txt.addEventListener("input", () => { + //ok + if (txt.value.includes("@")) { + document.getElementById("errormsg").style.display = "none"; + txt.classList.remove("error"); + return true; + } + //error + else { + document.getElementById("errormsg").style.display = "inline-block"; + txt.classList.add("error"); + return false; + } +// }); +} + +//handles the subscription button +document.getElementById("subscribe").addEventListener("click", () => { + + if (checkEmailValidity()){ + let email = document.querySelector(".mail").value; + document.getElementById("success-card").style.display = "block"; + document.getElementById("first-card").style.display = "none"; + + document.getElementById("customer-mail").textContent = email; + } +}); + +//handles the dismiss button + +document.getElementById("dismiss").addEventListener("click", () => { + + document.getElementById("first-card").style.display = "block"; + document.getElementById("success-card").style.display = "none"; + + document.querySelector(".mail").value = "email@company.com"; +}); \ No newline at end of file diff --git a/newsletter-sign-up-with-success-message-main/style.css b/newsletter-sign-up-with-success-message-main/style.css new file mode 100644 index 0000000..de2ebdf --- /dev/null +++ b/newsletter-sign-up-with-success-message-main/style.css @@ -0,0 +1,228 @@ +html { + background-color: rgb(49, 50, 62); + font-family: "assignmentfont"; +} + + + +.card { + display: flex; + position: absolute; + background-color: white; + border-radius: 15px; + width: 45vw; + height: 50vh; + left: 25vw; + top: 20vh; + padding-left: 3%; + padding-right: 3%; + padding-top: 2.5vh; + padding-bottom: 2.5vh; + font-size: 12px; +} + +.title { + font-size: 40px; +} + +.content { + width: 50%; +} + +.image { + background-image: url("./assets/images/illustration-sign-up-desktop.svg"); + background-repeat: no-repeat; + background-size: contain; + height: 90%; + width: 50%; + top: 5%; + margin-left: 50%; + margin-top: 0; + position: absolute; +} + +.mail { + position: relative; + display: inline-block; + border: 1px solid gray; + width: 92%; + padding: 6% 2% 2% 6%; + resize: none; + font-size: 12px; + color: gray; + border-radius: 8px; + line-height: 100%; + vertical-align: middle; + text-wrap-mode: nowrap; +} + + +.icon { + vertical-align: bottom; + width: 6%; + margin-right: 10px; +} + +p { + margin-right: 5%; +} + +.spacer { + width: 100%; + height: 10px; +} + +.submit { + position: relative; + display: block; + width: 100%; + font-weight: bold; + background-color: rgb(35, 38, 61); + color: white; + border-radius: 8px; + border: none; + cursor: pointer; + padding: 5% 2% 5% 2%; + margin-top: 2%; + font-size: 12px; + transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease; + box-shadow: 0 4px 6px rgba(0,0,0,0.3); +} + +.submit:hover { + background: #fd1d6b; + background: linear-gradient(90deg, rgba(253, 29, 107, 1) 0%, rgba(252, 176, 69, 1) 100%); +} + +.submit:active { + transform: scale(0.95); + transform: translateY(2px); + box-shadow: 0 2px 3px rgba(0,0,0,0.2); +} + +.bold { + font-weight: bold; +} + +#success-card { + display: none; + left: 32vw; + width: 25vw; + height: 40vh; + padding: 5%; +} + +.v-icon { + width: 50px; +} + +.error { + background-color: rgb(255, 239, 239); + border-color: red; + color: red; +} + +span p { + display: inline-block; +} + +#errormsg { + display: none; + position: absolute; + color: red; + text-align: right; + right: 45%; +} + + +@font-face { + font-family: "assignmentfont"; + src: url("./assets/fonts/Roboto-Regular.ttf"); + font-weight: normal; +} + +@font-face { + font-family: "assignmentfont"; + src: url("./assets/fonts/Roboto-Bold.ttf"); + font-weight: bold; /* Or font-weight: bold; */ +} + + +/* Responsive design */ + +@media screen and (max-width: 440px) { + + html { + background-color: white; + } + + .card { + border-radius: 0; + width: 100vw; + height: 100vh; + left: 0; + top: 0; + padding: 0; + } + + .image { + background-image: url("./assets/images/illustration-sign-up-mobile.svg"); + width: 100%; + top: 0; + margin: 0; + padding: 0; + } + + .content { + width: 80%; + position: absolute; + top: 32%; + padding: 10%; + z-index: 2; + font-size: 18px; + } + + .spacer { + height: 5px; + } + + .title { + font-size: 45px; + margin: 5% 0 2% 0; + } + + .mail { + font-size: 18px; + padding: 8% 2% 2% 6%; + } + + .submit { + font-size: 16px; + margin-top: 10px; + } + + #success-card { + left: 0; + width: 80%; + height: 100vh; + padding: 10%; + } + + #success-card p { + font-size: 20px; + } + + .v-icon { + margin-top: 30%; + width: 70px; + } + + #dismiss { + position: relative; + margin-top: 80%; + } + + #errormsg { + right: 20px; + } +} \ No newline at end of file