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

Vanilla JS

Chris Young•40
@chrisyoung0101
A solution to the Planets fact site challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Used flexbox for the content (overview, internal structure, & surface geology buttons, planet image, & text). For tablet and desktop, how can I keep the content centered when changing size of screen?

In index.css, is there a better way to handle media queries? My approach seemed to make the css overly complicated.

Used javascript to handle the showing / hiding of content when clicking the overview, internal structure, & surface geology buttons. My solution ended up being a bit bloated. Is there a way to set up a function that could maybe loop through a list of properties that would handle this behavior?

Used js to change the background color for the overview, internal structure, & surface geology buttons when on a specific planet. How could I make this code simpler / less code?

Used js to change the border color for the overview, internal structure, & surface geology buttons in mobile when on a specific planet as well as changing the border color when on tablet / desktop in the nav menu (planet names). How could I make this code simpler / less code?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Davide•1,705
    @Da-vi-de
    Posted almost 4 years ago

    Hi, that's a nice result for this challenge because it's done in plain JS and it's not easy as it seems to be. I get a sense you put all your effort to make it work and it works, so be proud of it! I can't judge all your code because there's a lot to process but i did the same challenge and at least i can answer to one question (which is important i guess) you asked.

    • What we have in this challenge is a "tab component", i dealt with it when i was studying JS a while back and i was taught one of the best way to make it work is taking advantage of a natural process that happens behind the scenes in the DOM, it's a phase called "capturing and bubbling", maybe you are familiar with this concept. By adding the eventListener to the parent element you can tell JS exactly the event.target which are the buttons in our case, the buttons have the attribute data the value is a number, when the code is interpreted it goes down to the end of the parent element (capturing phase) then like boiling water it goes all the way up (bubbling phase) and it stops when it gets to the beginning of the parent element where the event has been fired, so you take as many birds as you want with just one stone. I can copy and paste my code here but it's a lot, so feel free to go to my profile click on my project and inspect github code, take your time because it's not straight forward, especially JS. In case you need to clarify anything about it ask me.

    Hope it helps a little, keep coding :-)

    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