Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 4 years ago

intro-component-with-signup-form using Sass and Javascript

Brian Carlo Birondo•320
@Briancarlo24
A solution to the Intro component with sign-up form challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Please check if my Javascript is good enough. I am always willing to see the optimal solution and try to learn and apply it.

So please don't hesitate to leave feedbacks :D

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted almost 4 years ago

    Hi

    I’m afraid this doesn’t look right for me viewing on mobile - I’ll add some screenshots to slack for you.

    The content is being cut off on mobile landscape and error messages appear overlapping the input border.

    1. The first issue is because of height 100vh and width 100vw on the body. You never want to restrict height on containers that hold content like that - use min-height where needed instead. I also advise against ever using width 100vw. That is unnecessary as block elements like body are 100% wide by default, and can cause problems because viewport sizes don’t account for things like scrollbars and device notches - including 100vw can actually introduce a horizontal scroll bar
    2. The error message overlap may actually be solved when you fix no1, I’m not sure. I’d need to inspect in browser

    Other suggestions

    • you are heavily nesting css selectors. That’s definitely not advisable and a common mistake when people first start using scss. I recommend only nesting pseudos and media queries so your resultant css stays nice and flat (low specificity)
    • in html are the inputs missing labels?
    • error message elements each need an id and aria-live attribute
    • inputs each need aria-describedby linking to the error id
    • did you consider adding the error icons as background images or pseudo elements? That would be better as they don’t need to clutter up the html. If leaving in html, add aria-hidden or role presentation to those images to make 100% certain they are not announced by screenreaders (apple voiceover will still announce these even though it shouldn’t)
    • never have any text in a div or span alone - use a meaningful element. If in doubt, it’s probably a paragraph
    • use button element not the old input type button
    • if capitalising text, do it in css not the html. Some screenreaders will spell out capitalised text by the letter rather than reading the words
    • if using section element, the section needs a title, preferably with an id. The section element should really then have an aria-labelledby linking to the heading
    • back to css: rather than min width width and margin on the main, why not just have a little padding on the body? It seems over complicated and by adding margin and min width you are potentially conflicting on some mobiles
    • never have any font size declarations in px, that’s important. Convert to rem
    • I know it’s in effort to honour the design, but 10px equivalent (for error messages) is unreadably small and wouldn’t pass accessibility standards. I would challenge that design and have it larger
    • it’s extremely important to have visible focus styles on all interactive elements for users on keyboard
    • letter spacing should be unitless or ems so it always scales with the REM font
    • there appears to be duplication in the media query on this, not sure why (if there is)
    • 376px seems very early to be changing to desktop layout. Is there room for content to be side by side at that point? If not, the media query should be starting at a larger size

    I hope this is helpful for you

    Marked as helpful
  • Marlon Passos•920
    @MarlonPassos-git
    Posted almost 4 years ago

    To try to complement what Grace said,

    • Since you used SASS, you could have taken more advantage of the tool to help you, for example: Instead of typing this
    .header {
      margin-bottom: 4rem;
    
      .header-title {
        color: white;
        font-size: 1.7rem;
        line-height: 1.3;
        margin-bottom: 1.2rem;
      }
    

    you could have typed this

    .header {
      margin-bottom: 4rem;
    
      &-title {
        color: white;
        font-size: 1.7rem;
        line-height: 1.3;
        margin-bottom: 1.2rem;
      }
    
    

    Instead of putting the media queried down there separate from the code, you could have done something like this:

    .section {
    
    .. your code..
    
        @media screen and (min-width: 376px) {
            
            .. your mobile code ..
        }
    }
    

    I particularly prefer it this way because the whole style of my component is together and in the end SASS will leave everything together.

    You happen to repeat some code snippets in different elements, you could put them in an @mixin or in variables, for example the leftover buttons

    I like to put the variables, functions and mixins in another separate file, for me it's more organized

    Marked as helpful

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub