This is a solution to the Newsletter sign-up form with success message challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- Add their email and submit the form
- See a success message with their email after successfully submitting the form
- See form validation messages if:
- The field is left empty
- The email address is not formatted correctly
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
- Solution URL: Newsletter form using Popover API
- Live Site URL: Newsletter form using Popover Api
- Popover Api
- Popover Api polyfill
- HTML Form Validation
- Responsive Design
- Fluid typography
- Responsive images with srcset
- Semantic HTML5 markup
- Vite
- Normalize CSS
- Netlify
- CSS custom properties
- Flexbox
- Mobile-first workflow
A few of what I think were my best code snippets
HTML
<!--using srcset-->
<img
class="...."
srcset="img1.svg 375w,
img2.svg 376w
"
sizes="100%"
src="./assets/images/illustration-sign-up-mobile.svg"
alt="sign up image"
/>
<button
popovertarget="success"
popovertargetaction="show"
class="full-width line-height btn popoverBtn"
><button>
<dialog
class="modal"
id="success"
popover="manual"
></dialog>
<button
class="...."
popovertarget="success"
popovertargetaction="hide"
></button>
CSS
#email:invalid:is(:hover,:focus) {
background-color: var(--tomato-light);
color: var(--tomato-dark);
}
JS
dialog.showPopover();
I still have alot to learn about the popover API, dialog element and the popover polyfill does not work.
- Popover Api Introduction - Great crash course
- Using Popover API - This article covers the Popover API in detail
- Client-side Form Validation - This almost covers all you need for Client-side Form Validation
- Popover API polyfill
- Popover API Explainer - TBR
- Semantic and popover attribute - TBR
- Popover vs Dialog - TBR
- Website - WIP
- Frontend Mentor - @musagenius345
- Twitter - @musabullahi