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

REST countries API using React and Styled Components

Baldassare Pugliese•130
@bpa03
A solution to the REST Countries API with color theme switcher challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I would like to hear your feedback :)

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Raymart Pamplona•16,040
    @pikapikamart
    Posted almost 4 years ago

    Hey, really awesome work on this one. Desktop layout is really great, it is responsive and the mobile state looks really great as well.

    Some suggestions would be:

    • Your Where in the world? is pointing to "/" which is the home route that is why it is better to add aria-label="homepage" so that users will know where this link would take them, since Where in the world? is not descriptive enough to where it would take users.
    • Your toggle works but not really accessible. Remember, interactive components uses interactive elements. By using div you are making it not-accessible.
    • A proper markup for the toggle should be to use 2 radio buttons which are nested inside a fieldset along with a screen-reader only legend element, that will describe what is the purpose of the radio buttons. Take a look at this solution of mine for this challenge see the structure for the toggle.
    • Always have a main element to wrap the main content of your page. On this one, you should have used a:
    <header />
    <main />
    

    site structure.

    • Your input tag lacks an associated label tag on it. You can use the placeholder's text as the value for the label text-content. The label will be screen-reader only or you can use aria-label attribute on the input.
    • Your dropdown as well is not accessible at the moment. Again, interactive components. You can see and take a look at my dropdown as well but it is customized since I don't want to use select tag . But if you don't want my structuring, you can use select so that it will be accessible.
    • Each country flag-image should be using the country's name as the value with the "flag" word like Philippines flag so that it will be descriptive enough.
    • Also when using alt attribute, avoid using words that relates to "graphic" such as "image" and others. An img is already an image/graphic so no need to describe it as one.
    • A page must have a single h1 on a page. Since there are no text-content that are visible that could be h1, you will make the h1 screen-reader only text. Meaning this will be hidden for sighted users and only be visible for screen-reader users, search about sr-only stylings and see how it is used. The h1 text should describe what is the main content is all about, this h1 would be placed as the first text-content inside the main element.
    • Also on this one, wrapping every country-card inside an a tag is not ideal. What you could have made is that the img could be nested in the a tag or the country name has:
    <h2>
      <a> country name </a>
    </h2>
    

    So that it will use a more proper markup. Then if you wan the whole card to be clickable, you can just set the a tag's ::before to fill the whole height-and-width of the card so that you can click anywhere to toggle the link.

    • Those 3 information on each card could have used ul tag since those are "list" of information. You can nest it inside a section with a screen-reader heading tag, that defines what are those list of items.

    SELECTING A COUNTRY

    • The country-flag img should be using a proper alt value.
    • Use a ul tag on those information, again they are "list" of information about the selected country. Whenever you see sections like there where there are list of items, use ul.
    • Also, the border-countries are missing. You might want to look at that one.

    Aside from those, really great job again on this one.

    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

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.

Oops! 😬

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

Log in with GitHub